I run the command: ruby test/unit/user_test.rb I get the error: NoMethodError: undefined method `authenticate'' for #<Class:0x193dd20> C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base .rb:1959:in `method_missing'' test/unit/user_test.rb:13:in `test_auth'' The authenticate method is defined in This is denition of authenticate method in modes/user.rb class UserTest < ActiveSupport::TestCase # Replace this with your real tests. # test "the truth" do # assert true self.use_instantiated_fixtures = true fixtures :users def self.authenticate(login, pass) u=find(:first, :conditions=>["login = ?", login]) return nil if u.nil? return u if User.encrypt(pass, u.salt)==u.hashed_password nil end This is where it is called from user_test.rb def test_auth assert_equal @bob, User.authenticate("rao", "test") end username rao is already defined in users.yml Can someone please tell me how to fix this? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sorry, there was a mistake in my posting. The correction to user_test.rb def test_auth assert_equal @rao, User.authenticate("rao", "test") end where user rao has been defined in users.yml I get this error NoMethodError: undefined method `authenticate'' When the method ''authenticate'' is already defined. Why is it unable to find the method? Vishwa Rao wrote:> I run the command: ruby test/unit/user_test.rb > > I get the error: > NoMethodError: undefined method `authenticate'' for #<Class:0x193dd20> > C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base > .rb:1959:in `method_missing'' > test/unit/user_test.rb:13:in `test_auth'' > The authenticate method is defined in > > This is denition of authenticate method in modes/user.rb > class UserTest < ActiveSupport::TestCase > # Replace this with your real tests. > # test "the truth" do > # assert true > self.use_instantiated_fixtures = true > fixtures :users > def self.authenticate(login, pass) > u=find(:first, :conditions=>["login = ?", login]) > return nil if u.nil? > return u if User.encrypt(pass, u.salt)==u.hashed_password > nil > end > > This is where it is called from user_test.rb > def test_auth > assert_equal @bob, User.authenticate("rao", "test") > end > > username rao is already defined in users.yml > > Can someone please tell me how to fix this?-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2010/1/25 Vishwa Rao <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> I run the command: ruby test/unit/user_test.rb > > I get the error: > NoMethodError: undefined method `authenticate'' for #<Class:0x193dd20> > C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base > .rb:1959:in `method_missing'' > test/unit/user_test.rb:13:in `test_auth'' > The authenticate method is defined in > > This is denition of authenticate method in modes/user.rb > class UserTest < ActiveSupport::TestCase > # Replace this with your real tests. > # test "the truth" do > # assert true > self.use_instantiated_fixtures = true > fixtures :users > def self.authenticate(login, pass)You have this inside class UserTest instead of User Colin> u=find(:first, :conditions=>["login = ?", login]) > return nil if u.nil? > return u if User.encrypt(pass, u.salt)==u.hashed_password > nil > end > > This is where it is called from user_test.rb > def test_auth > assert_equal @bob, User.authenticate("rao", "test") > end > > username rao is already defined in users.yml > > Can someone please tell me how to fix this? > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.