stripe 3.3.2 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +20 -0
  4. data/.rubocop_todo.yml +62 -0
  5. data/.travis.yml +1 -1
  6. data/Gemfile +19 -12
  7. data/History.txt +10 -0
  8. data/README.md +5 -1
  9. data/Rakefile +8 -5
  10. data/VERSION +1 -1
  11. data/bin/stripe-console +2 -2
  12. data/lib/stripe.rb +72 -74
  13. data/lib/stripe/account.rb +15 -17
  14. data/lib/stripe/alipay_account.rb +10 -7
  15. data/lib/stripe/api_operations/create.rb +1 -1
  16. data/lib/stripe/api_operations/delete.rb +1 -1
  17. data/lib/stripe/api_operations/list.rb +2 -2
  18. data/lib/stripe/api_operations/request.rb +5 -12
  19. data/lib/stripe/api_operations/save.rb +6 -6
  20. data/lib/stripe/api_resource.rb +7 -9
  21. data/lib/stripe/apple_pay_domain.rb +2 -2
  22. data/lib/stripe/application_fee.rb +5 -5
  23. data/lib/stripe/application_fee_refund.rb +5 -5
  24. data/lib/stripe/balance.rb +1 -1
  25. data/lib/stripe/balance_transaction.rb +2 -2
  26. data/lib/stripe/bank_account.rb +7 -7
  27. data/lib/stripe/bitcoin_receiver.rb +4 -2
  28. data/lib/stripe/bitcoin_transaction.rb +3 -1
  29. data/lib/stripe/card.rb +5 -5
  30. data/lib/stripe/charge.rb +18 -18
  31. data/lib/stripe/country_spec.rb +2 -2
  32. data/lib/stripe/coupon.rb +1 -1
  33. data/lib/stripe/customer.rb +23 -23
  34. data/lib/stripe/dispute.rb +3 -3
  35. data/lib/stripe/ephemeral_key.rb +4 -4
  36. data/lib/stripe/errors.rb +4 -4
  37. data/lib/stripe/event.rb +1 -1
  38. data/lib/stripe/file_upload.rb +5 -5
  39. data/lib/stripe/invoice.rb +7 -7
  40. data/lib/stripe/invoice_item.rb +1 -1
  41. data/lib/stripe/invoice_line_item.rb +1 -1
  42. data/lib/stripe/list_object.rb +14 -18
  43. data/lib/stripe/login_link.rb +3 -3
  44. data/lib/stripe/oauth.rb +15 -13
  45. data/lib/stripe/order.rb +5 -5
  46. data/lib/stripe/order_return.rb +1 -1
  47. data/lib/stripe/payout.rb +3 -3
  48. data/lib/stripe/plan.rb +1 -1
  49. data/lib/stripe/product.rb +1 -1
  50. data/lib/stripe/recipient.rb +3 -2
  51. data/lib/stripe/recipient_transfer.rb +1 -2
  52. data/lib/stripe/refund.rb +1 -1
  53. data/lib/stripe/reversal.rb +5 -5
  54. data/lib/stripe/singleton_api_resource.rb +3 -3
  55. data/lib/stripe/sku.rb +1 -1
  56. data/lib/stripe/source.rb +13 -10
  57. data/lib/stripe/stripe_client.rb +149 -169
  58. data/lib/stripe/stripe_object.rb +77 -76
  59. data/lib/stripe/subscription.rb +5 -5
  60. data/lib/stripe/subscription_item.rb +2 -2
  61. data/lib/stripe/three_d_secure.rb +1 -1
  62. data/lib/stripe/token.rb +1 -1
  63. data/lib/stripe/transfer.rb +3 -3
  64. data/lib/stripe/util.rb +77 -62
  65. data/lib/stripe/version.rb +1 -1
  66. data/lib/stripe/webhook.rb +14 -10
  67. data/stripe.gemspec +14 -14
  68. data/test/stripe/account_test.rb +69 -81
  69. data/test/stripe/alipay_account_test.rb +19 -1
  70. data/test/stripe/api_operations_test.rb +7 -7
  71. data/test/stripe/api_resource_test.rb +224 -260
  72. data/test/stripe/apple_pay_domain_test.rb +8 -8
  73. data/test/stripe/application_fee_refund_test.rb +8 -8
  74. data/test/stripe/application_fee_test.rb +3 -3
  75. data/test/stripe/balance_test.rb +2 -2
  76. data/test/stripe/bank_account_test.rb +9 -11
  77. data/test/stripe/charge_test.rb +11 -11
  78. data/test/stripe/country_spec_test.rb +4 -4
  79. data/test/stripe/coupon_test.rb +10 -10
  80. data/test/stripe/customer_card_test.rb +11 -15
  81. data/test/stripe/customer_test.rb +26 -27
  82. data/test/stripe/dispute_test.rb +8 -8
  83. data/test/stripe/ephemeral_key_test.rb +14 -14
  84. data/test/stripe/errors_test.rb +2 -2
  85. data/test/stripe/file_upload_test.rb +26 -28
  86. data/test/stripe/invoice_item_test.rb +14 -14
  87. data/test/stripe/invoice_line_item_test.rb +1 -1
  88. data/test/stripe/invoice_test.rb +37 -37
  89. data/test/stripe/list_object_test.rb +60 -76
  90. data/test/stripe/login_link_test.rb +14 -14
  91. data/test/stripe/oauth_test.rb +42 -50
  92. data/test/stripe/order_return_test.rb +5 -5
  93. data/test/stripe/order_test.rb +12 -12
  94. data/test/stripe/payout_test.rb +9 -9
  95. data/test/stripe/plan_test.rb +9 -9
  96. data/test/stripe/product_test.rb +8 -8
  97. data/test/stripe/recipient_test.rb +9 -10
  98. data/test/stripe/refund_test.rb +9 -9
  99. data/test/stripe/reversal_test.rb +10 -10
  100. data/test/stripe/sku_test.rb +8 -8
  101. data/test/stripe/source_test.rb +14 -16
  102. data/test/stripe/stripe_client_test.rb +235 -266
  103. data/test/stripe/stripe_object_test.rb +163 -147
  104. data/test/stripe/stripe_response_test.rb +4 -3
  105. data/test/stripe/subscription_item_test.rb +11 -11
  106. data/test/stripe/subscription_test.rb +14 -14
  107. data/test/stripe/three_d_secure_test.rb +2 -2
  108. data/test/stripe/transfer_test.rb +8 -8
  109. data/test/stripe/util_test.rb +59 -57
  110. data/test/stripe/webhook_test.rb +18 -16
  111. data/test/stripe_test.rb +4 -4
  112. data/test/test_data.rb +26 -26
  113. data/test/test_helper.rb +29 -25
  114. metadata +6 -10
  115. data/test/stripe/bitcoin_receiver_test.rb +0 -67
  116. data/test/stripe/bitcoin_transaction_test.rb +0 -19
  117. data/test/stripe/recipient_card_test.rb +0 -44
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class StripeResponseTest < Test::Unit::TestCase
@@ -29,8 +29,9 @@ module Stripe
29
29
  headers = { "Request-Id" => "request-id" }
