Sha256: 4b1d6e270ecb3a65b979731354f43a3197eea557edd1294c790366df0e5fc63c

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datts_right-0.0.26 spec/datts_right/add_definition_spec.rb
datts_right-0.0.25 spec/datts_right/add_definition_spec.rb
datts_right-0.0.24 spec/datts_right/add_definition_spec.rb