bill_forward 1.2014.296 → 1.2015.183

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +29 -27
  3. data/.idea/compiler.xml +23 -23
  4. data/.idea/copyright/profiles_settings.xml +2 -2
  5. data/.idea/encodings.xml +5 -5
  6. data/.idea/inspectionProfiles/Project_Default.xml +10 -10
  7. data/.idea/inspectionProfiles/profiles_settings.xml +6 -6
  8. data/.idea/misc.xml +23 -23
  9. data/.idea/modules.xml +9 -9
  10. data/.idea/scopes/scope_settings.xml +4 -4
  11. data/.idea/vcs.xml +7 -7
  12. data/.rspec +1 -1
  13. data/Gemfile +13 -9
  14. data/LICENSE.md +22 -22
  15. data/README.md +285 -227
  16. data/Rakefile +73 -73
  17. data/bill_forward.gemspec +28 -29
  18. data/bill_forward.iml +28 -28
  19. data/lib/bill_forward/billing_entity.rb +295 -262
  20. data/lib/bill_forward/client.rb +350 -355
  21. data/lib/bill_forward/entities/account.rb +18 -18
  22. data/lib/bill_forward/entities/amendments/issue_invoice_amendment.rb +10 -0
  23. data/lib/bill_forward/entities/amendments/product_rate_plan_migration_amendment.rb +18 -0
  24. data/lib/bill_forward/entities/api_configuration.rb +12 -0
  25. data/lib/bill_forward/entities/invoice.rb +29 -3
  26. data/lib/bill_forward/entities/invoice_parts/taxation_link.rb +5 -5
  27. data/lib/bill_forward/entities/organisation.rb +36 -36
  28. data/lib/bill_forward/entities/payment_method.rb +4 -4
  29. data/lib/bill_forward/entities/payment_method_subscription_link.rb +5 -5
  30. data/lib/bill_forward/entities/pricing_component.rb +21 -21
  31. data/lib/bill_forward/entities/pricing_component_tier.rb +5 -5
  32. data/lib/bill_forward/entities/pricing_component_value.rb +5 -5
  33. data/lib/bill_forward/entities/pricing_component_value_migration_amendment_mapping.rb +31 -0
  34. data/lib/bill_forward/entities/product.rb +5 -5
  35. data/lib/bill_forward/entities/product_rate_plan.rb +43 -19
  36. data/lib/bill_forward/entities/profile.rb +14 -14
  37. data/lib/bill_forward/entities/refund.rb +5 -0
  38. data/lib/bill_forward/entities/role.rb +3 -3
  39. data/lib/bill_forward/entities/stripe_ach_token.rb +9 -0
  40. data/lib/bill_forward/entities/subscription.rb +83 -53
  41. data/lib/bill_forward/entities/subscription_charge.rb +14 -0
  42. data/lib/bill_forward/insertable_entity.rb +21 -31
  43. data/lib/bill_forward/mutable_entity.rb +26 -46
  44. data/lib/bill_forward/resource_path.rb +10 -10
  45. data/lib/bill_forward/type_check.rb +20 -20
  46. data/lib/bill_forward/version.rb +4 -4
  47. data/lib/bill_forward.rb +17 -17
  48. data/scratch/Gemfile +9 -0
  49. data/scratch/scratch.example.rb +8 -0
  50. data/spec/component/account_spec.rb +199 -199
  51. data/spec/component/billing_entity_spec.rb +152 -152
  52. data/spec/functional/account_spec.rb +24 -24
  53. data/spec/functional/bad_citizen/account_spec.rb +102 -102
  54. data/spec/functional/bad_citizen/credit_note_spec.rb +14 -13
  55. data/spec/functional/bad_citizen/payment_method_spec.rb +1 -1
  56. data/spec/functional/bad_citizen/product_rate_plan_migration_amendment_spec.rb +379 -0
  57. data/spec/functional/bad_citizen/product_rate_plan_spec.rb +103 -47
  58. data/spec/functional/bad_citizen/product_spec.rb +16 -9
  59. data/spec/functional/bad_citizen/situational/authorize_net_token_spec.rb +4 -0
  60. data/spec/functional/bad_citizen/situational/malordered_entity_spec.rb +1 -1
  61. data/spec/functional/bad_citizen/situational/payment_method_spec.rb +6 -1
  62. data/spec/functional/bad_citizen/situational/subscription_chargeable_spec.rb +96 -65
  63. data/spec/functional/bad_citizen/subscription_spec.rb +99 -60
  64. data/spec/functional/bad_citizen/subscription_with_credit_spec.rb +121 -91
  65. data/spec/functional/bad_citizen/unit_of_measure_spec.rb +14 -7
  66. data/spec/functional/client_spec.rb +23 -23
  67. data/spec/functional/organisation_spec.rb +27 -27
  68. data/spec/setup_test_constants.rb +72 -72
  69. data/spec/spec_helper.rb +10 -10
  70. data/spec/syntax/account_spec.rb +23 -23
  71. data/spec/syntax/billing_entity_spec.rb +92 -92
  72. data/tools/RSpec hardcoded.sublime-build +16 -0
  73. data/tools/RSpec.sublime-build +13 -0
  74. data/tools/Ruby legacy.sublime-build +7 -0
  75. data/tools/local_bundle_build.sh +8 -0
  76. data/tools/local_bundle_install.sh +9 -0
  77. metadata +30 -85