30
30
 
31
31
  env = Faraday::Env.from(
32
- :status => 200, :body => body,
33
- :response_headers => headers)
32
+ status: 200, body: body,
33
+ response_headers: headers
34
+ )
34
35
  http_resp = Faraday::Response.new(env)
35
36
 
36
37
  resp = StripeResponse.from_faraday_response(http_resp)
@@ -1,32 +1,32 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class SubscriptionItemTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
6
  items = Stripe::SubscriptionItem.list(
7
- subscription: "sub_123",
7
+ subscription: "sub_123"
8
8
  )
9
9
  assert_requested :get, "#{Stripe.api_base}/v1/subscription_items",
10
- query: { subscription: "sub_123" }
11
- assert items.data.kind_of?(Array)
12
- assert items.data[0].kind_of?(Stripe::SubscriptionItem)
10
+ query: { subscription: "sub_123" }
11
+ assert items.data.is_a?(Array)
12
+ assert items.data[0].is_a?(Stripe::SubscriptionItem)
13
13
  end
14
14
 
15
15
  should "be retrievable" do
16
16
  item = Stripe::SubscriptionItem.retrieve("si_123")
17
17
  assert_requested :get, "#{Stripe.api_base}/v1/subscription_items/si_123"
18
- assert item.kind_of?(Stripe::SubscriptionItem)
18
+ assert item.is_a?(Stripe::SubscriptionItem)
19
19
  end
