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

ilias Georgakopoulos
ilias Georgakopoulos
22,866 Points

What 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:inblock 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:inblock 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:inblock (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:inblock 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:inblock 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:inblock (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:inblock 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:inblock 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:inblock 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:inblock 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
ilias Georgakopoulos
22,866 Points

I found the problem. I messed up the positions of the "end" in the user_friendship_test.rb.

Before: http://briefcase.pathfinder.gr/download/623644

After: http://briefcase.pathfinder.gr/download/623646