Sha256: 69bfa2361fceb3e3a032620b8ac4b240162ea03579da0ace5e5ea844ebb99c3f
Contents?: true
Size: 1.74 KB
Versions: 4
Compression:
Stored size: 1.74 KB
Contents
require 'spec_helper' describe Customize::Characterize do with_model :product do table do |t| t.string :name t.timestamps end model do include Customize::Inherited include Customize::Characterize end end with_model :person do table do |t| end model do include Customize::Characterize end end context :model_without_inherit do subject { Person.create } it :has_character do subject.characters.create :key=>:foo, :type=>:boolean, :value=>true subject.reload subject.character[:foo].should be_true end it :should_not_return_inherited_characters do subject.inherited_characters.should be_nil end end context :model_with_inherit do subject { Customize::Character.delete_all parent = Product.create! parent.characters.create! :key=>:p, :value=>1 p = Product.create! p.inherit parent p } it "has characters" do subject.characters.should_not be_nil end context "support type" do before :each do @value = example.metadata[:description_args].first @type = example.metadata[:type] subject.characters.create :key=>@type, :type=>@type, :value=>@value subject.reload end after :each do subject.character[@type].should == @value end it 10, :type=>:integer do end it 12.34, :type=>:decimal do end it 'string', :type=>:string do end it [1, 2, 3] do end it Hash.new(:foo=>:bar) do end end it "has readonly hash character" do subject.characters.create! :key=>:foo, :value=>'bar' subject.character[:foo].should == 'bar' end it "has inherited character" do subject.character[:p].should == 1 end it :has_def_inherited_characters do subject.inherited_characters.should_not be_empty end end end
Version data entries
4 entries across 4 versions & 1 rubygems