Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Editing Todo Items

Getting 3 failures editing to_do lists

nearly getting the hang of this but can't work this one out

something relating to the ("#todo_item_#{todo_item.id}") line ?

any ideas

git https://github.com/neilp666/todo2015

Editing todo lists is unsuccessful with not enough content (FAILED - 1) is unsuccessful with no content (FAILED - 2) is successful with valid content (FAILED - 3)

Failures:

1) Editing todo lists is unsuccessful with not enough content Failure/Error: within("#todo_item_#{todo_item.id}") do NameError: undefined local variable or method todo_item' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fb8b56a33b0> # ./spec/features/todo_items/edit_spec.rb:46:inblock (2 levels) in <top (required)>'

2) Editing todo lists is unsuccessful with no content Failure/Error: within("#todo_item_#{todo_item.id}") do NameError: undefined local variable or method todo_item' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fb8b85e9728> # ./spec/features/todo_items/edit_spec.rb:32:inblock (2 levels) in <top (required)>'

3) Editing todo lists is successful with valid content Failure/Error: within("#todo_item_#{todo_item.id}") do NameError: undefined local variable or method todo_item' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fb8b8721398> # ./spec/features/todo_items/edit_spec.rb:17:inblock (2 levels) in <top (required)>'

Finished in 0.52455 seconds 3 examples, 3 failures

Failed examples:

rspec ./spec/features/todo_items/edit_spec.rb:44 # Editing todo lists is unsuccessful with not enough content rspec ./spec/features/todo_items/edit_spec.rb:30 # Editing todo lists is unsuccessful with no content rspec ./spec/features/todo_items/edit_spec.rb:15 # Editing todo lists is successful with valid content

Randomized with seed 16149

Neils-MacBook-Pro-2:todo2015 neilpatel$

1 Answer

Seth Reece
Seth Reece
32,867 Points

Hi Neil,

You need to set a todo item in your spec just as you did a todo list. E.g.

let!(:todo_item) { todo_list.todo_items.create(content: "Milk") }