pactas_itero 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +15 -0
  3. data/.rubocop.yml +765 -0
  4. data/CHANGELOG.md +15 -0
  5. data/Gemfile +2 -0
  6. data/Rakefile +3 -0
  7. data/lib/pactas_itero/api/contracts.rb +7 -0
  8. data/lib/pactas_itero/api/customers.rb +2 -0
  9. data/lib/pactas_itero/api/invoices.rb +2 -0
  10. data/lib/pactas_itero/api/oauth.rb +2 -0
  11. data/lib/pactas_itero/api/orders.rb +2 -0
  12. data/lib/pactas_itero/api/rated_items.rb +11 -2
  13. data/lib/pactas_itero/api.rb +2 -0
  14. data/lib/pactas_itero/client.rb +11 -9
  15. data/lib/pactas_itero/configurable.rb +8 -6
  16. data/lib/pactas_itero/default.rb +7 -5
  17. data/lib/pactas_itero/error.rb +39 -35
  18. data/lib/pactas_itero/ext/hash/camelize_keys.rb +6 -3
  19. data/lib/pactas_itero/response/raise_error.rb +3 -1
  20. data/lib/pactas_itero/version.rb +3 -1
  21. data/lib/pactas_itero.rb +3 -1
  22. metadata +11 -83
  23. data/Gemfile.lock +0 -112
  24. data/bin/setup +0 -7
  25. data/pactas_itero.gemspec +0 -37
  26. data/spec/fixtures/bearer_token.json +0 -5
  27. data/spec/fixtures/commit_order_response.json +0 -50
  28. data/spec/fixtures/contract.json +0 -46
  29. data/spec/fixtures/contract_cancellation_preview_response.json +0 -73
  30. data/spec/fixtures/contract_changes.json +0 -22
  31. data/spec/fixtures/contract_termination_response.json +0 -79
  32. data/spec/fixtures/contracts.json +0 -48
  33. data/spec/fixtures/create_order_response.json +0 -17
  34. data/spec/fixtures/create_rated_item.json +0 -8
  35. data/spec/fixtures/customer.json +0 -23
  36. data/spec/fixtures/customers.json +0 -40
  37. data/spec/fixtures/invoice.json +0 -22
  38. data/spec/fixtures/invoice_download.pdf +0 -0
  39. data/spec/fixtures/invoices.json +0 -46
  40. data/spec/fixtures/order.json +0 -15
  41. data/spec/fixtures/payment_transaction.json +0 -37
  42. data/spec/fixtures/rated_items.json +0 -12
  43. data/spec/fixtures/self_service_token.json +0 -6
  44. data/spec/pactas_itero/api/contracts_spec.rb +0 -193
  45. data/spec/pactas_itero/api/customers_spec.rb +0 -231
  46. data/spec/pactas_itero/api/invoices_spec.rb +0 -103
  47. data/spec/pactas_itero/api/oauth_spec.rb +0 -44
  48. data/spec/pactas_itero/api/orders_spec.rb +0 -102
  49. data/spec/pactas_itero/api/payment_transactions_spec.rb +0 -66
  50. data/spec/pactas_itero/api/rated_items_spec.rb +0 -113
  51. data/spec/pactas_itero/client_spec.rb +0 -312
  52. data/spec/pactas_itero_spec.rb +0 -37
  53. data/spec/spec_helper.rb +0 -100
  54. data/yarn-error.log +0 -43
