Sha256: 1d0979c10b742acb913fe863e942055c25899665ef7218d1ac934c00fffc21b4

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
datts_right-0.0.23 spec/datts_right/add_definition_spec.rb
datts_right-0.0.22 spec/datts_right/add_definition_spec.rb
datts_right-0.0.21 spec/datts_right/add_definition_spec.rb
datts_right-0.0.20 spec/datts_right/add_definition_spec.rb