<commit_before># fake\_braintree, a Braintree fake

This library is a way to test Braintree code without hitting Braintree's servers.
It uses [Capybara::Server](https://github.com/jnicklas/capybara/blob/master/lib/capybara/server.rb)
to intercept all of the calls from Braintree's Ruby library and returns XML that the Braintree library
can parse. The whole point is not to hit the Braintree API.

Currently in alpha (i.e. it does not support every Braintree call).

## Supported API methods

### Customer
* `Braintree::Customer.find`
* `Braintree::Customer.create`
* `Braintree::Customer.update`

### Subscription
* `Braintree::Subscription.find`
* `Braintree::Subscription.create`

### CreditCard
* `Braintree::CreditCard.find`
* `Braintree::CreditCard.sale`

### Transaction
* `Braintree::Transaction.sale`

### TransparentRedirect
* `Braintree::TransparentRedirect.url`
* `Braintree::TransparentRedirect.confirm` (only for creating customers)

## Quick start
Call `FakeBraintree.activate!` to make it go. `FakeBraintree.clear!` will clear
all data, which you probably want to do before each test.

Example, in spec\_helper.rb:

    FakeBraintree.activate!

    RSpec.configure do |c|
      c.before do
        FakeBraintree.clear!
      end
    end

## Verifying credit cards

To verify every credit card you try to use, call:

    FakeBraintree.verify_all_cards!

This will stay "on" until you set

    FakeBraintree.verify_all_cards = false

Calling FakeBraintree.clear! _will not_ change this setting. It does very basic
verification: it only matches the credit card number against these:
http://www.braintreepayments.com/docs/ruby/reference/sandbox and rejects them if
they aren't one of the listed numbers.

## Declining credit cards

To decline every card you try, call:

    FakeBraintree.decline_all_cards!

This will decline all cards until you call

    FakeBraintree.clear!<commit_msg>Clarify.<commit_after># fake\_braintree, a Braintree fake

This library is a way to test Braintree code without hitting Braintree's servers.
It uses [Capybara::Server](https://github.com/jnicklas/capybara/blob/master/lib/capybara/server.rb)
to intercept all of the calls from Braintree's Ruby library and returns XML that the Braintree library
can parse. The whole point is not to hit the Braintree API.

Currently in alpha (i.e. it does not support every Braintree call).

## Supported API methods

### Customer
* `Braintree::Customer.find`
* `Braintree::Customer.create`
* `Braintree::Customer.update`

### Subscription
* `Braintree::Subscription.find`
* `Braintree::Subscription.create`

### CreditCard
* `Braintree::CreditCard.find`
* `Braintree::CreditCard.sale`

### Transaction
* `Braintree::Transaction.sale`

### TransparentRedirect
* `Braintree::TransparentRedirect.url`
* `Braintree::TransparentRedirect.confirm` (only for creating customers)

## Quick start
Call `FakeBraintree.activate!` to make it go. `FakeBraintree.clear!` will clear
all data, which you probably want to do before each test.

Example, in spec\_helper.rb:

    FakeBraintree.activate!

    RSpec.configure do |c|
      c.before do
        FakeBraintree.clear!
      end
    end

## Verifying credit cards

To verify every credit card you try to use, call:

    FakeBraintree.verify_all_cards!

This will stay "on" until you set

    FakeBraintree.verify_all_cards = false

Calling FakeBraintree.clear! _will not_ change this setting. It does very basic
verification: it only matches the credit card number against these:
http://www.braintreepayments.com/docs/ruby/reference/sandbox and rejects them if
they aren't one of the listed numbers.

## Declining credit cards

To decline every card you try, call:

    FakeBraintree.decline_all_cards!

This will decline all cards until you call

    FakeBraintree.clear!

This behavior is different from FakeBraintree.verify\_all\_cards, which will
stay on even when `clear!` is called.
{'fraction_non_alphanumeric': 0.09025824597289696, 'fraction_numerical': 0.0, 'mean_word_length': 4.636887608069165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7089240', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1185, 'n_words': 400}