Skip to content

Instantly share code, notes, and snippets.

@zdenal
Created February 27, 2010 16:29
Show Gist options
  • Save zdenal/316807 to your computer and use it in GitHub Desktop.
Save zdenal/316807 to your computer and use it in GitHub Desktop.
require 'spec_helper'
share_as :SetCallbacks do
before(:each) do
@valid_attributes = {
:name => 'Forms'
}
@tag = Tag.new(@valid_attributes)
end
end
describe Tag, "Create" do
include SetCallbacks
it "should create a new instance given valid attributes" do
@tag.should be_valid
Tag.all.should have(0).items
lambda{@tag.create}.should change{ Tag.all.size }.by(1)
end
it "should not be valid" do
@tag = Tag.new
@tag.valid?
@tag.errors.values.should have(1).items
@tag.errors.on(:name).should have(1).items
end
it "should not create tag with exist name" do
Tag.all.should have(1).items
lambda{@tag.create}.should_not change{Tag.all.size}
@tag.errors.on(:name).should have(1).items
end
end
describe Tag, "Update" do
include SetCallbacks
it "test" do
@tag.should be_valid
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment