spec/unit/braintree/transaction_spec.rb in braintree-1.0.1 vs spec/unit/braintree/transaction_spec.rb in braintree-1.1.0

- old
+ new

@@ -28,11 +28,11 @@ expect do Braintree::Transaction.submit_for_settlement("invalid-transaction-id") end.to raise_error(ArgumentError, "transaction_id is invalid") end end - + describe "initialize" do it "sets up customer attributes in customer_details" do transaction = Braintree::Transaction._new( :customer => { :id => "123", @@ -52,37 +52,37 @@ transaction.customer_details.email.should == "adam.taylor@lednerllc.com" transaction.customer_details.website.should == "lednerllc.com" transaction.customer_details.phone.should == "1-999-652-4189 x56883" transaction.customer_details.fax.should == "012-161-8055" end - + it "sets up credit card attributes in credit_card_details" do transaction = Braintree::Transaction._new( :credit_card => { :token => "mzg2", :bin => "411111", :last_4 => "1111", :card_type => "Visa", :expiration_month => "08", :expiration_year => "2009", - :issuer_location => "US" + :customer_location => "US" } ) transaction.credit_card_details.token.should == "mzg2" transaction.credit_card_details.bin.should == "411111" transaction.credit_card_details.last_4.should == "1111" transaction.credit_card_details.card_type.should == "Visa" transaction.credit_card_details.expiration_month.should == "08" transaction.credit_card_details.expiration_year.should == "2009" - transaction.credit_card_details.issuer_location.should == "US" + transaction.credit_card_details.customer_location.should == "US" end it "sets up history attributes in status_history" do time = Time.utc(2010,1,14) transaction = Braintree::Transaction._new( :status_history => [ - { :timestamp => time, :amount => "12.00", :transaction_source => "API", + { :timestamp => time, :amount => "12.00", :transaction_source => "API", :user => "larry", :status => "authorized" }, { :timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API", :user => "curly", :status => "scheduled_for_settlement"} ]) transaction.status_history.size.should == 2 @@ -98,49 +98,49 @@ transaction = Braintree::Transaction._new( :custom => "\n " ) end end - + describe "inspect" do it "includes the id, type, amount, and status first" do transaction = Braintree::Transaction._new( :id => "1234", :type => "sale", :amount => "100.00", :status => "authorized" ) output = transaction.inspect - output.should include(%Q(#<Braintree::Transaction id: "1234", type: "sale", amount: "100.00", status: "authorized")) + output.should include(%Q(#<Braintree::Transaction id: "1234", type: "sale", amount: "100.0", status: "authorized")) end end - + describe "==" do it "returns true when it should" do first = Braintree::Transaction._new(:id => 123) second = Braintree::Transaction._new(:id => 123) - + first.should == second second.should == first end - + it "returns false when it should" do first = Braintree::Transaction._new(:id => 123) second = Braintree::Transaction._new(:id => 124) - + first.should_not == second - second.should_not == first + second.should_not == first end end - + describe "new" do it "is protected" do expect do Braintree::Transaction.new end.to raise_error(NoMethodError, /protected method .new/) end end - + describe "refunded?" do it "is true if the transaciton has been refunded" do transaction = Braintree::Transaction._new(:refund_id => "123") transaction.refunded?.should == true end