20
20
 
21
21
  should "be creatable" do
22
22
  item = Stripe::SubscriptionItem.create(
23
- item: 'silver',
23
+ item: "silver",
24
24
  plan: "sapphire-elite",
25
25
  quantity: 3,
26
26
  subscription: "sub_123"
27
27
  )
28
28
  assert_requested :post, "#{Stripe.api_base}/v1/subscription_items"
29
- assert item.kind_of?(Stripe::SubscriptionItem)
29
+ assert item.is_a?(Stripe::SubscriptionItem)
30
30
  end
31
31
 
32
32
  should "be saveable" do
@@ -37,16 +37,16 @@ module Stripe
37
37
  end
38
38
 
39
39
  should "be updateable" do
40
- item = Stripe::SubscriptionItem.update("si_123", metadata: {foo: 'bar'})
40
+ item = Stripe::SubscriptionItem.update("si_123", metadata: { foo: "bar" })
41
41
  assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/si_123"
42
- assert item.kind_of?(Stripe::SubscriptionItem)
42
+ assert item.is_a?(Stripe::SubscriptionItem)
43
43
  end
44
44
 
45
45
  should "be deletable" do
46
46
  item = Stripe::SubscriptionItem.retrieve("si_123")
47
47
  item = item.delete
48
48
  assert_requested :delete, "#{Stripe.api_base}/v1/subscription_items/#{item.id}"
49
- assert item.kind_of?(Stripe::SubscriptionItem)
49
+ assert item.is_a?(Stripe::SubscriptionItem)
50
50
  end
51
51
  end
52
52
  end
@@ -1,19 +1,19 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class SubscriptionTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
6
  subscriptions = Stripe::Subscription.list
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/subscriptions"
8
- assert subscriptions.data.kind_of?(Array)
9
- assert subscriptions.data[0].kind_of?(Stripe::Subscription)
8
+ assert subscriptions.data.is_a?(Array)
9
+ assert subscriptions.data[0].is_a?(Stripe::Subscription)
10
10
  end
11
11
 
12
12
  should "be retrievable" do
13
13
  subscription = Stripe::Subscription.retrieve("sub_123")
14
14
  assert_requested :get,
15
- "#{Stripe.api_base}/v1/subscriptions/sub_123"
16
- assert subscription.kind_of?(Stripe::Subscription)
15
+ "#{Stripe.api_base}/v1/subscriptions/sub_123"
16
+ assert subscription.is_a?(Stripe::Subscription)
17
17
  end
18
18
 
19
19
  should "be creatable" do
@@ -21,37 +21,37 @@ module Stripe
21
21
  customer: "cus_123"
22
22
  )
23
23
  assert_requested :post, "#{Stripe.api_base}/v1/subscriptions"
24
- assert subscription.kind_of?(Stripe::Subscription)
24
+ assert subscription.is_a?(Stripe::Subscription)
25
25
  end
26
26
 
27
27
  should "be saveable" do
28
28
  subscription = Stripe::Subscription.retrieve("sub_123")
29
- subscription.metadata['key'] = 'value'
29
+ subscription.metadata["key"] = "value"
30
30
  subscription.save
31
31
  assert_requested :post,
32
- "#{Stripe.api_base}/v1/subscriptions/#{subscription.id}"
32
+ "#{Stripe.api_base}/v1/subscriptions/#{subscription.id}"
33
33
  end
