Mocks and Associations

Hi List,

I am doing some testing which involves an authentication method on my
user controller. In production it actually uses PAM (on my linux system
to an external LDAP server) to authenticate users but this is
impractical for my testing. To get to the point I have:

require ‘pam’

class User < ActiveRecord::Base
has_many :blah

def authenticate(password)
# some pam voodoo here

In my test/mocks/test directory I have:

require ‘models/user’

class User < ActiveRecord::Base
def authenticate(pass)
pass == Digest::MD5.hexdigest(self.password)

However, whenever I run this test my associations fail. Does anyone
have any suggestions?



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs