Sha256: 80af2acde856e09f3128d620be9e906596a8916949ea94463be66d462848de4e
Contents?: true
Size: 1.41 KB
Versions: 6
Compression:
Stored size: 1.41 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe DattsRight, ".add_definition(key, value)" do before do reset_database end it "should add a definition to the existing definition" do c = Category.create c.definition = {:robot => {:object_type => "string"}} c.save c.add_definition(:name, :object_type => "string", :description => "This is great") c.save c.definition[:name].should == {:object_type => "string", :description => "This is great"} end it "should raise DattsRight::AttributeAlreadyExists if the attribute is already there" do c = Category.create c.definition = {:robot => {:object_type => "string"}} c.save lambda {c.add_definition(:robot, "whatever")}.should raise_error(DattsRight::AlreadyDefined, "robot is already defined") end it "should raise NoMethodError if it doesn't have definition => true" do lambda {Page.create.add_definition(:fake, :object_type => "string")}.should raise_error(DattsRight::NoDefinitionError) end it "should raise AttributeKeyRequired if no attr_key is passed" do lambda {Page.create.add_definition(nil, {})}.should raise_error(DattsRight::AttributeKeyRequired) end it "should be able to handle if definition is nil" do c = Category.create c.definition = nil c.save lambda {c.add_definition(:real, :object_type => "string")}.should_not raise_error(NoMethodError) end end
Version data entries
6 entries across 6 versions & 1 rubygems