34
34
 
35
35
  should "be updateable" do
36
- subscription = Stripe::Subscription.update("sub_123", metadata: {foo: 'bar'})
36
+ subscription = Stripe::Subscription.update("sub_123", metadata: { foo: "bar" })
37
37
  assert_requested :post,
38
- "#{Stripe.api_base}/v1/subscriptions/sub_123"
39
- assert subscription.kind_of?(Stripe::Subscription)
38
+ "#{Stripe.api_base}/v1/subscriptions/sub_123"
39
+ assert subscription.is_a?(Stripe::Subscription)
40
40
  end
41
41
 
42
42
  should "be deletable" do
43
43
  subscription = Stripe::Subscription.retrieve("sub_123")
44
44
  subscription = subscription.delete
45
45
  assert_requested :delete,
46
- "#{Stripe.api_base}/v1/subscriptions/#{subscription.id}"
47
- assert subscription.kind_of?(Stripe::Subscription)
46
+ "#{Stripe.api_base}/v1/subscriptions/#{subscription.id}"
47
+ assert subscription.is_a?(Stripe::Subscription)
48
48
  end
49
49
 
50
50
  context "#delete_discount" do
51
51
  should "be able to delete a subscriptions's discount" do
52
52
  subscription = Stripe::Subscription.retrieve("sub_123")
53
53
  subscription = subscription.delete_discount
54
- assert subscription.kind_of?(Stripe::Subscription)
54
+ assert subscription.is_a?(Stripe::Subscription)
55
55
  end
56
56
  end
57
57
  end
@@ -1,11 +1,11 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class ThreeDSecureTest < Test::Unit::TestCase
5
5
  should "be retrievable" do
6
6
  secure = Stripe::ThreeDSecure.retrieve("tdsrc_123")
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/3d_secure/tdsrc_123"
8
- assert secure.kind_of?(Stripe::ThreeDSecure)
8
+ assert secure.is_a?(Stripe::ThreeDSecure)
9
9
  end
10
10
 
11
11
  should "be creatable" do
@@ -1,18 +1,18 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class TransferTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
6
  transfers = Stripe::Transfer.list
7
7
  assert_requested :get, "#{Stripe.api_base}/v1/transfers"
8
- assert transfers.data.kind_of?(Array)
9
- assert transfers.data[0].kind_of?(Stripe::Transfer)
8
+ assert transfers.data.is_a?(Array)
9
+ assert transfers.data[0].is_a?(Stripe::Transfer)
10
10
  end
11
11
 
12
12
  should "be retrievable" do
13
13
  transfer = Stripe::Transfer.retrieve("tr_123")
14
14
  assert_requested :get, "#{Stripe.api_base}/v1/transfers/tr_123"
15
- assert transfer.kind_of?(Stripe::Transfer)
15
+ assert transfer.is_a?(Stripe::Transfer)
16
16
  end
17
17
 
18
18
  should "be creatable" do
@@ -22,20 +22,20 @@ module Stripe
22
22
  destination: "acct_123"
23
23
  )
24
24
  assert_requested :post, "#{Stripe.api_base}/v1/transfers"
25
- assert transfer.kind_of?(Stripe::Transfer)
25
+ assert transfer.is_a?(Stripe::Transfer)
26
26
  end
27
27
 
28
28
  should "be saveable" do
29
29
  transfer = Stripe::Transfer.retrieve("tr_123")
30
- transfer.metadata['key'] = 'value'
30
+ transfer.metadata["key"] = "value"
31
31
  transfer.save
32
32
  assert_requested :post, "#{Stripe.api_base}/v1/transfers/#{transfer.id}"
33
33
  end
34
34
 
35
35
  should "be updateable" do
36
- transfer = Stripe::Transfer.update("tr_123", metadata: {foo: 'bar'})
36
+ transfer = Stripe::Transfer.update("tr_123", metadata: { foo: "bar" })
37
37
  assert_requested :post, "#{Stripe.api_base}/v1/transfers/tr_123"
