For example, I have this scenario where a Directory model will only save if it can connect to the LDAP server. In a test I'm writting, though, connecting to the LDAP server is not relevant, so I tried doing this:
context "LDAP is on" do before(:each) do Directory.stub!(:authenticate_user).and_return(@user). @account.directory = Directory.make :ldap_on end ... end However, the Directory.make fails (since the before_save ldap test fails, because authenticate_user can't connect to the LDAP server). The issue is that it stubs the method as a singleton method of Directory. One alternative is opening the Directory class and redefining the authenticate_user method, but I'd like to know if rSpec supports somehow stubing a class and let it stub instance too. Cheers, Marcelo.
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users