Sha256: 53b93cb39b249868ba3c9f00ffeec2abae08190b4bfd62836dfac31d3bf3afa5
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
# encoding: utf-8 require "spec_helper" # # TODO This requires much more testing, although most of the basics # are checked by other parts of the code. # describe CouchRest::Model::CastedArray do let :klass do CouchRest::Model::CastedArray end describe "#initialize" do it "should set the casted properties" do prop = double('Property') parent = double('Parent') obj = klass.new([], prop, parent) expect(obj.casted_by_property).to eql(prop) expect(obj.casted_by).to eql(parent) expect(obj).to be_empty end end describe "#as_couch_json" do let :property do CouchRest::Model::Property.new(:cat, :type => Cat) end let :obj do klass.new([ { :name => 'Felix' }, { :name => 'Garfield' } ], property) end it "should return an array" do expect(obj.as_couch_json).to be_a(Array) end it "should call as_couch_json on each value" do expect(obj.first).to receive(:as_couch_json) obj.as_couch_json end it "should return value if no as_couch_json method" do obj = klass.new(['Felix', 'Garfield'], CouchRest::Model::Property.new(:title, :type => String)) expect(obj.first).not_to respond_to(:as_couch_json) expect(obj.as_couch_json.first).to eql('Felix') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
couchrest_model-2.2.0.beta2 | spec/unit/casted_array_spec.rb |
couchrest_model-2.2.0.beta1 | spec/unit/casted_array_spec.rb |