38
- assert transfer.kind_of?(Stripe::Transfer)
38
+ assert transfer.is_a?(Stripe::Transfer)
39
39
  end
40
40
  end
41
41
  end
@@ -1,18 +1,18 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class UtilTest < Test::Unit::TestCase
5
5
  should "#encode_parameters should prepare parameters for an HTTP request" do
6
6
  params = {
7
- :a => 3,
8
- :b => "+foo?",
9
- :c => "bar&baz",
10
- :d => { :a => "a", :b => "b" },
11
- :e => [0, 1],
12
- :f => "",
7
+ a: 3,
8
+ b: "+foo?",
9
+ c: "bar&baz",
10
+ d: { a: "a", b: "b" },
11
+ e: [0, 1],
12
+ f: "",
13
13
 
14
14
  # note the empty hash won't even show up in the request
15
- :g => [],
15
+ g: [],
16
16
  }
17
17
  assert_equal(
18
18
  "a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[]=0&e[]=1&f=",
@@ -22,25 +22,25 @@ module Stripe
22
22
 
23
23
  should "#encode_params should throw an error on an array of maps that cannot be encoded" do
24
24
  params = {
25
- :a => [
26
- { :a => 1, :b => 2 },
27
- { :c => 3, :a => 4 },
28
- ]
25
+ a: [
26
+ { a: 1, b: 2 },
27
+ { c: 3, a: 4 },
28
+ ],
29
29
  }
30
30
  e = assert_raises(ArgumentError) do
31
31
  Stripe::Util.encode_parameters(params)
32
32
  end
33
- expected = "All maps nested in an array should start with the same key " +
34
- "(expected starting key 'a', got 'c')"
33
+ expected = "All maps nested in an array should start with the same key " \
34
+ "(expected starting key 'a', got 'c')"
35
35
  assert_equal expected, e.message
36
36
 
37
37
  # Make sure the check is recursive by taking our original params and
38
38
  # nesting it into yet another map and array. Should throw exactly the
39
39
  # same error because it's still the in inner array of maps that's wrong.
40
40
  params = {
41
- :x => [
42
- params
43
- ]
41
+ x: [
42
+ params,
43
+ ],
44
44
  }
45
45
  e = assert_raises(ArgumentError) do
46
46
  Stripe::Util.encode_parameters(params)
@@ -61,15 +61,15 @@ module Stripe
61
61
  [:a, 3],
62
62
  [:b, "foo?"],
63
63
  [:c, "bar&baz"],
64
- [:d, { :a => "a", :b => "b" }],
64
+ [:d, { a: "a", b: "b" }],
65
65
  [:e, [0, 1]],
66
66
  [:f, [
67
- { :foo => "1", :ghi => "2" },
68
- { :foo => "3", :bar => "4" },
69
- ]],
67
+ { foo: "1", ghi: "2" },
68
+ { foo: "3", bar: "4" },
69
+ ],],
70
70
  ]
