Created
January 1, 2014 01:32
-
-
Save jacqueline-homan/8204014 to your computer and use it in GitHub Desktop.
Unable to get this part of the testing in the TDD todo app to work for me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CompletionsController < ApplicationController | |
def create | |
todo = Todo.find(params[:todo_id]) | |
todo.touch :completed_at | |
redirect_to todos_path | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<% @todos.each do |todo| %> | |
<li class= 'todo<%= 'completed' if todo.completed_at? %>' > | |
<%= todo.description %> | |
<%= link_to 'Complete', todo_completion_path(todo), method: :post %> | |
</li> | |
<% end %> | |
</ul> | |
<%= link_to 'Add new todo', new_todo_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
feature 'Manage todos' do | |
scenario 'create new todo' do | |
sign_in | |
create_todo_with_description 'Read three chapters of RSpec book' | |
user_sees_todo_item 'Read three chapters of RSpec book' | |
# RSpec deletes all the todos from the database | |
end | |
scenario 'view only my todos' do | |
# todo = Todo.where(description: 'Read three chapters of RSpec book').first | |
# expect(todo).to be_nil | |
sign_in | |
create(:todo, description: 'Buy coffee cream', owner_email: 'not_me@example.com') | |
user_does_not_see_todo_item 'Buy coffee cream' | |
end | |
scenario 'denote completed todos' do | |
sign_in | |
create_todo_with_description 'Buy coffee cream' | |
within 'li.todo' do | |
click_link 'Complete' | |
end | |
expect(page).to have_css 'li.todo.completed' | |
end | |
def create_todo_with_description(description) | |
click_link 'Add new todo' | |
fill_in 'Description', with: description | |
click_button 'Create todo' | |
end | |
def user_sees_todo_item(description) | |
expect(page).to have_css 'li.todo', text: description | |
end | |
def user_does_not_see_todo_item(description) | |
expect(page).not_to have_css 'li.todo', text: description | |
end | |
## The following def block was moved into a module | |
## to keep our features nice and slim. | |
## The logic for signing in is in a module | |
## that can be managed separately, so if the logic for | |
## signing in changes, it's all contained in the | |
## SignInHelpers module under spec/support. | |
# def sign_in | |
# visit root_path | |
# fill_in 'Email address', with: 'person@email.com' | |
# click_button 'Sign In' | |
# end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Todos::Application.routes.draw do | |
root to: 'high_voltage/pages#show', id: 'home' | |
resource :session, only: [:create] | |
resources :todos, only: [:index, :new, :create] do | |
resource :completion, only: [:create] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ todos git:(master) ✗ rake routes | |
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0 | |
root / high_voltage/pages#show {:id=>"home"} | |
session POST /session(.:format) sessions#create | |
todo_completion POST /todos/:todo_id/completion(.:format) completions#create | |
todos GET /todos(.:format) todos#index | |
POST /todos(.:format) todos#create | |
new_todo GET /todos/new(.:format) todos#new | |
page GET /pages/*id high_voltage/pages#show | |
➜ todos git:(master) ✗ rspec spec/integration/manage_todos_spec.rb:23 | |
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0 | |
Run options: include {:locations=>{"./spec/integration/manage_todos_spec.rb"=>[23]}} | |
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. | |
F | |
Failures: | |
1) Manage todos denote completed todos | |
Failure/Error: expect(page).to have_css 'li.todo.completed' | |
expected css "li.todo.completed" to return something | |
# ./spec/integration/manage_todos_spec.rb:31:in `block (2 levels) in <top (required)>' | |
Finished in 0.29813 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/integration/manage_todos_spec.rb:23 # Manage todos denote completed todos | |
Randomized with seed 13015 | |
➜ todos git:(master) ✗ rspec spec/integration/manage_todos_spec.rb:23 | |
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0 | |
Run options: include {:locations=>{"./spec/integration/manage_todos_spec.rb"=>[23]}} | |
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. | |
F | |
Failures: | |
1) Manage todos denote completed todos | |
Failure/Error: click_button 'Create todo' | |
ActionView::Template::Error: | |
undefined method `completed?' for #<Todo:0x000000050ea948> | |
# ./app/views/todos/index.html.erb:3:in `block in _app_views_todos_index_html_erb__3364276476556946193_43849380' | |
# ./app/views/todos/index.html.erb:2:in `_app_views_todos_index_html_erb__3364276476556946193_43849380' | |
# (eval):2:in `click_button' | |
# ./spec/integration/manage_todos_spec.rb:39:in `create_todo_with_description' | |
# ./spec/integration/manage_todos_spec.rb:25:in `block (2 levels) in <top (required)>' | |
Finished in 0.27912 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/integration/manage_todos_spec.rb:23 # Manage todos denote completed todos | |
Randomized with seed 61706 | |
➜ todos git:(master) ✗ rspec spec/integration/manage_todos_spec.rb:23 | |
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0 | |
Run options: include {:locations=>{"./spec/integration/manage_todos_spec.rb"=>[23]}} | |
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. | |
F | |
Failures: | |
1) Manage todos denote completed todos | |
Failure/Error: expect(page).to have_css 'li.todo.completed' | |
expected css "li.todo.completed" to return something | |
# ./spec/integration/manage_todos_spec.rb:31:in `block (2 levels) in <top (required)>' | |
Finished in 0.29148 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/integration/manage_todos_spec.rb:23 # Manage todos denote completed todos | |
Randomized with seed 48061 | |
➜ todos git:(master) ✗ rspec spec/integration/manage_todos_spec.rb:23 | |
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0 | |
Run options: include {:locations=>{"./spec/integration/manage_todos_spec.rb"=>[23]}} | |
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. | |
F | |
Failures: | |
1) Manage todos denote completed todos | |
Failure/Error: expect(page).to have_css 'li.todo.completed' | |
expected css "li.todo.completed" to return something | |
# ./spec/integration/manage_todos_spec.rb:31:in `block (2 levels) in <top (required)>' | |
Finished in 0.29129 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/integration/manage_todos_spec.rb:23 # Manage todos denote completed todos | |
Randomized with seed 57816 | |
➜ todos git:(master) ✗ rspec spec/integration/manage_todos_spec.rb:23 | |
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0 | |
Run options: include {:locations=>{"./spec/integration/manage_todos_spec.rb"=>[23]}} | |
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. | |
F | |
Failures: | |
1) Manage todos denote completed todos | |
Failure/Error: expect(page).to have_css 'li.todo.completed' | |
expected css "li.todo.completed" to return something | |
# ./spec/integration/manage_todos_spec.rb:31:in `block (2 levels) in <top (required)>' | |
Finished in 0.2939 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/integration/manage_todos_spec.rb:23 # Manage todos denote completed todos | |
Randomized with seed 9038 | |
➜ todos git:(master) ✗ rspec spec/integration/manage_todos_spec.rb:23 | |
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0 | |
Run options: include {:locations=>{"./spec/integration/manage_todos_spec.rb"=>[23]}} | |
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. | |
F | |
Failures: | |
1) Manage todos denote completed todos | |
Failure/Error: expect(page).to have_css 'li.todo.completed' | |
expected css "li.todo.completed" to return something | |
# ./spec/integration/manage_todos_spec.rb:31:in `block (2 levels) in <top (required)>' | |
Finished in 0.291 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/integration/manage_todos_spec.rb:23 # Manage todos denote completed todos | |
Randomized with seed 27598 | |
➜ todos git:(master) ✗ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment