Sha256: d2be4c84250b3205b563094c0f7c12b330ad6999463936886d1846242304a962
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe DattsRight, ".update_definition(key, value)" do before do reset_database end it "should update attr_key of a definition" do c = Category.create c.definition = {:robot => {:object_type => "string"}} c.update_definition(:robot, :attr_key => "bodi") c.definition[:robot].should be_nil c.definition[:bodi].should == {:object_type => "string"} end it "should update attr_key of a definition even if it's not symbolized" do c = Category.create c.definition = {:robot => {:object_type => "string"}} c.update_definition(:robot, "attr_key" => "bodi") c.definition[:robot].should be_nil c.definition[:bodi].should == {:object_type => "string"} end it "should be able to update the rest (all except attr_key) of the definition" do c = Category.create c.definition = {:robot => {:object_type => "string", :desc => "hi"}} c.update_definition(:robot, :object_type => "integer", :desc => "wyt") c.definition[:robot].should == {:object_type => "integer", :desc => "wyt"} end it "should raise NotDefinedError if it doesn't exist" do lambda {Category.create.update_definition(:robot, {})}.should raise_error(DattsRight::NotDefinedError, "robot is not defined") end it "should raise NoDefinitionError if it doesn't have definition => true" do lambda {Page.create.update_definition(:fake, {})}.should raise_error(DattsRight::NoDefinitionError) end it "should be able to handle if definition is nil" do c = Category.create c.definition = nil c.save lambda {c.update_definition(:real, :object_type => "string")}.should raise_error(DattsRight::NotDefinedError) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datts_right-0.0.30 | spec/datts_right/update_definition_spec.rb |