71
71
  assert_equal([
72
- ["a", 3],
72
+ ["a", 3],
73
73
  ["b", "foo?"],
74
74
  ["c", "bar&baz"],
75
75
  ["d[a]", "a"],
@@ -89,22 +89,22 @@ module Stripe
89
89
 
90
90
  should "#symbolize_names should convert names to symbols" do
91
91
  start = {
92
- 'foo' => 'bar',
93
- 'array' => [{ 'foo' => 'bar' }],
94
- 'nested' => {
92
+ "foo" => "bar",
93
+ "array" => [{ "foo" => "bar" }],
94
+ "nested" => {
95
95
  1 => 2,
96
96
  :symbol => 9,
97
- 'string' => nil
98
- }
97
+ "string" => nil,
98
+ },
99
99
  }
100
100
  finish = {
101
- :foo => 'bar',
102
- :array => [{ :foo => 'bar' }],
103
- :nested => {
101
+ foo: "bar",
102
+ array: [{ foo: "bar" }],
103
+ nested: {
104
104
  1 => 2,
105
105
  :symbol => 9,
106
- :string => nil
107
- }
106
+ :string => nil,
107
+ },
108
108
  }
109
109
 
110
110
  symbolized = Stripe::Util.symbolize_names(start)
@@ -113,7 +113,7 @@ module Stripe
113
113
 
114
114
  should "#normalize_opts should reject nil keys" do
115
115
  assert_raise { Stripe::Util.normalize_opts(nil) }
116
- assert_raise { Stripe::Util.normalize_opts(:api_key => nil) }
116
+ assert_raise { Stripe::Util.normalize_opts(api_key: nil) }
117
117
  end
118
118
 
119
119
  should "#convert_to_stripe_object should pass through unknown types" do
@@ -122,18 +122,18 @@ module Stripe
122
122
  end
123
123
 
124
124
  should "#convert_to_stripe_object should turn hashes into StripeObjects" do
125
- obj = Util.convert_to_stripe_object({ :foo => "bar" }, {})
125
+ obj = Util.convert_to_stripe_object({ foo: "bar" }, {})
126
126
  assert obj.is_a?(StripeObject)
127
127
  assert_equal "bar", obj.foo
128
128
  end
129
129
 
130
130
  should "#convert_to_stripe_object should turn lists into ListObjects" do
131
- obj = Util.convert_to_stripe_object({ :object => "list" }, {})
131
+ obj = Util.convert_to_stripe_object({ object: "list" }, {})
132
132
  assert obj.is_a?(ListObject)
133
133
  end
134
134
 
135
135
  should "#convert_to_stripe_object should marshal other classes" do
136
- obj = Util.convert_to_stripe_object({ :object => "account" }, {})
136
+ obj = Util.convert_to_stripe_object({ object: "account" }, {})
137
137
  assert obj.is_a?(Account)
138
138
  end
139
139
 
@@ -143,23 +143,23 @@ module Stripe
143
143
  end
144
144
 
145
145
  should "#array_to_hash should convert an array into a hash with integer keys" do
146
- assert_equal({"0" => 1, "1" => 2, "2" => 3}, Util.array_to_hash([1, 2, 3]))
146
+ assert_equal({ "0" => 1, "1" => 2, "2" => 3 }, Util.array_to_hash([1, 2, 3]))
147
147
  end
148
148
 
149
149
  context ".request_id_dashboard_url" do
150
150
  should "generate a livemode URL" do
151
151
  assert_equal "https://dashboard.stripe.com/live/logs/request-id",
152
- Util.request_id_dashboard_url("request-id", "sk_live_123")
152
+ Util.request_id_dashboard_url("request-id", "sk_live_123")
153
153
  end
154
154
 
155
155
  should "generate a testmode URL" do
156
156
  assert_equal "https://dashboard.stripe.com/test/logs/request-id",
157
- Util.request_id_dashboard_url("request-id", "sk_test_123")
157
+ Util.request_id_dashboard_url("request-id", "sk_test_123")
158
158
  end
159
159
 
160
160
  should "default to a testmode URL" do
161
161
  assert_equal "https://dashboard.stripe.com/test/logs/request-id",
162
- Util.request_id_dashboard_url("request-id", nil)
162
+ Util.request_id_dashboard_url("request-id", nil)
163
163
  end
164
164
  end
165
165
 
@@ -296,20 +296,20 @@ module Stripe
296
296
  context ".normalize_headers" do
297
297
  should "normalize the format of a header key" do
298
298
  assert_equal({ "Request-Id" => nil },
299
- Util.normalize_headers({ "Request-Id" => nil }))
299
+ Util.normalize_headers("Request-Id" => nil))
300
300
  assert_equal({ "Request-Id" => nil },
301
- Util.normalize_headers({ "request-id" => nil }))
301
+ Util.normalize_headers("request-id" => nil))
302
302
  assert_equal({ "Request-Id" => nil },
303
- Util.normalize_headers({ "Request-ID" => nil }))
303
+ Util.normalize_headers("Request-ID" => nil))
304
304
  assert_equal({ "Request-Id" => nil },
305
- Util.normalize_headers({ :request_id => nil }))
305
+ Util.normalize_headers(request_id: nil))
306
306
  end
