Sha256: 5feb5d95281d0e644c7bfb6933bc3006d36a73d8bb0013e55ef54ec63669aac2
Contents?: true
Size: 1.04 KB
Versions: 33
Compression:
Stored size: 1.04 KB
Contents
require "spec_helper" describe Mongoid::Extensions::Array::Accessors do describe "#update" do context "when the attributes exist" do before do @array = [{ :_id => 1, :name => "James T. Kirk" }] end it "overwrites with the new attributes" do @array.update({ :_id => 1, :name => "Spock" }) @array.first[:name].should == "Spock" end end context "when the attributes do not exist" do before do @array = [{ :_id => 1, :name => "James T. Kirk" }] end it "appends the new attributes" do @array.update({ :_id => 2, :name => "Scotty" }) @array.size.should == 2 @array.last[:name].should == "Scotty" end end context "when the new attribtues have no id" do before do @array = [{ :_id => 1, :name => "James T. Kirk" }] end it "appends the new attributes" do @array.update({:name => "Scotty" }) @array.size.should == 2 @array.last[:name].should == "Scotty" end end end end
Version data entries
33 entries across 33 versions & 1 rubygems