Skip to content

Instantly share code, notes, and snippets.

@dbussink
Created November 1, 2008 15:13
Show Gist options
  • Save dbussink/21536 to your computer and use it in GitHub Desktop.
Save dbussink/21536 to your computer and use it in GitHub Desktop.
share_examples_for 'A Resource' do
before do
%w[ @article ].each do |ivar|
raise "+#{ivar}+ should be defined in before block" unless instance_variable_get(ivar)
end
end
it 'should respond to #save' do
@article.should respond_to(:save)
end
describe '#save' do
it 'should return true even when resource is not dirty' do
@article.save.should be_true
end
it 'should save a resource succesfully when dirty' do
@article.title = "Completely different title"
@article.save.should be_true
@article.reload
@article.title.should eql("Completely different title")
end
it 'should not save a resource when it\'s invalid'
end
it 'should respond to #destroy' do
@article.should respond_to(:destroy)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment