Mock

let(:user) { mock_model(User) }
works

it “should mock a user” do
@user = mock_model(User)
end
works

before(:all) do
@user = mock_model(user)
end
fails

before(:each) block { a=mock(User)
works

Mocks are implicitly verified and cleared out after(:each) so they won’t work in before(:all).

mock doesnot work in an example group (describe() block), but it works in an example (it() block).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s