Sha256: 19eec34ad98e3655663e4b079e666ad68549b88c666278cbff2f4b7af926bc8b

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 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::Characterize
			include Customize::Inherited
		end
	end

	subject { Product.create! }

	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
		parent = Product.create!
		parent.characters.create! :key=>:p, :value=>1
		subject.inherit parent
		subject.character[:p].should == 1
	end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
customize-0.0.2 spec/customize/characterize_spec.rb
customize-0.0.1 spec/customize/characterize_spec.rb