Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
knowmalaria
stripe-ruby-mock
Commits
f97c4fd1
Commit
f97c4fd1
authored
Apr 16, 2015
by
Eric Saxby & Matt Camuto
Committed by
AlexMamonchik
Mar 01, 2016
Browse files
added accounts test and merge with PR#218
parent
6c26487d
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/stripe_mock/data.rb
View file @
f97c4fd1
...
...
@@ -15,7 +15,79 @@ module StripeMock
currencies_supported:
[
"usd"
],
default_currency:
"usd"
,
country:
"US"
,
object:
"account"
,
business_name:
"Stripe.com"
,
business_url:
nil
,
support_phone:
nil
,
managed:
false
,
product_description:
nil
,
debit_negative_balances:
true
,
bank_accounts:
{
object:
"list"
,
total_count:
0
,
has_more:
false
,
url:
"/v1/accounts/
#{
id
}
/bank_accounts"
,
data:
[
]
},
verification:
{
fields_needed:
[],
due_by:
nil
,
contacted:
false
},
transfer_schedule:
{
delay_days:
7
,
interval:
"daily"
},
tos_acceptance:
{
ip:
nil
,
date:
nil
,
user_agent:
nil
},
legal_entity:
{
type:
nil
,
business_name:
nil
,
address:
{
line1:
nil
,
line2:
nil
,
city:
nil
,
state:
nil
,
postal_code:
nil
,
country:
"US"
},
first_name:
nil
,
last_name:
nil
,
personal_address:
{
line1:
nil
,
line2:
nil
,
city:
nil
,
state:
nil
,
postal_code:
nil
,
country:
nil
},
dob:
{
day:
nil
,
month:
nil
,
year:
nil
},
additional_owners:
nil
,
verification:
{
status:
"unverified"
,
document:
nil
,
details:
nil
}
},
decline_charge_on:
{
cvc_failure:
false
,
avs_failure:
false
},
keys:
{
secret:
nil
,
publishable:
nil
}
}.
merge
(
params
)
end
...
...
lib/stripe_mock/request_handlers/accounts.rb
View file @
f97c4fd1
...
...
@@ -13,12 +13,14 @@ module StripeMock
def
new_account
(
route
,
method_url
,
params
,
headers
)
params
[
:id
]
||=
new_id
(
'acct'
)
route
=~
method_url
accounts
[
params
[
:id
]
]
||=
Data
.
mock_account
(
params
)
accounts
[
params
[
:id
]]
||=
Data
.
mock_account
(
params
)
end
def
get_account
(
route
,
method_url
,
params
,
headers
)
route
=~
method_url
Data
.
mock_account
init_account
id
=
$1
||
accounts
.
keys
[
0
]
assert_existence
:account
,
id
,
accounts
[
id
]
end
def
update_account
(
route
,
method_url
,
params
,
headers
)
...
...
@@ -28,8 +30,18 @@ module StripeMock
end
def
list_accounts
(
route
,
method_url
,
params
,
headers
)
init_account
Data
.
mock_list_object
(
accounts
.
values
,
params
)
end
private
def
init_account
if
accounts
==
{}
acc
=
Data
.
mock_account
accounts
[
acc
[
:id
]]
=
acc
end
end
end
end
end
spec/shared_stripe_examples/account_examples.rb
View file @
f97c4fd1
...
...
@@ -7,11 +7,30 @@ shared_examples 'Account API' do
expect
(
account
).
to
be_a
Stripe
::
Account
expect
(
account
.
id
).
to
match
/acct\_/
end
it
'retrieves a specific stripe account'
do
account
=
Stripe
::
Account
.
retrieve
(
'acct_103ED82ePvKYlo2C'
)
it
'all'
,
live:
true
do
expect
(
account
).
to
be_a
Stripe
::
Account
expect
(
account
.
id
).
to
match
/acct\_/
end
it
'retrieves all'
,
live:
true
do
accounts
=
Stripe
::
Account
.
all
expect
(
accounts
).
to
be_a
Stripe
::
ListObject
expect
(
accounts
.
data
).
to
eq
[]
expect
(
accounts
.
data
.
count
).
to
satisfy
{
|
n
|
n
>=
1
}
end
it
'creates one more account'
do
account
=
Stripe
::
Account
.
create
(
email:
'lol@what.com'
)
expect
(
account
).
to
be_a
Stripe
::
Account
end
it
'updates account'
do
account
=
Stripe
::
Account
.
retrieve
account
.
support_phone
=
'1234567'
account
.
save
account
=
Stripe
::
Account
.
retrieve
expect
(
account
.
support_phone
).
to
eq
'1234567'
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment