For example, I have this scenario where a Directory model will only save
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
@account.directory = Directory.make :ldap_on
However, the Directory.make fails (since the before_save ldap test
because authenticate_user can’t connect to the LDAP server). The issue
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.