Hi,
The methods I´ve put in GenericMessageFunctions are available and working within the Rails app, but I can´t access them from my tests. Why isn´t User.find() available from the GenericMessageFunctions module when it´s accessed trough a test? Should I include some library to get it working?
$ ruby test/unit/tweet_test.rb
1) Error: test_redelegating_ownership(TweetTest): TypeError: can't dump anonymous class Class /opt/local/lib/ruby/1.8/yaml/rubytypes.rb:6:in `to_yaml' whenever/gems/activerecord-2.3.8/lib/active_record/ connection_adapters/abstract/quoting.rb:31:in `quote' whenever/gems/activerecord-2.3.8/lib/active_record/ connection_adapters/mysql_adapter.rb:236:in `quote' whenever/gems/activerecord-2.3.8/lib/active_record/base.rb:1443:in `quote_value' whenever/gems/activerecord-2.3.8/lib/active_record/base.rb:1608:in `find_one' whenever/gems/activerecord-2.3.8/lib/active_record/base.rb:1599:in `find_from_ids' whenever/gems/activerecord-2.3.8/lib/active_record/base.rb:619:in `find' lib/generic_message_functions.rb:4:in `delegate_to' test/unit/tweet_test.rb:62:in `test_redelegating_ownership' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/ active_support/testing/setup_and_teardown.rb:62:in `__send__' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/ active_support/testing/setup_and_teardown.rb:62:in `run'
1 module GenericMessageFunctions 2 3 def delegate_to(user_id, *msg_note) 4 new_user = User.find(user_id) 5 self.delegated_to = user_id 6 self.save 7 end 8 9 end
## tweet_test
test "redelegating ownership" do tweet = Tweet.make(:user_id => 63) user = User.make(:id => 83)
tweet.delegate_to(User) assert(tweet.delegated_to, 83) end
## Tweet.rb
require 'generic_message_functions.rb' include GenericMessageFunctions
class Tweet < ActiveRecord::Base end