fake_braintree 0.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +9 -0
- data/NEWS.md +5 -1
- data/README.md +22 -19
- data/fake_braintree.gemspec +0 -4
- data/lib/fake_braintree/address.rb +1 -1
- data/lib/fake_braintree/credit_card.rb +5 -5
- data/lib/fake_braintree/customer.rb +4 -4
- data/lib/fake_braintree/redirect.rb +2 -2
- data/lib/fake_braintree/server.rb +1 -1
- data/lib/fake_braintree/sinatra_app.rb +28 -17
- data/lib/fake_braintree/subscription.rb +4 -3
- data/lib/fake_braintree/version.rb +1 -1
- data/spec/fake_braintree/address_spec.rb +1 -1
- data/spec/fake_braintree/credit_card_spec.rb +30 -28
- data/spec/fake_braintree/customer_spec.rb +32 -36
- data/spec/fake_braintree/subscription_spec.rb +33 -16
- data/spec/fake_braintree/transaction_spec.rb +26 -25
- data/spec/fake_braintree/transparent_redirect_spec.rb +21 -21
- data/spec/fake_braintree_spec.rb +23 -22
- data/spec/support/braintree_helpers.rb +4 -4
- data/spec/support/customer_helpers.rb +1 -1
- data/spec/support/subscription_helpers.rb +7 -3
- metadata +27 -41
data/spec/fake_braintree_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe FakeBraintree, '.decline_all_cards!' do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def create_sale
|
16
|
-
Braintree::CreditCard.sale(cc_token, :
|
16
|
+
Braintree::CreditCard.sale(cc_token, amount: 10.00)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -43,8 +43,8 @@ describe FakeBraintree do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'logs to the correct path' do
|
46
|
-
Braintree::Configuration.logger.info('
|
47
|
-
File.readlines(FakeBraintree.log_file_path).last.should
|
46
|
+
Braintree::Configuration.logger.info('Some test')
|
47
|
+
File.readlines(FakeBraintree.log_file_path).last.should include "Some test"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -67,18 +67,17 @@ end
|
|
67
67
|
|
68
68
|
describe FakeBraintree, 'VALID_CREDIT_CARDS' do
|
69
69
|
it 'includes only credit cards that are valid in the Braintree sandbox' do
|
70
|
-
|
71
|
-
|
70
|
+
valid_credit_cards = %w(
|
71
|
+
4111111111111111 4005519200000004
|
72
|
+
4009348888881881 4012000033330026
|
73
|
+
4012000077777777 4012888888881881
|
74
|
+
4217651111111119 4500600000000061
|
75
|
+
5555555555554444 378282246310005
|
76
|
+
371449635398431 6011111111111117
|
77
|
+
3530111333300000
|
78
|
+
)
|
72
79
|
|
73
|
-
|
74
|
-
%w(4111111111111111 4005519200000004
|
75
|
-
4009348888881881 4012000033330026
|
76
|
-
4012000077777777 4012888888881881
|
77
|
-
4217651111111119 4500600000000061
|
78
|
-
5555555555554444 378282246310005
|
79
|
-
371449635398431 6011111111111117
|
80
|
-
3530111333300000
|
81
|
-
)
|
80
|
+
FakeBraintree::VALID_CREDIT_CARDS.sort.should == valid_credit_cards.sort
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
@@ -90,13 +89,13 @@ end
|
|
90
89
|
|
91
90
|
describe FakeBraintree, '.generate_transaction' do
|
92
91
|
it 'allows setting the subscription id' do
|
93
|
-
transaction = FakeBraintree.generate_transaction(:
|
92
|
+
transaction = FakeBraintree.generate_transaction(subscription_id: 'foobar')
|
94
93
|
transaction['subscription_id'].should == 'foobar'
|
95
94
|
end
|
96
95
|
|
97
96
|
it 'allows setting created_at' do
|
98
97
|
time = Time.now
|
99
|
-
transaction = FakeBraintree.generate_transaction(:
|
98
|
+
transaction = FakeBraintree.generate_transaction(created_at: time)
|
100
99
|
transaction['created_at'].should == time
|
101
100
|
end
|
102
101
|
|
@@ -108,7 +107,7 @@ describe FakeBraintree, '.generate_transaction' do
|
|
108
107
|
end
|
109
108
|
|
110
109
|
it 'has the correct amount' do
|
111
|
-
transaction = FakeBraintree.generate_transaction(:
|
110
|
+
transaction = FakeBraintree.generate_transaction(amount: '20.00')
|
112
111
|
transaction['amount'].should == '20.00'
|
113
112
|
end
|
114
113
|
|
@@ -118,25 +117,27 @@ describe FakeBraintree, '.generate_transaction' do
|
|
118
117
|
|
119
118
|
context 'status_history' do
|
120
119
|
it 'returns a hash with a status_history key' do
|
121
|
-
FakeBraintree.generate_transaction(:
|
120
|
+
FakeBraintree.generate_transaction(amount: '20').should have_key('status_history')
|
122
121
|
end
|
123
122
|
|
124
123
|
it 'has a timestamp of Time.now' do
|
125
124
|
Timecop.freeze do
|
126
|
-
transaction = FakeBraintree.generate_transaction(
|
127
|
-
|
125
|
+
transaction = FakeBraintree.generate_transaction(
|
126
|
+
status: Braintree::Transaction::Status::Failed,
|
127
|
+
subscription_id: 'my_subscription_id'
|
128
|
+
)
|
128
129
|
transaction['status_history'].first['timestamp'].should == Time.now
|
129
130
|
end
|
130
131
|
end
|
131
132
|
|
132
133
|
it 'has the desired amount' do
|
133
|
-
transaction = FakeBraintree.generate_transaction(:
|
134
|
+
transaction = FakeBraintree.generate_transaction(amount: '20.00')
|
134
135
|
transaction['status_history'].first['amount'].should == '20.00'
|
135
136
|
end
|
136
137
|
|
137
138
|
it 'has the desired status' do
|
138
139
|
status = Braintree::Transaction::Status::Failed
|
139
|
-
transaction = FakeBraintree.generate_transaction(:
|
140
|
+
transaction = FakeBraintree.generate_transaction(status: status)
|
140
141
|
transaction['status_history'].first['status'].should == status
|
141
142
|
end
|
142
143
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module BraintreeHelpers
|
2
2
|
def create_braintree_customer(cc_number, expiration_date)
|
3
3
|
Braintree::Customer.create(
|
4
|
-
:
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
4
|
+
email: 'me@example.com',
|
5
|
+
credit_card: {
|
6
|
+
number: cc_number,
|
7
|
+
expiration_date: expiration_date
|
8
8
|
}
|
9
9
|
).customer
|
10
10
|
end
|
@@ -2,7 +2,7 @@ module CustomerHelpers
|
|
2
2
|
def create_customer(credit_card_options = {})
|
3
3
|
credit_card_options[:number] ||= TEST_CC_NUMBER
|
4
4
|
credit_card_options[:expiration_date] ||= '04/2016'
|
5
|
-
Braintree::Customer.create(:
|
5
|
+
Braintree::Customer.create(credit_card: credit_card_options)
|
6
6
|
end
|
7
7
|
|
8
8
|
def create_customer_with_invalid_card(credit_card_options = {})
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module SubscriptionHelpers
|
2
|
-
def create_subscription(
|
3
|
-
|
4
|
-
|
2
|
+
def create_subscription(user_options = {})
|
3
|
+
options = {
|
4
|
+
payment_method_token: cc_token,
|
5
|
+
plan_id: 'my_plan_id'
|
6
|
+
}.merge(user_options)
|
7
|
+
|
8
|
+
Braintree::Subscription.create(options)
|
5
9
|
end
|
6
10
|
end
|
metadata
CHANGED
@@ -1,167 +1,153 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_braintree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot, inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: i18n
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sinatra
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: braintree
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.5'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.5'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: thin
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 2.12.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 2.12.0
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: capybara
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 2.0.3
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ~>
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 2.0.3
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: bourne
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
|
-
- - ~>
|
115
|
+
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
117
|
version: '1.3'
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
|
-
- - ~>
|
122
|
+
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: '1.3'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: timecop
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
|
-
- - ~>
|
129
|
+
- - "~>"
|
144
130
|
- !ruby/object:Gem::Version
|
145
131
|
version: '0.6'
|
146
132
|
type: :development
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
|
-
- - ~>
|
136
|
+
- - "~>"
|
151
137
|
- !ruby/object:Gem::Version
|
152
138
|
version: '0.6'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: rake
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
|
-
- -
|
143
|
+
- - ">="
|
158
144
|
- !ruby/object:Gem::Version
|
159
145
|
version: '0'
|
160
146
|
type: :development
|
161
147
|
prerelease: false
|
162
148
|
version_requirements: !ruby/object:Gem::Requirement
|
163
149
|
requirements:
|
164
|
-
- -
|
150
|
+
- - ">="
|
165
151
|
- !ruby/object:Gem::Version
|
166
152
|
version: '0'
|
167
153
|
description: A fake Braintree that you can run integration tests against
|
@@ -172,8 +158,8 @@ executables: []
|
|
172
158
|
extensions: []
|
173
159
|
extra_rdoc_files: []
|
174
160
|
files:
|
175
|
-
- .gitignore
|
176
|
-
- .travis.yml
|
161
|
+
- ".gitignore"
|
162
|
+
- ".travis.yml"
|
177
163
|
- CONTRIBUTING.md
|
178
164
|
- GOALS
|
179
165
|
- Gemfile
|
@@ -217,17 +203,17 @@ require_paths:
|
|
217
203
|
- lib
|
218
204
|
required_ruby_version: !ruby/object:Gem::Requirement
|
219
205
|
requirements:
|
220
|
-
- -
|
206
|
+
- - ">="
|
221
207
|
- !ruby/object:Gem::Version
|
222
208
|
version: 1.9.2
|
223
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
210
|
requirements:
|
225
|
-
- -
|
211
|
+
- - ">="
|
226
212
|
- !ruby/object:Gem::Version
|
227
213
|
version: '0'
|
228
214
|
requirements: []
|
229
215
|
rubyforge_project:
|
230
|
-
rubygems_version: 2.
|
216
|
+
rubygems_version: 2.2.2
|
231
217
|
signing_key:
|
232
218
|
specification_version: 4
|
233
219
|
summary: A fake Braintree that you can run integration tests against
|