Sha256: cc8cf7d0b2269dce6662b0d7ac4ede4c7b62db6e474c235d1435f4f5e08c61ac
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
require 'spec_helper' describe Hashme::CastedArray do let :owner do double() end let :submodel do Class.new do include Hashme property :name, String end end describe "#initialize" do before :each do @prop = Hashme::Property.new(:name, String) @obj = Hashme::CastedArray.new(owner, @prop, ['test']) end it "should prepare array" do @obj.length.should eql(1) end it "should set owner and property" do @obj.casted_by.should eql(owner) @obj.casted_by_property.should eql(@prop) end it "should instantiate and cast each value" do @obj.first.should eql("test") @obj.first.class.should eql(String) end end describe "adding to array" do before :each do @prop = Hashme::Property.new(:item, submodel) @obj = Hashme::CastedArray.new(owner, @prop, [{:name => 'test'}]) end it "should cast new items" do @obj << {:name => 'test2'} @obj.last.class.should eql(submodel) @obj.first.name.should eql('test') @obj.last.name.should eql('test2') @obj.last.casted_by.should eql(owner) @obj.last.casted_by_property.should eql(@prop) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hashme-0.1.2 | spec/hashme/casted_array_spec.rb |
hashme-0.1.1 | spec/hashme/casted_array_spec.rb |
hashme-0.1.0 | spec/hashme/casted_array_spec.rb |