Skip to content

Commit

Permalink
Can generate a transaction with no args.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Nov 20, 2011
1 parent 4fc470d commit 917a235
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -90,7 +90,8 @@ It takes the following options:
* `:amount`: the amount of the transaction
* `:status`: the status of the transaction, e.g. `Braintree::Transaction::Status::Failed`

Any or all of these can be nil, and in fact are nil by default.
Any or all of these can be nil, and in fact are nil by default. You can also
call it with no arguments.

Full example:

Expand Down
2 changes: 1 addition & 1 deletion lib/fake_braintree.rb
Expand Up @@ -99,7 +99,7 @@ def self.credit_card_from_token(token)
end
end

def self.generate_transaction(options)
def self.generate_transaction(options = {})
history_item = { 'timestamp' => Time.now,
'amount' => options[:amount],
'status' => options[:status] }
Expand Down
4 changes: 4 additions & 0 deletions spec/fake_braintree_spec.rb
Expand Up @@ -112,6 +112,10 @@ def write_to_log
transaction['subscription_id'].should == 'foobar'
end

it "allows no arguments" do
expect { FakeBraintree.generate_transaction }.not_to raise_error
end

context "status_history" do
it "returns a hash with a status_history key" do
FakeBraintree.generate_transaction(:amount => '20').should have_key('status_history')
Expand Down

0 comments on commit 917a235

Please sign in to comment.