Skip to content

Instantly share code, notes, and snippets.

@mfurtak
Created February 8, 2011 00:50
Show Gist options
  • Save mfurtak/815621 to your computer and use it in GitHub Desktop.
Save mfurtak/815621 to your computer and use it in GitHub Desktop.
Testing poetry
describe User, 'as creator' do
subject { Factory(:user) }
let(:object) { mock 'arbitrary object' }
it "did not create another object when the object does not have a creator_id" do
subject.should_not be_creator_of(object)
end
it "did not create another object when the object's creator_id does not match" do
object.should_receive(:creator_id).and_return(subject.id + 1)
subject.should_not be_creator_of(object)
end
it "created another object when its creator_id matches" do
object.should_receive(:creator_id).and_return(subject.id)
subject.should be_creator_of(object)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment