spec/unit/braintree/errors_spec.rb in braintree-3.3.0 vs spec/unit/braintree/errors_spec.rb in braintree-3.4.0

- old
+ new

@@ -2,28 +2,28 @@ describe Braintree::Errors do describe "for" do it "accesses errors for the given scope" do errors = Braintree::Errors.new( - :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]} + :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}, ) errors.for(:level1).size.should == 1 errors.for(:level1)[0].code.should == "code1" end it "returns nil if there are no errors at the given scope" do errors = Braintree::Errors.new( - :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]} + :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}, ) errors.for(:no_errors_here).should == nil end end describe "inspect" do it "is better than the default inspect" do errors = Braintree::Errors.new( - :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]} + :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}, ) errors.inspect.should == "#<Braintree::Errors level1:[(code1) message]>" end it "shows errors 2 levels deep" do @@ -31,11 +31,11 @@ :level1 => { :errors => [{:code => "code1", :attribute => "attr", :message => "message"}], :level2 => { :errors => [{:code => "code2", :attribute => "attr2", :message => "message2"}], } - } + }, ) errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>" end it "shows errors 3 levels deep" do @@ -46,11 +46,11 @@ :errors => [{:code => "code2", :attribute => "attr2", :message => "message2"}], :level3 => { :errors => [{:code => "code3", :attribute => "attr3", :message => "message3"}], } } - } + }, ) errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>" end end @@ -63,20 +63,20 @@ :errors => [ {:code => "2", :attribute => "attr2", :message => "message2"}, {:code => "3", :attribute => "attr3", :message => "message3"} ], } - } + }, ) errors.map { |e| e.code }.sort.should == %w[1 2 3] end end describe "size" do it "returns the number of validation errors at the first level if only has one level" do errors = Braintree::Errors.new( - :level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]} + :level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]}, ) errors.size.should == 1 end it "returns the total number of validation errors in the hierarchy" do @@ -87,10 +87,10 @@ :errors => [ {:code => "2", :attribute => "attr2", :message => "message2"}, {:code => "3", :attribute => "attr3", :message => "message3"} ], } - } + }, ) errors.size.should == 3 end end end