data/README.md CHANGED
@@ -1,227 +1,285 @@
1
- # BillForwardApiClient
2
-
3
- This client library provides (via Ruby) easy access to the BillForward API.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile and run `bundle`:
8
-
9
- ```ruby
10
- gem 'bill_forward', :git => 'git@github.com:billforward/bf-ruby.git', :branch => 'master'
11
- ```
12
-
13
- Or install this source as a local gem using:
14
-
15
- ```bash
16
- bundle
17
- gem build bill_forward.gemspec
18
- gem install bill_forward
19
- ```
20
-
21
- ## Usage
22
- ### Including the Gem
23
-
24
- Once installed, require the BillForward gem:
25
-
26
- ```ruby
27
- require 'bill_forward'
28
- ```
29
-
30
- ### Getting Credentials
31
- You will need an API token. First log into your [Sandbox account](https://app-sandbox.billforward.net/login/#/) ([register](https://app-sandbox.billforward.net/register/#/) if necessary).
32
-
33
- Then [generate an API token](https://app-sandbox.billforward.net/setup/#/personal/api-keys).
34
-
35
- We support also client-id and client-secret authentication. For details, please [contact BillForward support](http://www.billforward.net/contact-us/).
36
-
37
- ### Connecting
38
-
39
- Create a default Client. Requests will be sent using its credentials:
40
-
41
- ```ruby
42
- my_client = BillForward::Client.new(
43
- :host => "API URL goes here",
44
- :api_token => "API token goes here"
45
- )
46
- BillForward::Client.default_client = my_client
47
- ```
48
-
49
- ### Invocation
50
-
51
- ##### Getting single entities:
52
-
53
- e.g. Get Subscription by ID:
54
-
55
- ```ruby
56
- subscription = BillForward::Subscription.get_by_id '3C39A79F-777E-4BDF-BDDC-221652F74E9D'
57
- puts subscription
58
- ```
59
-
60
- ##### Accessing entity variables:
61
-
62
- The entity can be accessed as a HashWithIndifferentAccess, or as an array.
63
-
64
- ```ruby
65
- # The following are equivalent:
66
- puts subscription.id
67
- puts subscription['id']
68
- puts subscription[:id]
69
- ```
70
-
71
- ##### Getting a list of entities:
72
-
73
- e.g. List Accounts
74
-
75
- ```ruby
76
- query_params = {
77
- 'records' => 3,
78
- 'order_by' => 'created',
79
- 'order' => 'ASC'
80
- }
81
- accounts = BillForward::Account.get_all query_params
82
- puts accounts
83
- ```
84
-
85
- ##### Creating an entity:
86
-
87
- e.g. Create simple Account
88
-
89
- ```ruby
90
- created_account = BillForward::Account.create
91
- ```
92
-
93
- e.g. Create complex Account
94
-
95
- ```ruby
96
- # Create an account with a profile (where the profile has addresses)
97
- addresses = Array.new
98
- addresses.push(
99
- BillForward::Address.new({
100
- 'addressLine1' => 'address line 1',
101
- 'addressLine2' => 'address line 2',
102
- 'addressLine3' => 'address line 3',
103
- 'city' => 'London',
104
- 'province' => 'London',
105
- 'country' => 'United Kingdom',
106
- 'postcode' => 'SW1 1AS',
107
- 'landline' => '02000000000',
108
- 'primaryAddress' => true
109
- }))
110
- profile = BillForward::Profile.new({
111
- 'email' => 'always@testing.is.moe',
112
- 'firstName' => 'Test',
113
- 'addresses' => addresses
114
- })
115
- account = BillForward::Account.new({
116
- 'profile' => profile
117
- })
118
- created_account = BillForward::Account.create account
119
- puts created_account
120
- ```
121
-
122
- ##### Updating an entity
123
-
124
- ```ruby
125
- gotten_account = BillForward::Account.get_by_id '908AF77A-0E5D-4D80-9B91-31EDE9962BF6'
126
- gotten_account.profile.email = 'sometimes@testing.is.moe'
127
- updated_account = gotten_account.save() # or: gotten_account.profile.save()
128
- puts updated_account
129
- ```
130
-
131
- ## Development
132
- ### Building
133
- Clone the source, then run `bundle`.
134
- ```bash
135
- bundle
136
- ```
137
- If ever you add a new dependency, you will need to run this again.
138
-
139
- To install the gem, run:
140
- ```ruby
141
- gem build bill_forward.gemspec
142
- gem install bill_forward
143
- ```
144
-
145
- ### Running tests
146
- Development is decidedly test-driven.
147
-
148
- We use RSpec for testing.
149
-
150
- Run offline tests with:
151
- ```bash
152
- rake
153
- ```
154
-
155
- If you wish to run online tests also, you will need to declare some test constants. Create a file `test_constants.rb` in the directory `spec/`, containing the following declarations:
156
-
157
- ```ruby
158
- module BillForwardTest
159
- BILLFORWARD_API_HOST='insert-API-URL-here'
160
- BILLFORWARD_API_TOKEN="insert-access-token-here OR leave-blank-for-OAUTH"
161
-
162
- ### alternatively:
163
- # (these values are used if you leave API token blank)
164
- # authenticate using OAUTH:
165
- BILLFORWARD_USERNAME="insert-username"
166
- BILLFORWARD_PASSWORD="insert-password"
167
- BILLFORWARD_CLIENT_ID="insert-client-id"
168
- BILLFORWARD_CLIENT_SECRET="insert-client-secret"
169
-
170
-
171
- # ---- Enable logging if you want (shows request and response bodies)
172
- USE_LOGGING=false
173
-
174
-
175
- # ---- Enable proxy if you want (for example to see requests in Fiddler)
176
- CLIENT_PROXY_ENABLED=false
177
- CLIENT_PROXY_URL="http://127.0.0.1:8888"
178
- end
179
- ```
180
-
181
- Run main functional tests + offline tests with:
182
- ```bash
183
- rake spec_main
184
- ```
185
-
186
- There are further tests still that can be run, but these are situational -- for example, they require an invoice to exist already, or require credentials to be declared for a payment gateway.
187
-
188
- You can specify constants for use in situational tests in the usual test constants file, as before:
189
-
190
- ```ruby
191
- module BillForwardTest
192
- BILLFORWARD_API_HOST='insert-API-URL-here'
193
- BILLFORWARD_API_TOKEN="insert-access-token-here OR leave-blank-for-OAUTH"
194
-
195
- ### alternatively:
196
- # (these values are used if you leave API token blank)
197
- # authenticate using OAUTH:
198
- BILLFORWARD_USERNAME="insert-username"
199
- BILLFORWARD_PASSWORD="insert-password"
200
- BILLFORWARD_CLIENT_ID="insert-client-id"
201
- BILLFORWARD_CLIENT_SECRET="insert-client-secret"
202
-
203
-
204
- # ---- Enable logging if you want (shows request and response bodies)
205
- USE_LOGGING=false
206
-
207
-
208
- # ---- Enable proxy if you want (for example to see requests in Fiddler)
209
- CLIENT_PROXY_ENABLED=false
210
- CLIENT_PROXY_URL="http://127.0.0.1:8888"
211
-
212
-
213
- ## These constants are required only for running situational tests (not in the main run):
214
- # ---- Required for Authorize.Net gateway tests only
215
- AUTHORIZE_NET_LOGIN_ID = 'FILL IN WITH AUTHORIZE NET LOGIN ID'
216
- AUTHORIZE_NET_TRANSACTION_KEY = 'FILL IN WITH AUTHORIZE NET TRANSACTION KEY'
217
- # ---- Required for Authorize.Net tokenization tests only
218
- AUTHORIZE_NET_CUSTOMER_PROFILE_ID = 12345678 # FILL IN WITH AUTHORIZE NET CUSTOMER PROFILE ID
219
- AUTHORIZE_NET_CUSTOMER_PAYMENT_PROFILE_ID = 12345678 # FILL IN WITH AUTHORIZE NET CUSTOMER PAYMENT PROFILE ID
220
- AUTHORIZE_NET_CARD_LAST_4_DIGITS = 1234
221
- end
222
- ```
223
-
224
- Run main functional tests + offline tests + situational tests with:
225
- ```bash
226
- rake spec_all
227
- ```
1
+ # BillForwardApiClient
2
+
3
+ This client library provides (via Ruby) easy access to the BillForward API.
4
+
5
+ ## Installation
6
+ ### From Git
7
+
8
+ Add this line to your application's Gemfile and run `bundle`:
9
+
10
+ ```ruby
11
+ gem 'bill_forward', :git => 'git@github.com:billforward/bf-ruby.git', :branch => 'master'
12
+ ```
13
+
14
+ Or install this source as a local gem using:
15
+
16
+ ```bash
17
+ bundle
18
+ gem build bill_forward.gemspec
19
+ gem install bill_forward
20
+ ```
21
+
22
+ ### From RubyGems mirror
23
+
24
+ Add the `bill_forward` gem to your application's Gemfile and run `bundle`:
25
+ ```ruby
26
+ source 'https://rubygems.org'
27
+ gem 'bill_forward'
28
+ ```
29
+
30
+ ## Usage
31
+ ### Including the Gem
32
+
33
+ Once installed, require the BillForward gem:
34
+
35
+ ```ruby
36
+ require 'bill_forward'
37
+ ```
38
+
39
+ ### Getting Credentials
40
+ You will need an API token. First log into your [Sandbox account](https://app-sandbox.billforward.net/login/#/) ([register](https://app-sandbox.billforward.net/register/#/) if necessary).
41
+
42
+ Then [generate an API token](https://app-sandbox.billforward.net/setup/#/personal/api-keys).
43
+
44
+ We support also client-id and client-secret authentication. For details, please [contact BillForward support](http://www.billforward.net/contact-us/).
45
+
46
+ ### Connecting
47
+
48
+ Create a default Client. Requests will be sent using its credentials:
49
+
50
+ ```ruby
51
+ my_client = BillForward::Client.new(
52
+ :host => "API URL goes here",
53
+ :api_token => "API token goes here"
54
+ )
55
+ BillForward::Client.default_client = my_client
56
+ ```
57
+
58
+ ### Invocation
59
+
60
+ ##### Getting single entities:
61
+
62
+ e.g. Get Subscription by ID:
63
+
64
+ ```ruby
65
+ subscription = BillForward::Subscription.get_by_id '3C39A79F-777E-4BDF-BDDC-221652F74E9D'
66
+ puts subscription
67
+ ```
68
+
69
+ ##### Accessing entity variables:
70
+
71
+ The entity can be accessed as a HashWithIndifferentAccess, or as an array.
72
+
73
+ ```ruby
74
+ # The following are equivalent:
75
+ puts subscription.id
76
+ puts subscription['id']
77
+ puts subscription[:id]
78
+ ```
79
+
80
+ ##### Getting a list of entities:
81
+
82
+ e.g. List Accounts
83
+
84
+ ```ruby
85
+ query_params = {
86
+ 'records' => 3,
87
+ 'order_by' => 'created',
88
+ 'order' => 'ASC'
89
+ }
90
+ accounts = BillForward::Account.get_all query_params
91
+ puts accounts
92
+ ```
93
+
94
+ ##### Creating an entity:
95
+
96
+ e.g. Create simple Account
97
+
98
+ ```ruby
99
+ created_account = BillForward::Account.create
100
+ ```
101
+
102
+ e.g. Create complex Account
103
+
104
+ ```ruby
105
+ # Create an account with a profile (where the profile has addresses)
106
+ addresses = Array.new
107
+ addresses.push(
108
+ BillForward::Address.new({
109
+ 'addressLine1' => 'address line 1',
110
+ 'addressLine2' => 'address line 2',
111
+ 'addressLine3' => 'address line 3',
112
+ 'city' => 'London',
113
+ 'province' => 'London',
114
+ 'country' => 'United Kingdom',
115
+ 'postcode' => 'SW1 1AS',
116
+ 'landline' => '02000000000',
117
+ 'primaryAddress' => true
118
+ }))
119
+ profile = BillForward::Profile.new({
120
+ 'email' => 'always@testing.is.moe',
121
+ 'firstName' => 'Test',
122
+ 'addresses' => addresses
123
+ })
124
+ account = BillForward::Account.new({
125
+ 'profile' => profile
126
+ })
127
+ created_account = BillForward::Account.create account
128
+ puts created_account
129
+ ```
130
+
131
+ ##### Updating an entity
132
+
133
+ ```ruby
134
+ gotten_account = BillForward::Account.get_by_id '908AF77A-0E5D-4D80-9B91-31EDE9962BF6'
135
+ gotten_account.profile.email = 'sometimes@testing.is.moe'
136
+ updated_account = gotten_account.save() # or: gotten_account.profile.save()
137
+ puts updated_account
138
+ ```
139
+
140
+ ## Documentation
141
+
142
+ View our [API Documentation](https://app-sandbox.billforward.net/#/api/method/accounts/POST?api=Ruby&path=%2Faccounts).
143
+
144
+ ## Development
145
+ ### Building
146
+ Clone the source, then run `bundle`.
147
+ ```bash
148
+ bundle
149
+ ```
150
+ If ever you add a new dependency, you will need to run this again.
151
+
152
+ To install the gem, run:
153
+ ```ruby
154
+ gem build bill_forward.gemspec
155
+ gem install bill_forward
156
+ ```
157
+
158
+ Maybe you find yourself running the above two snippets very often.
159
+ You can invoke them more simply by running `tools/local_bundle_install.sh`.
160
+
161
+ ### Invoking unpacked gem
162
+ The `scratch/` directory contains a Gemfile that includes this repo's gem, without having to repeatedly bundle and gem build & install upon changes.
163
+
164
+ Run `bundle` once in the `scratch/` directory to pull in its dependent gems.
165
+
166
+ You can recruit this Gemfile using a file like as `scratch/scratch.example.rb`.
167
+ Make your own `scratch/scratch.rb` (this particular path is exempt from version control), or any file ending in `.scratch.rb` to play around with this gem locally.
168
+
169
+ In Sublime I use such a build system to run `.rb` scratch files:
170
+
171
+ ```json
172
+ {
173
+ "env": {
174
+ "PATH":"${HOME}/.rvm/bin:${PATH}"
175
+ },
176
+ "cmd": ["rvm-auto-ruby", "-rubygems", "${file}" ],
177
+ "selector": "source.ruby"
178
+ }
179
+ ```
180
+
181
+ You'll find this build system in `tools/Ruby\ legacy.sublime-build`.
182
+
183
+ ### Running tests
184
+ Development is decidedly test-driven.
185
+
186
+ We use RSpec for testing.
187
+
188
+ Run offline tests with:
189
+ ```bash
190
+ rake
191
+ ```
192
+
193
+ If you wish to run online tests also, you will need to declare some test constants. Create a file `test_constants.rb` in the directory `spec/`, containing the following declarations:
194
+
195
+ ```ruby
196
+ module BillForwardTest
197
+ BILLFORWARD_API_HOST='insert-API-URL-here'
198
+ BILLFORWARD_API_TOKEN="insert-access-token-here OR leave-blank-for-OAUTH"
199
+
200
+ ### alternatively:
201
+ # (these values are used if you leave API token blank)
202
+ # authenticate using OAUTH:
203
+ BILLFORWARD_USERNAME="insert-username"
204
+ BILLFORWARD_PASSWORD="insert-password"
205
+ BILLFORWARD_CLIENT_ID="insert-client-id"
206
+ BILLFORWARD_CLIENT_SECRET="insert-client-secret"
207
+
208
+
209
+ # ---- Enable logging if you want (shows request and response bodies)
210
+ USE_LOGGING=false
211
+
212
+
213
+ # ---- Enable proxy if you want (for example to see requests in Fiddler)
214
+ CLIENT_PROXY_ENABLED=false
215
+ CLIENT_PROXY_URL="http://127.0.0.1:8888"
216
+ end
217
+ ```
218
+
219
+ In Sublime I use such a build system to run individual `_spec.rb` specs:
220
+
221
+ ```json
222
+ {
223
+ "env": {
224
+ "PATH":"${HOME}/.rvm/bin:${PATH}"
225
+ },
226
+ "cmd": ["rvm-auto-ruby","-S", "bundle", "exec", "rspec", "-I ${file_path}", "$file"],
227
+ "working_dir": "${project_path}",
228
+ "selector": "source.ruby",
229
+
230
+ "windows":
231
+ {
232
+ "cmd": ["rspec.bat", "-I ${file_path}", "$file"]
233
+ }
234
+ }
235
+ ```
236
+
237
+ You'll find this build system in `tools/RSpec.sublime-build`.
238
+
239
+ Run main functional tests + offline tests with:
240
+ ```bash
241
+ rake spec_main
242
+ ```
243
+
244
+ There are further tests still that can be run, but these are situational -- for example, they require an invoice to exist already, or require credentials to be declared for a payment gateway.
245
+
246
+ You can specify constants for use in situational tests in the usual test constants file, as before:
247
+
248
+ ```ruby
249
+ module BillForwardTest
250
+ BILLFORWARD_API_HOST='insert-API-URL-here'
251
+ BILLFORWARD_API_TOKEN="insert-access-token-here OR leave-blank-for-OAUTH"
252
+
253
+ ### alternatively:
254
+ # (these values are used if you leave API token blank)
255
+ # authenticate using OAUTH:
256
+ BILLFORWARD_USERNAME="insert-username"
257
+ BILLFORWARD_PASSWORD="insert-password"
258
+ BILLFORWARD_CLIENT_ID="insert-client-id"
259
+ BILLFORWARD_CLIENT_SECRET="insert-client-secret"
260
+
261
+
262
+ # ---- Enable logging if you want (shows request and response bodies)
263
+ USE_LOGGING=false
264
+
265
+
266
+ # ---- Enable proxy if you want (for example to see requests in Fiddler)
267
+ CLIENT_PROXY_ENABLED=false
268
+ CLIENT_PROXY_URL="http://127.0.0.1:8888"
269
+
270
+
271
+ ## These constants are required only for running situational tests (not in the main run):
272
+ # ---- Required for Authorize.Net gateway tests only
273
+ AUTHORIZE_NET_LOGIN_ID = 'FILL IN WITH AUTHORIZE NET LOGIN ID'
274
+ AUTHORIZE_NET_TRANSACTION_KEY = 'FILL IN WITH AUTHORIZE NET TRANSACTION KEY'
275
+ # ---- Required for Authorize.Net tokenization tests only
276
+ AUTHORIZE_NET_CUSTOMER_PROFILE_ID = 12345678 # FILL IN WITH AUTHORIZE NET CUSTOMER PROFILE ID
277
+ AUTHORIZE_NET_CUSTOMER_PAYMENT_PROFILE_ID = 12345678 # FILL IN WITH AUTHORIZE NET CUSTOMER PAYMENT PROFILE ID
278
+ AUTHORIZE_NET_CARD_LAST_4_DIGITS = 1234
279
+ end
280
+ ```
281
+
282
+ Run main functional tests + offline tests + situational tests with:
283
+ ```bash
284
+ rake spec_all
285
+ ```
data/Rakefile CHANGED
@@ -1,73 +1,73 @@
1
- require "bundler/gem_tasks"
2
-
3
- begin
4
- require 'rspec/core/rake_task'
5
-
6
- # these specs test syntax and language features
7
- syntax_specs = FileList['spec/syntax/*_spec.rb']
8
- # these specs use mocking to test entities without calling a real API
9
- component_specs = FileList['spec/component/*_spec.rb']
10
- # these specs call the API, but in a read-only manner
11
- functional_good_citizen_specs = FileList['spec/functional/*_spec.rb']
12
- # these specs call the API, leaving lasting side-effects
13
- functional_bad_citizen_specs = FileList['spec/functional/bad_citizen/*_spec.rb']
14
- # these specs call the API, and also require prior setup (for example, ensure an invoice exists beforehand)
15
- # we do not consider these part of the main run, as they're particularly bad citizens
16
- functional_situational_specs = FileList['spec/functional/bad_citizen/situational/*_spec.rb']
17
-
18
- # offline tests
19
- fast_specs = FileList[]
20
- fast_specs.concat(syntax_specs)
21
- fast_specs.concat(component_specs)
22
-
23
- # offline tests + main functional run
24
- main_specs = FileList[]
25
- main_specs.concat(fast_specs)
26
- puts functional_good_citizen_specs
27
- main_specs.concat(functional_good_citizen_specs)
28
- main_specs.concat(functional_bad_citizen_specs)
29
-
30
- # offline tests + main functional run + situational functional
31
- all_specs = FileList[]
32
- all_specs.concat(main_specs)
33
- all_specs.concat(functional_situational_specs)
34
-
35
-
36
- RSpec::Core::RakeTask.new(:spec_offline) do |t|
37
- spec_files = FileList[]
38
- spec_files.concat(fast_specs)
39
-
40
- # trick t.pattern into accepting a list of files (otherwise deprecated)
41
- # otherwise globbing does not work on Windows (only first file is matched)
42
- t.pattern = spec_files
43
-
44
- t.rspec_opts = "--color --format documentation"
45
- end
46
-
47
- RSpec::Core::RakeTask.new(:spec_main) do |t|
48
- spec_files = FileList[]
49
- spec_files.concat(main_specs)
50
-
51
- # trick t.pattern into accepting a list of files (otherwise deprecated)
52
- # otherwise globbing does not work on Windows (only first file is matched)
53
- t.pattern = spec_files
54
-
55
- t.rspec_opts = "--color --format documentation"
56
- end
57
-
58
- RSpec::Core::RakeTask.new(:spec_all) do |t|
59
- spec_files = FileList[]
60
- spec_files.concat(all_specs)
61
-
62
- # trick t.pattern into accepting a list of files (otherwise deprecated)
63
- # otherwise globbing does not work on Windows (only first file is matched)
64
- t.pattern = spec_files
65
-
66
- t.rspec_opts = "--color --format documentation"
67
- end
68
-
69
- # Make 'Rspec test run' the default task
70
- task :default => :spec_offline
71
- rescue LoadError
72
- # no rspec available
73
- end
1
+ require "bundler/gem_tasks"
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+
6
+ # these specs test syntax and language features
7
+ syntax_specs = FileList['spec/syntax/*_spec.rb']
8
+ # these specs use mocking to test entities without calling a real API
9
+ component_specs = FileList['spec/component/*_spec.rb']
10
+ # these specs call the API, but in a read-only manner
11
+ functional_good_citizen_specs = FileList['spec/functional/*_spec.rb']
12
+ # these specs call the API, leaving lasting side-effects
13
+ functional_bad_citizen_specs = FileList['spec/functional/bad_citizen/*_spec.rb']
14
+ # these specs call the API, and also require prior setup (for example, ensure an invoice exists beforehand)
15
+ # we do not consider these part of the main run, as they're particularly bad citizens
16
+ functional_situational_specs = FileList['spec/functional/bad_citizen/situational/*_spec.rb']
17
+
18
+ # offline tests
19
+ fast_specs = FileList[]
20
+ fast_specs.concat(syntax_specs)
21
+ fast_specs.concat(component_specs)
22
+
23
+ # offline tests + main functional run
24
+ main_specs = FileList[]
25
+ main_specs.concat(fast_specs)
26
+ puts functional_good_citizen_specs
27
+ main_specs.concat(functional_good_citizen_specs)
28
+ main_specs.concat(functional_bad_citizen_specs)
29
+
30
+ # offline tests + main functional run + situational functional
31
+ all_specs = FileList[]
32
+ all_specs.concat(main_specs)
33
+ all_specs.concat(functional_situational_specs)
34
+
35
+
36
+ RSpec::Core::RakeTask.new(:spec_offline) do |t|
37
+ spec_files = FileList[]
38
+ spec_files.concat(fast_specs)
39
+
40
+ # trick t.pattern into accepting a list of files (otherwise deprecated)
41
+ # otherwise globbing does not work on Windows (only first file is matched)
42
+ t.pattern = spec_files
43
+
44
+ t.rspec_opts = "--color --format documentation"
45
+ end
46
+
47
+ RSpec::Core::RakeTask.new(:spec_main) do |t|
48
+ spec_files = FileList[]
49
+ spec_files.concat(main_specs)
50
+
51
+ # trick t.pattern into accepting a list of files (otherwise deprecated)
52
+ # otherwise globbing does not work on Windows (only first file is matched)
53
+ t.pattern = spec_files
54
+
55
+ t.rspec_opts = "--color --format documentation"
56
+ end
57
+
58
+ RSpec::Core::RakeTask.new(:spec_all) do |t|
59
+ spec_files = FileList[]
60
+ spec_files.concat(all_specs)
61
+
62
+ # trick t.pattern into accepting a list of files (otherwise deprecated)
63
+ # otherwise globbing does not work on Windows (only first file is matched)
64
+ t.pattern = spec_files
65
+
66
+ t.rspec_opts = "--color --format documentation"
67
+ end
68
+
69
+ # Make 'Rspec test run' the default task
70
+ task :default => :spec_offline
71
+ rescue LoadError
72
+ # no rspec available
73
+ end