Skip to content

Commit

Permalink
Fix an argument for test_faker_stripe.rb
Browse files Browse the repository at this point in the history
This PR fixes an argument for test_faker_stripe.rb.

This change was hidden by the same `ArgumentError` in different messages.

## Expected error

```console
Faker::Stripe.valid_card(card_type: Faker::Lorem.word)
# => ArgumentError: Valid credit cards argument can be left blank or include
#    visa, visa_debit, mc, mc_2_series, mc_debit, mc_prepaid, amex, amex_2,
#    discover, discover_2, diners_club, diners_club_2, jcb
#    from
#    /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/faker-2.1.2/lib/faker/default/stripe.rb:13:in
#    `valid_card'
```

```console
Faker::Stripe.invalid_card(card_error: Faker::Lorem.word)
# => ArgumentError: Invalid credit cards argument can be left blank or
#    include addressZipFail, addressFail, zipFail, addressZipUnavailable,
#    cvcFail, customerChargeFail, successWithReview, declineCard,
#    declineFraudulentCard, declineIncorrectCvc, declineExpired,
#    declineProcessingError, declineIncorrectNumber
#    from /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/faker-2.1.2/lib/faker/default/stripe.rb:43:in
#    `invalid_card'
```

## Actual error

```console
Faker::Stripe.valid_card(Faker::Lorem.word)
# => ArgumentError: wrong number of arguments (given 1, expected 0)
#    from /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/faker-2.1.2/lib/faker/default/stripe.rb:6:in
#    `valid_card'
```

```console
Faker::Stripe.invalid_card(Faker::Lorem.word)
# => ArgumentError: wrong number of arguments (given 1, expected 0)
#    from /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/faker-2.1.2/lib/faker/default/stripe.rb:36:in
#    `invalid_card'
```

This was found by running the test with faker-ruby#1698.

```console
% bundle exec rake test
Loaded suite
/Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.1/lib/rake/rake_test_loader
Started

(snip)

/Users/koic/src/github.com/faker-ruby/faker/test/faker/default/test_faker_stripe.rb:38:
Passing `card_error` with the 1st argument of `Stripe.invalid_card` is
deprecated. Use keyword argument like `Stripe.invalid_card(card_error: ...)` instead.
/Users/koic/src/github.com/faker-ruby/faker/test/faker/default/test_faker_stripe.rb:16:
Passing `card_type` with the 1st argument of `Stripe.valid_card` is
deprecated. Use keyword argument like `Stripe.valid_card(card_type: ...)` instead.
```
  • Loading branch information
koic committed Aug 24, 2019
1 parent 840cf10 commit c05d4f6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/faker/default/test_faker_stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ def test_valid_card
end

def test_valid_card_error
assert_raise ArgumentError do
assert @tester.valid_card(Faker::Lorem.word)
e = assert_raise ArgumentError do
assert @tester.valid_card(card_type: Faker::Lorem.word)
end

assert(e.message.start_with?('Valid credit cards argument can be left blank or include'))
end

def test_specific_valid_card
Expand All @@ -34,9 +36,11 @@ def test_invalid_card
end

def test_invalid_card_error
assert_raise ArgumentError do
assert @tester.invalid_card(Faker::Lorem.word)
e = assert_raise ArgumentError do
assert @tester.invalid_card(card_error: Faker::Lorem.word)
end

assert(e.message.start_with?('Invalid credit cards argument can be left blank or include'))
end

def test_specific_error_invalid_card
Expand Down

0 comments on commit c05d4f6

Please sign in to comment.