Sha256: b83aa7861169ddfa95a081a77e3a372ba9e81ceb6c66e1bfcfe62ec72235b119
Contents?: true
Size: 1.67 KB
Versions: 18
Compression:
Stored size: 1.67 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe DattsRight do before do reset_database @page = Page.create end describe ".add_dynamic_attribute(attr_key, object_type)" do it "should be aliased by add_datt" do Page.instance_method(:add_dynamic_attribute).should == Page.instance_method(:add_datt) end it "should add a dynamic attribute" do @page.add_dynamic_attribute(:rocks, "string") @page.dynamic_attribute_details(:rocks).value.should be_nil @page.add_dynamic_attribute(:rock, "string", "123") @page.read_datt(:rock).should == "123" @page.dynamic_attribute_details(:rock).value.should == "123" end it "should ignore when trying to add same attribute" do @page.add_dynamic_attribute(:rocks, "string") @page.add_dynamic_attribute(:rocks, "integer") @page.dynamic_attribute_details(:rocks).object_type.should == "string" end it "should return false if the method that is being added already exists" do @page.add_dynamic_attribute(:name, "text").should be_false end it "should not make any changes to the original attribute" do @page.update_attribute(:name, "juno") @page.add_dynamic_attribute(:name, "text") @page.name.should == "juno" end end describe ".add_dynamic_attribute!" do it "should be aliased by add_datt!" do Page.instance_method(:add_dynamic_attribute!).should == Page.instance_method(:add_datt!) end it "should create the dynamic attribute, not waiting to save the attributable record" do @page.add_dynamic_attribute!(:price, "integer", 200) Page.last.price.should == 200 end end end
Version data entries
18 entries across 18 versions & 1 rubygems