@@ -1,102 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe PactasItero::Api::Orders do
4
- describe ".create_order" do
5
- it "requests the correct resource" do
6
- client = PactasItero::Client.new(bearer_token: "bt")
7
- post_data = {
8
- ContractId: "5370e5ab9e40071fd01e01e0",
9
- Cart: {
10
- PlanVariantId: "525bf9089e40073a58590fd5",
11
- },
12
- }.to_json
13
- request = stub_post("/api/v1/orders").
14
- with(body: post_data).
15
- to_return(
16
- body: fixture("create_order_response.json"),
17
- headers: { content_type: "application/json; charset=utf-8" },
18
- )
19
-
20
- client.create_order(
21
- contract_id: "5370e5ab9e40071fd01e01e0",
22
- cart: {
23
- plan_variant_id: "525bf9089e40073a58590fd5",
24
- },
25
- )
26
-
27
- expect(request).to have_been_made
28
- end
29
-
30
- it "returns the created order" do
31
- client = PactasItero::Client.new(bearer_token: "bt")
32
- post_data = {
33
- ContractId: "5370e5ab9e40071fd01e01e0",
34
- Cart: {
35
- PlanVariantId: "525bf9089e40073a58590fd5",
36
- },
37
- }.to_json
38
- request = stub_post("/api/v1/orders").
39
- with(body: post_data).
40
- to_return(
41
- body: fixture("create_order_response.json"),
42
- headers: { content_type: "application/json; charset=utf-8" },
43
- )
44
-
45
- order = client.create_order(
46
- contract_id: "5370e5ab9e40071fd01e01e0",
47
- cart: {
48
- plan_variant_id: "525bf9089e40073a58590fd5",
49
- },
50
- )
51
-
52
- expect(order.id).to eq "537dfcab9e400760b4cd6347"
53
- expect(order.contract_id).to eq "5370e5ab9e40071fd01e01e0"
54
- end
55
- end
56
-
57
- describe ".order" do
58
- it "requests the correct resource" do
59
- client = PactasItero::Client.new(bearer_token: "bt")
60
- request = stub_get("/api/v1/orders/5357bc4f1d8dd00fa0db6c31").
61
- to_return(
62
- body: fixture("order.json"),
63
- headers: { content_type: "application/json; charset=utf-8" },
64
- )
65
-
66
- client.order("5357bc4f1d8dd00fa0db6c31")
67
-
68
- expect(request).to have_been_made
69
- end
70
- end
71
-
72
- describe ".commit_order" do
73
- it "requests the correct resource" do
74
- client = PactasItero::Client.new(bearer_token: "bt")
75
- request = stub_post("/api/v1/orders/537dfcab9e400760b4cd6347/commit").
76
- with(body: {}.to_json).
77
- to_return(
78
- body: fixture("commit_order_response.json"),
79
- headers: { content_type: "application/json; charset=utf-8" },
80
- )
81
-
82
- client.commit_order("537dfcab9e400760b4cd6347")
83
-
84
- expect(request).to have_been_made
85
- end
86
-
87
- it "returns the updated contract" do
88
- client = PactasItero::Client.new(bearer_token: "bt")
89
- request = stub_post("/api/v1/orders/537dfcab9e400760b4cd6347/commit").
90
- with(body: {}.to_json).
91
- to_return(
92
- body: fixture("commit_order_response.json"),
93
- headers: { content_type: "application/json; charset=utf-8" },
94
- )
95
-
96
- contract = client.commit_order("537dfcab9e400760b4cd6347")
97
-
98
- expect(contract.id).to eq "5370e5ab9e40071fd01e01e0"
99
- expect(contract.current_phase.plan_variant_id).to eq "525bf9089e40073a58590fd5"
100
- end
101
- end
102
- end
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- describe PactasItero::Api::PaymentTransactions do
5
- describe ".payment_transaction" do
6
- it "requests the correct resource" do
7
- client = PactasItero::Client.new(bearer_token: "bearer_token")
8
- request = stub_get("/api/v1/PaymentTransactions/payment_transaction_id").to_return(
9
- body: fixture("payment_transaction.json"),
10
- headers: { content_type: "application/json; charset=utf-8" },
11
- )
12
-
13
- client.payment_transaction("payment_transaction_id")
14
-
15
- expect(request).to have_been_made
16
- end
17
-
18
- it "returns the payment transaction details" do
19
- client = PactasItero::Client.new(bearer_token: "bearer_token")
20
- stub_get("/api/v1/PaymentTransactions/payment_transaction_id").to_return(
21
- body: fixture("payment_transaction.json"),
22
- headers: { content_type: "application/json; charset=utf-8" },
23
- )
24
-
25
- transaction = client.payment_transaction("payment_transaction_id")
26
-
27
- expect(transaction.amount).to eq 11.89
28
- expect(transaction.contract_id).to eq "592d74a981b1f010f04293a4"
29
- expect(transaction.currency).to eq "EUR"
30
- expect(transaction.customer_id).to eq "592d74a881b1f010f04293a2"
31
- expect(transaction.customer_name).to eq "Example Company"
32
- expect(transaction.id).to eq "597de03d81b1ef0d18a46f4e"
33
- expect(transaction.payment_provider).to eq "Example Provider"
34
- expect(transaction.payment_provider_role).to eq "CreditCard"
35
- expect(transaction.preauth).to eq false
36
- expect(transaction.provider_transaction_id).to eq "ccec718e-271e-4d0e-b0e1-94894e40c0c7"
37
- expect(transaction.status).to eq(
38
- "amount" => 11.89,
39
- "http_code" => 0,
40
- "preauth" => false,
41
- "status" => "Succeeded",
42
- "timestamp" => "2017-07-30T13:33:49.9900000Z",
43
- )
44
- expect(transaction.status_history).to eq(
45
- [
46
- {
47
- "amount" => 11.89,
48
- "http_code" => 0,
49
- "preauth" => false,
50
- "status" => "InProgress",
51
- "timestamp" => "2017-07-30T13:33:49.9760000Z",
52
- },
53
- {
54
- "amount" => 11.89,
55
- "http_code" => 0,
56
- "preauth" => false,
57
- "status" => "Succeeded",
58
- "timestamp" => "2017-07-30T13:33:49.9900000Z",
59
- },
60
- ],
61
- )
62
- expect(transaction.status_timestamp).to eq "2017-07-30T13:33:49.9900000Z"
63
- expect(transaction.trigger).to eq "Recurring"
64
- end
65
- end
66
- end
@@ -1,113 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe PactasItero::Api::RatedItems do
4
- describe ".create_rated_item" do
5
- it "requests the correct resource" do
6
- client = PactasItero::Client.new(bearer_token: "bt")
7
- post_data = {
8
- PeriodStart: "2014-09-19T08:18:51.907Z",
9
- PeriodEnd: "2014-09-19T08:19:51.907Z",
10
- Quantity: 2,
11
- Description: "the description",
12
- PricePerUnit: 123.45,
13
- TaxPolicyId: "tax-policy-id",
14
- }.to_json
15
- request = stub_post("/api/v1/contracts/contract-id/ratedItems").
16
- with(body: post_data).
17
- to_return(
18
- body: fixture("create_rated_item.json"),
19
- headers: { content_type: "application/json; charset=utf-8" },
20
- )
21
-
22
- client.create_rated_item(
23
- "contract-id",
24
- 2,
25
- "the description",
26
- 123.45,
27
- "tax-policy-id",
28
- {
29
- period_start: "2014-09-19T08:18:51.907Z",
30
- period_end: "2014-09-19T08:19:51.907Z",
31
- },
32
- )
33
-
34
- expect(request).to have_been_made
35
- end
36
-
37
- it "returns the created rated item" do
38
- client = PactasItero::Client.new(bearer_token: "bt")
39
- post_data = {
40
- PeriodStart: "2014-09-19T08:18:51.907Z",
41
- PeriodEnd: "2014-09-19T08:19:51.907Z",
42
- Quantity: 2,
43
- Description: "the description",
44
- PricePerUnit: 123.45,
45
- TaxPolicyId: "tax-policy-id",
46
- }.to_json
47
- request = stub_post("/api/v1/contracts/contract-id/ratedItems").
48
- with(body: post_data).
49
- to_return(
50
- body: fixture("create_rated_item.json"),
51
- headers: { content_type: "application/json; charset=utf-8" },
52
- )
53
-
54
- rated_item = client.create_rated_item(
55
- "contract-id",
56
- 2,
57
- "the description",
58
- 123.45,
59
- "tax-policy-id",
60
- {
61
- period_start: "2014-09-19T08:18:51.907Z",
62
- period_end: "2014-09-19T08:19:51.907Z",
63
- },
64
- )
65
-
66
- expect(rated_item.description).to eq "the description"
67
- expect(rated_item.period_end).to eq "2014-09-19T08:18:51.907Z"
68
- expect(rated_item.period_start).to eq "2014-09-19T08:18:51.907Z"
69
- expect(rated_item.price_per_unit).to eq 123.45
70
- expect(rated_item.quantity).to eq 2
71
- expect(rated_item.tax_policy_id).to eq "tax-policy-id"
72
- end
73
- end
74
-
75
- describe ".rated_items" do
76
- it "returns rated items" do
77
- client = PactasItero::Client.new(bearer_token: "bt")
78
- stub_get("/api/v1/contracts/contract-id/ratedItems").
79
- to_return(
80
- body: fixture("rated_items.json"),
81
- headers: { content_type: "application/json; charset=utf-8" },
82
- )
83
-
84
- rated_items = client.rated_items("contract-id")
85
-
86
- expect(rated_items).to be_a Array
87
- rated_item = rated_items.first
88
- expect(rated_item.id).to eq "591b847314aa03167c5a3b08"
89
- expect(rated_item.line_item_id).to eq "59308e9781b1ef1190f21478"
90
- expect(rated_item.quantity).to eq 1
91
- expect(rated_item.price_per_unit).to eq 3.9
92
- expect(rated_item.tax_policy_id).to eq "tax-policy-id"
93
- expect(rated_item.description).to eq "1x DHL Versandmarken"
94
- expect(rated_item.period_end).to eq "2017-05-15T22:00:00.0000000Z"
95
- expect(rated_item.period_start).to eq "2017-05-15T22:00:00.0000000Z"
96
- end
97
- end
98
-
99
- describe ".delete_rated_item" do
100
- it "deletes a rated item" do
101
- client = PactasItero::Client.new(bearer_token: "bt")
102
- stub_delete("/api/v1/ratedItems/rated-item-id").
103
- to_return(
104
- body: "",
105
- headers: { content_type: "application/json; charset=utf-8" },
106
- )
107
-
108
- response = client.delete_rated_item("rated-item-id")
109
-
110
- expect(response).to be_nil
111
- end
112
- end
113
- end
@@ -1,312 +0,0 @@
1
- require "spec_helper"
2
- require "json"
3
-
4
- describe PactasItero::Client do
5
- before do
6
- PactasItero.reset!
7
- end
8
-
9
- describe "module configuration" do
10
- before do
11
- PactasItero.configure do |config|
12
- PactasItero::Configurable.keys.each do |key|
13
- config.send("#{key}=", "the #{key} value")
14
- end
15
- end
16
- end
17
-
18
- it "inherits the module configuration" do
19
- client = PactasItero::Client.new
20
-
21
- PactasItero::Configurable.keys.each do |key|
22
- expect(client.instance_variable_get(:"@#{key}")).to eq("the #{key} value")
23
- end
24
- end
25
-
26
- describe "with class level configuration" do
27
- before do
28
- @opts = {
29
- # connection_options: {ssl: {verify: false}},
30
- client_id: "the_client_id",
31
- client_secret: "the_client_secret",
32
- }
33
- end
34
-
35
- it "overrides module configuration" do
36
- client = PactasItero::Client.new(@opts)
37
-
38
- expect(client.client_id).to eq("the_client_id")
39
- expect(client.client_secret).to eq("the_client_secret")
40
- expect(client.user_agent).to eq(PactasItero.user_agent)
41
- end
42
-
43
- it "can set configuration after initialization" do
44
- client = PactasItero::Client.new
45
- client.configure do |config|
46
- @opts.each do |key, value|
47
- config.send("#{key}=", value)
48
- end
49
- end
50
-
51
- expect(client.client_id).to eq("the_client_id")
52
- expect(client.client_secret).to eq("the_client_secret")
53
- expect(client.user_agent).to eq(PactasItero.user_agent)
54
- end
55
- end
56
- end
57
-
58
- describe ".get" do
59
- it "requests the given resource using get" do
60
- client = PactasItero::Client.new(bearer_token: "bt")
61
- request = stub_get("/something?foo=bar")
62
-
63
- client.get "/something", foo: "bar"
64
-
65
- expect(request).to have_been_made
66
- end
67
-
68
- it "passes along request headers" do
69
- client = PactasItero::Client.new(bearer_token: "bt")
70
- request = stub_get("/").
71
- with(query: { foo: "bar" }, headers: { accept: "text/plain" })
72
- client.get "/", foo: "bar", accept: "text/plain"
73
-
74
- expect(request).to have_been_made
75
- end
76
- end
77
-
78
- describe ".head" do
79
- it "requests the given resource using head" do
80
- client = PactasItero::Client.new(bearer_token: "bt")
81
- request = stub_head("/something?foo=bar")
82
-
83
- client.head "/something", foo: "bar"
84
-
85
- expect(request).to have_been_made
86
- end
87
-
88
- it "passes along request headers" do
89
- client = PactasItero::Client.new(bearer_token: "bt")
90
- request = stub_head("/").
91
- with(query: { foo: "bar" }, headers: { accept: "text/plain" })
92
-
93
- client.head "/", foo: "bar", accept: "text/plain"
94
-
95
- expect(request).to have_been_made
96
- end
97
- end
98
-
99
- describe ".post" do
100
- it "requests the given resource using post" do
101
- client = PactasItero::Client.new(bearer_token: "bt")
102
- request = stub_post("/something").
103
- with(body: { foo: "bar" }.to_json)
104
-
105
- client.post "/something", foo: "bar"
106
-
107
- expect(request).to have_been_made
108
- end
109
-
110
- it "passes along request headers" do
111
- client = PactasItero::Client.new(bearer_token: "bt")
112
- headers = { "X-Foo" => "bar" }
113
- request = stub_post("/").
114
- with(body: { foo: "bar" }.to_json, headers: headers)
115
-
116
- client.post "/", foo: "bar", headers: headers
117
-
118
- expect(request).to have_been_made
119
- end
120
- end
121
-
122
- describe ".put" do
123
- it "requests the given resource using put" do
124
- client = PactasItero::Client.new(bearer_token: "bt")
125
- request = stub_put("/something").
126
- with(body: { foo: "bar" }.to_json)
127
-
128
- client.put "/something", foo: "bar"
129
-
130
- expect(request).to have_been_made
131
- end
132
-
133
- it "passes along request headers" do
134
- client = PactasItero::Client.new(bearer_token: "bt")
135
- headers = { "X-Foo" => "bar" }
136
- request = stub_put("/").
137
- with(body: { foo: "bar" }.to_json, headers: headers)
138
-
139
- client.put "/", foo: "bar", headers: headers
140
-
141
- expect(request).to have_been_made
142
- end
143
- end
144
-
145
- describe ".patch" do
146
- it "requests the given resource using patch" do
147
- client = PactasItero::Client.new(bearer_token: "bt")
148
- request = stub_patch("/something").
149
- with(body: { foo: "bar" }.to_json)
150
-
151
- client.patch "/something", foo: "bar"
152
-
153
- expect(request).to have_been_made
154
- end
155
-
156
- it "passes along request headers" do
157
- client = PactasItero::Client.new(bearer_token: "bt")
158
- headers = { "X-Foo" => "bar" }
159
- request = stub_patch("/").
160
- with(body: { foo: "bar" }.to_json, headers: headers)
161
-
162
- client.patch "/", foo: "bar", headers: headers
163
-
164
- expect(request).to have_been_made
165
- end
166
- end
167
-
168
- describe ".delete" do
169
- it "requests the given resource using delete" do
170
- client = PactasItero::Client.new(bearer_token: "bt")
171
- request = stub_delete("/something")
172
-
173
- client.delete "/something"
174
-
175
- expect(request).to have_been_made
176
- end
177
-
178
- it "passes along request headers" do
179
- client = PactasItero::Client.new(bearer_token: "bt")
180
- headers = { "X-Foo" => "bar" }
181
- request = stub_delete("/").with(headers: headers)
182
-
183
- client.delete "/", headers: headers
184
-
185
- expect(request).to have_been_made
186
- end
187
- end
188
-
189
- describe "when making requests" do
190
- it "uses the sandbox endpoint by default" do
191
- client = PactasItero::Client.new
192
-
193
- expect(client.api_endpoint).to eq "https://sandbox.billwerk.com/"
194
- end
195
-
196
- it "uses the production endpoint when production is set to true" do
197
- client = PactasItero::Client.new(production: true)
198
-
199
- expect(client.api_endpoint).to eq "https://app.billwerk.com/"
200
- end
201
-
202
- it "sets a default user agent" do
203
- client = PactasItero::Client.new(bearer_token: "bt")
204
- request = stub_get("/").
205
- with(headers: { user_agent: PactasItero::Default.user_agent })
206
-
207
- client.get "/"
208
-
209
- expect(request).to have_been_made
210
- end
211
-
212
- it "accepts a custom user agent" do
213
- user_agent = "Mozilla/1.0 (Win3.1)"
214
- client = PactasItero::Client.new(user_agent: user_agent, bearer_token: "bt")
215
- request = stub_get("/").with(headers: { user_agent: user_agent })
216
-
217
- client.get "/"
218
-
219
- expect(request).to have_been_made
220
- end
221
-
222
- it "creates the correct auth headers with supplied bearer_token" do
223
- token = "the_bearer_token"
224
- request = stub_get("/").with(headers: { authorization: "Bearer #{token}" })
225
- client = PactasItero::Client.new(bearer_token: token)
226
-
227
- client.get "/"
228
-
229
- expect(request).to have_been_made
230
- end
231
-
232
- it "creates the correct auth headers with supplied bearer_token" do
233
- token = OpenStruct.new(access_token: "the_bearer_token")
234
- client = PactasItero::Client.new(bearer_token: token)
235
-
236
- request = stub_get("/").with(headers: { authorization: "Bearer #{token.access_token}" })
237
-
238
- client.get "/"
239
-
240
- expect(request).to have_been_made
241
- end
242
- end
243
-
244
- context "error handling" do
245
- it "raises on 404" do
246
- client = PactasItero::Client.new(bearer_token: "bt")
247
- stub_get("/four_oh_four").to_return(status: 404)
248
-
249
- expect { client.get("/four_oh_four") }.to raise_error PactasItero::NotFound
250
- end
251
-
252
- it "raises on 500" do
253
- client = PactasItero::Client.new(bearer_token: "bt")
254
- stub_get("/five_oh_oh").to_return(status: 500)
255
-
256
- expect { client.get("/five_oh_oh") }.to raise_error PactasItero::InternalServerError
257
- end
258
-
259
- it "includes a message" do
260
- client = PactasItero::Client.new(bearer_token: "bt")
261
- stub_get("/with_message").to_return(
262
- status: 422,
263
- headers: { content_type: "application/json" },
264
- body: { Message: "'Something' is not a valid ObjectId. Expected a 24 digit hex string." }.to_json,
265
- )
266
-
267
- expect { client.get("/with_message") }.to raise_error(
268
- PactasItero::UnprocessableEntity,
269
- "GET https://sandbox.billwerk.com/with_message: " \
270
- "422 - 'Something' is not a valid ObjectId. Expected a 24 digit hex string.",
271
- )
272
- end
273
-
274
- it "raises a ClientError on unknown client errors" do
275
- client = PactasItero::Client.new(bearer_token: "bt")
276
- stub_get("/something").to_return(
277
- status: 418,
278
- headers: { content_type: "application/json" },
279
- body: { message: "I'm a teapot" }.to_json,
280
- )
281
-
282
- expect { client.get("/something") }.to raise_error PactasItero::ClientError
283
- end
284
-
285
- it "raises a ServerError on unknown server errors" do
286
- client = PactasItero::Client.new(bearer_token: "bt")
287
- stub_get("/something").to_return(
288
- status: 509,
289
- headers: { content_type: "application/json" },
290
- body: { message: "Bandwidth exceeded" }.to_json,
291
- )
292
-
293
- expect { client.get("/something") }.to raise_error PactasItero::ServerError
294
- end
295
- end
296
-
297
- describe ".sandbox_api_endpoint" do
298
- it "returns url of the sandbox endpoint" do
299
- client = PactasItero::Client.new
300
-
301
- expect(client.sandbox_api_endpoint).to eq "https://sandbox.billwerk.com"
302
- end
303
- end
304
-
305
- describe ".production_api_endpoint" do
306
- it "returns url of the sandbox endpoint" do
307
- client = PactasItero::Client.new
308
-
309
- expect(client.production_api_endpoint).to eq "https://app.billwerk.com"
310
- end
311
- end
312
- end
@@ -1,37 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe PactasItero do
4
- it "sets defaults" do
5
- PactasItero::Configurable.keys.each do |key|
6
- expect(PactasItero.instance_variable_get(:"@#{key}")).to eq(PactasItero::Default.send(key))
7
- end
8
- end
9
-
10
- describe ".client" do
11
- it "creates an PactasItero::Client" do
12
- expect(PactasItero.client).to be_kind_of PactasItero::Client
13
- end
14
-
15
- it "creates new client everytime" do
16
- expect(PactasItero.client).to_not eq(PactasItero.client)
17
- end
18
-
19
- it "allows stubbing the method" do
20
- pactas_client = instance_double(PactasItero::Client)
21
- allow(PactasItero).to receive(:client).and_return(pactas_client)
22
-
23
- expect(PactasItero.client).to be_kind_of RSpec::Mocks::InstanceVerifyingDouble
24
- end
25
- end
26
-
27
- describe ".configure" do
28
- PactasItero::Configurable.keys.each do |key|
29
- it "sets the #{key.to_s.gsub('_', ' ')}" do
30
- PactasItero.configure do |config|
31
- config.send("#{key}=", key)
32
- end
33
- expect(PactasItero.instance_variable_get(:"@#{key}")).to eq(key)
34
- end
35
- end
36
- end
37
- end