307
307
 
308
308
  should "tolerate bad formatting" do
309
309
  assert_equal({ "Request-Id" => nil },
310
- Util.normalize_headers({ "-Request--Id-" => nil }))
310
+ Util.normalize_headers("-Request--Id-" => nil))
311
311
  assert_equal({ "Request-Id" => nil },
312
- Util.normalize_headers({ :request__id => nil }))
312
+ Util.normalize_headers(request__id: nil))
313
313
  end
314
314
  end
315
315
 
@@ -324,7 +324,7 @@ module Stripe
324
324
  context ".colorize" do
325
325
  should "colorize for a TTY" do
326
326
  assert_equal "\033[0;32;49mfoo\033[0m",
327
- Util.send(:colorize, "foo", :green, true)
327
+ Util.send(:colorize, "foo", :green, true)
328
328
  end
329
329
 
330
330
  should "not colorize otherwise" do
@@ -348,21 +348,23 @@ module Stripe
348
348
  # Open this instance of StringIO, and add a method override so that it
349
349
  # looks like a TTY.
350
350
  out.instance_eval do
351
- def isatty; true; end
351
+ def isatty
352
+ true
353
+ end
352
354
  end
353
355
 
354
356
  Util.send(:log_internal, "message", { foo: "bar" },
355
- color: :green, level: Stripe::LEVEL_DEBUG, logger: nil, out: out)
357
+ color: :green, level: Stripe::LEVEL_DEBUG, logger: nil, out: out)
356
358
  assert_equal "\e[0;32;49mDEBU\e[0m message \e[0;32;49mfoo\e[0m=bar\n",
357
- out.string
359
+ out.string
358
360
  end
359
361
 
360
362
  should "log in a data friendly way" do
361
363
  out = StringIO.new
362
364
  Util.send(:log_internal, "message", { foo: "bar" },
363
- color: :green, level: Stripe::LEVEL_DEBUG, logger: nil, out: out)
365
+ color: :green, level: Stripe::LEVEL_DEBUG, logger: nil, out: out)
364
366
  assert_equal "message=message level=debug foo=bar\n",
365
- out.string
367
+ out.string
366
368
  end
367
369
 
368
370
  should "log to a logger if set" do
@@ -376,9 +378,9 @@ module Stripe
376
378
  }
377
379
 
378
380
  Util.send(:log_internal, "message", { foo: "bar" },
379
- color: :green, level: Stripe::LEVEL_DEBUG, logger: logger, out: nil)
381
+ color: :green, level: Stripe::LEVEL_DEBUG, logger: logger, out: nil)
380
382
  assert_equal "message=message foo=bar",
381
- out.string
383
+ out.string
382
384
  end
383
385
  end
384
386
 
@@ -395,15 +397,15 @@ module Stripe
395
397
  end
396
398
 
397
399
  should "wrap more complex values in double quotes" do
398
- assert_equal %{"abc=123"}, Util.send(:wrap_logfmt_value, %{abc=123})
400
+ assert_equal %("abc=123"), Util.send(:wrap_logfmt_value, %(abc=123))
399
401
  end
400
402
 
401
403
  should "escape double quotes already in the value" do
402
- assert_equal %{"abc=\\"123\\""}, Util.send(:wrap_logfmt_value, %{abc="123"})
404
+ assert_equal %("abc=\\"123\\""), Util.send(:wrap_logfmt_value, %(abc="123"))
403
405
  end
404
406
 
405
407
  should "remove newlines" do
406
- assert_equal %{"abc"}, Util.send(:wrap_logfmt_value, "a\nb\nc")
408
+ assert_equal %("abc"), Util.send(:wrap_logfmt_value, "a\nb\nc")
407
409
  end
408
410
 
409
411
  should "not error if given a non-string" do