Created
November 1, 2008 15:13
-
-
Save dbussink/21536 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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