Sha256: e26cd083832db3fce58f77ef4801d5d901d0d13b3f7128b6b57f7fb58ad4e075
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe DattsRight, ".add_definitions(hash)" do before do reset_database end it "should add a definition to the existing definition" do c = Category.create c.should_receive(:add_definition).with(:robot, :object_type => "text") c.should_receive(:add_definition).with(:another, :object_type => "string") c.add_definitions(:robot => {:object_type => "text"}, :another => {:object_type => "string"}) end it "should accept 'flat' hashes in an array (straight from a form)" do # [{"name"=>"A key", "description"=>"asd", "attr_key"=>"a_key"}, {"name"=>"A key", "description"=>"asd", "attr_key"=>"b_key"}] c = Category.create c.should_receive(:add_definition).with(:a_key, {:name=>"A key"}) c.should_receive(:add_definition).with(:b_key, {:name=>"B key"}) c.add_definitions({"name"=>"A key", "attr_key"=>"a_key"}, {"name"=>"B key", "attr_key"=>"b_key"}) c = Category.create c.should_receive(:add_definition).with(:a_key, {:name=>"A key"}) c.should_receive(:add_definition).with(:b_key, {:name=>"B key"}) c.add_definitions([{"name"=>"A key", "attr_key"=>"a_key"}, {"name"=>"B key", "attr_key"=>"b_key"}]) end it "should not explode if nil is passed" do lambda {Category.create.add_definitions(nil)}.should_not raise_error(NoMethodError) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datts_right-0.0.25 | spec/datts_right/add_definitions_spec.rb |