Simply Rails 2, pg 242 testing problem
I don't know if anyone else going through the book has had this problem, hopefully someone can help me out!
I've just run (as on pg 242) after adding the tests to test a vote's relationship to a story and the voting history order, and rather than all the tests passing, like in the screenshot, I've got 3 failures!
I don't think I'm good enough to understand the errors I got given. Can anybody please help me?!
Code:
Macintosh-9:shovell Laura$ rake test:units
(in /Users/Laura/shovell)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:test "/Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb" "test/unit/story_test.rb" "test/unit/vote_test.rb"
Loaded suite /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader
Started
..F..FF
Finished in 0.127123 seconds.
1) Failure:
test_should_have_a_votes_association(StoryTest)
[./test/unit/story_test.rb:23:in `test_should_have_a_votes_association'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in `__send__'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in `run']:
<[#<Vote id: 953125641, story_id: 1, created_at: "2008-07-11 13:25:45", updated_at: "2008-07-11 13:25:45">,
#<Vote id: 996332877, story_id: 1, created_at: "2008-07-11 13:25:45", updated_at: "2008-07-11 13:25:45">]> expected but was
<[]>.
2) Failure:
test_should_return_highest_vote_id_first(StoryTest)
[./test/unit/story_test.rb:27:in `test_should_return_highest_vote_id_first'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in `__send__'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in `run']:
<#<Vote id: 996332877, story_id: 1, created_at: "2008-07-11 13:25:45", updated_at: "2008-07-11 13:25:45">> expected but was
<nil>.
3) Failure:
test_story_association(VoteTest)
[./test/unit/vote_test.rb:5:in `test_story_association'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in `__send__'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in `run']:
<#<Story id: 953125641, name: "My shiny weblog", link: "http://poocs.net/", created_at: "2008-07-11 13:25:45", updated_at: "2008-07-11 13:25:45">> expected but was
<nil>.
7 tests, 7 assertions, 3 failures, 0 errors
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]