Sha256: eab70937b5ba14d658f044f517831cf4355383d22366b1ccfddd27813dc95f25
Contents?: true
Size: 1.97 KB
Versions: 2
Compression:
Stored size: 1.97 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 not raise AlreadyDefined if the attr_key is the same" do c = Category.create c.definition = {:robot => {:object_type => "string"}} lambda {c.update_definition(:robot, :attr_key => "robot")}.should_not raise_error(DattsRight::AlreadyDefined) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
datts_right-0.0.32 | spec/datts_right/update_definition_spec.rb |
datts_right-0.0.31 | spec/datts_right/update_definition_spec.rb |