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 Validating Length

Que Sengmany
Que Sengmany
12,213 Points

rspec testing still failing

I've followed the instructions as per the video with exactly the same contect for my todo_list.rb and create_spec.rb and still getting 2 failures.

[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. .FF

Failures:

1) Creating todo lists displays an error when the todo list has no title Failure/Error: expect(page).to have_content("This is what I'm doing today.") expected to find text "This is what I'm doing today." in "Listing todo_lists Title Description New Todo list" # ./spec/features/todo_lists/create_spec.rb:31:in `block (2 levels) in <top (required)>'

2) Creating todo lists displays an error when the todo list has a title less than 3 characters Failure/Error: expect(page).to have_content("This is what I'm doing today.") expected to find text "This is what I'm doing today." in "Listing todo_lists Title Description New Todo list" # ./spec/features/todo_lists/create_spec.rb:49:in `block (2 levels) in <top (required)>'

Finished in 1.62 seconds 3 examples, 2 failures

Failed examples:

rspec ./spec/features/todo_lists/create_spec.rb:16 # Creating todo lists displays an error when the todo list has no title rspec ./spec/features/todo_lists/create_spec.rb:34 # Creating todo lists displays an error when the todo list has a title less than 3 characters

Randomized with seed 39971

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Please show us your code for your todo_list model, controller, view and the spec that fails. Ideally, if you put your code on github and link it here, I will be able to test it on my machine and look for problems.

1 Answer

David O' Rojo
David O' Rojo
11,051 Points

Look at the error message:

Creating todo lists displays an error when the todo list has no title Failure/Error: expect(page).to have_content("This is what I'm doing today.")

When the error is displayed it should be expected that the new todo list is not created, therefore no content from the todo list should be displayed. To test that, change the expect(page).to expectations to expect(page).not_to.