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!
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

ilias Georgakopoulos
22,866 PointsWhat is a State Machine? rake db:test:prepare problem
c:\treebook>ruby -Itest test/unit/user_friendship_test.rb Run options:
Running tests:
..EEEE..
Finished tests in 0.250014s, 31.9982 tests/s, 15.9991 assertions/s.
1) Error:
test: UserFriendship should have a pending state. (UserFriendshipTest):
NoMethodError: undefined method state' for nil:NilClass
test/unit/user_friendship_test.rb:26:in
block in <class:UserFriendshipTest>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/shoulda-context-1.1.4/lib/shoulda/context/c
ontext.rb:400:in call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/shoulda-context-1.1.4/lib/shoulda/context/c
ontext.rb:400:in
block in create_test_from_should_hash'
2) Error:
test: UserFriendship should send an acceptance email. (UserFriendshipTest):
NoMethodError: undefined method accept!' for nil:NilClass
test/unit/user_friendship_test.rb:54:in
block (2 levels) in <class:UserFriendshipTest>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/tes
ting/assertions.rb:55:in assert_difference'
test/unit/user_friendship_test.rb:53:in
block in <class:UserFriendshipTest>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/shoulda-context-1.1.4/lib/shoulda/context/c
ontext.rb:400:in call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/shoulda-context-1.1.4/lib/shoulda/context/c
ontext.rb:400:in
block in create_test_from_should_hash'
3) Error:
test: UserFriendship should send an email. (UserFriendshipTest):
NoMethodError: undefined method send_request_email' for nil:NilClass
test/unit/user_friendship_test.rb:37:in
block (2 levels) in <class:UserFriendshipTest>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/tes
ting/assertions.rb:55:in assert_difference'
test/unit/user_friendship_test.rb:36:in
block in <class:UserFriendshipTest>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/shoulda-context-1.1.4/lib/shoulda/context/c
ontext.rb:400:in call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/shoulda-context-1.1.4/lib/shoulda/context/c
ontext.rb:400:in
block in create_test_from_should_hash'
4) Error:
test: UserFriendship should set the state to accepted. (UserFriendshipTest):
NoMethodError: undefined method accept!' for nil:NilClass
test/unit/user_friendship_test.rb:48:in
block in <class:UserFriendshipTest>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/shoulda-context-1.1.4/lib/shoulda/context/c
ontext.rb:400:in call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/shoulda-context-1.1.4/lib/shoulda/context/c
ontext.rb:400:in
block in create_test_from_should_hash'
8 tests, 4 assertions, 0 failures, 4 errors, 0 skips
c:\treebook>
I can't get these tests to pass. I am sure that has to do with the test db but i can't find the problem. When i run rake db:test:prepare it seems i don't get any errors but when i run bin/rake db:test:prepare i get the following error.
c:\treebook>bin/rake db:test:prepare 'bin' is not recognized as an internal or external command, operable program or batch file. (the bin folder exists in the treebook folder with all the files in it.)
user_friendship_test.rb file. http://briefcase.pathfinder.gr/download/623644
user_friendship.rb file. http://briefcase.pathfinder.gr/download/623645
Any ideas? Thanks in advance.
c:\treebook>
1 Answer

ilias Georgakopoulos
22,866 PointsI found the problem. I messed up the positions of the "end" in the user_friendship_test.rb.