I’m building an app while following a tutorial in the book Simply Rails 2 and am having trouble getting some tests to pass.
Here are the errors I’m receiving:
1) Failure:
test_should_show_index(StoriesControllerTest)
[/Users/ryanclark/Projects/shovell/test/functional/stories_controller_test.rb:8:in `test_should_show_index'
/Users/ryanclark/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.0.2/lib/active_support/testing/default.rb:7:in `run']:
<nil> expected to not be nil.
2) Failure:
test_should_show_navigation_menu(StoriesControllerTest)
[/Users/ryanclark/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.0.2/lib/action_controller/assertions/selector_assertions.rb:297:in `assert_select'
/Users/ryanclark/Projects/shovell/test/functional/stories_controller_test.rb:44:in `test_should_show_navigation_menu'
/Users/ryanclark/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.0.2/lib/active_support/testing/default.rb:7:in `run']:
Expected at least 2 elements matching "#navigation li", found 3.
<false> is not true.
3) Failure:
test_should_show_new_form(StoriesControllerTest)
[/Users/ryanclark/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.0.2/lib/action_controller/assertions/selector_assertions.rb:297:in `assert_select'
/Users/ryanclark/Projects/shovell/test/functional/stories_controller_test.rb:18:in `test_should_show_new_form'
/Users/ryanclark/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.0.2/lib/active_support/testing/default.rb:7:in `run']:
Expected at least 3 elements matching "form p", found 4.
<false> is not true.
My project is on Github and I would really appreciate a little insight if someone would take a look and help me out.
Also, I’m happy to provide more details and code, just trying to keep the post short.
Failure 1: In test ‘test_should_show_index’ at line 8
assert_not_nil assigns(:stories).You have no stores with ‘votes_count >= 5’ in your test database. Here is your fixture for Stories (stories.yml):
All stories have default value for votes_count (it is 0, see db/schema.rb, line 20). You need at least one story to have votes_count >= 5, thus change fixture to something like this:
Failure 2: In test ‘test_should_show_navigation_menu’ at line 44
assert_select '#navigation li', 2Your navigation div has 3 child
<li>tags instead of 2 expected (see application.html.erb):Failure 3: In test ‘test_should_show_new_form’ at line 18
assert_select 'form p', :count => 3.Your form contains 4
<p>tags instead of 3 expected. You can find it inside your template for ‘new’ action method (new.html.erb):Hope this helps.