gecko-ruby 0.9.1 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.github/config/rubocop_linter_action.yml +7 -0
  3. data/.github/workflows/testing.yml +26 -0
  4. data/.rubocop.yml +23 -16
  5. data/CHANGELOG.md +18 -0
  6. data/Gemfile +2 -0
  7. data/README.md +1 -1
  8. data/Rakefile +3 -1
  9. data/gecko-ruby.gemspec +11 -10
  10. data/generate.thor +4 -1
  11. data/lib/gecko-ruby.rb +2 -0
  12. data/lib/gecko.rb +3 -0
  13. data/lib/gecko/client.rb +17 -14
  14. data/lib/gecko/ext/liquid_compat.rb +10 -10
  15. data/lib/gecko/ext/log_subscriber.rb +6 -6
  16. data/lib/gecko/helpers/association_helper.rb +14 -12
  17. data/lib/gecko/helpers/inspection_helper.rb +4 -2
  18. data/lib/gecko/helpers/record_helper.rb +2 -0
  19. data/lib/gecko/helpers/serialization_helper.rb +5 -1
  20. data/lib/gecko/helpers/validation_helper.rb +3 -1
  21. data/lib/gecko/record/account.rb +4 -1
  22. data/lib/gecko/record/address.rb +2 -0
  23. data/lib/gecko/record/base.rb +5 -3
  24. data/lib/gecko/record/base_adapter.rb +33 -22
  25. data/lib/gecko/record/company.rb +3 -0
  26. data/lib/gecko/record/contact.rb +2 -0
  27. data/lib/gecko/record/currency.rb +2 -0
  28. data/lib/gecko/record/exceptions.rb +2 -0
  29. data/lib/gecko/record/fulfillment.rb +2 -0
  30. data/lib/gecko/record/fulfillment_line_item.rb +2 -1
  31. data/lib/gecko/record/image.rb +13 -8
  32. data/lib/gecko/record/invoice.rb +7 -3
  33. data/lib/gecko/record/invoice_line_item.rb +2 -1
  34. data/lib/gecko/record/location.rb +2 -0
  35. data/lib/gecko/record/note.rb +2 -0
  36. data/lib/gecko/record/order.rb +2 -0
  37. data/lib/gecko/record/order_line_item.rb +3 -0
  38. data/lib/gecko/record/payment_method.rb +15 -0
  39. data/lib/gecko/record/payment_term.rb +2 -1
  40. data/lib/gecko/record/product.rb +4 -0
  41. data/lib/gecko/record/purchase_order.rb +2 -1
  42. data/lib/gecko/record/purchase_order_line_item.rb +2 -1
  43. data/lib/gecko/record/tax_type.rb +2 -1
  44. data/lib/gecko/record/user.rb +3 -1
  45. data/lib/gecko/record/variant.rb +9 -7
  46. data/lib/gecko/record/webhook.rb +3 -1
  47. data/lib/gecko/version.rb +3 -1
  48. data/test/client_test.rb +4 -2
  49. data/test/fixtures/vcr_cassettes/images.yml +1 -1
  50. data/test/fixtures/vcr_cassettes/payment_methods.yml +69 -0
  51. data/test/fixtures/vcr_cassettes/payment_methods_count.yml +66 -0
  52. data/test/gecko_test.rb +2 -0
  53. data/test/helpers/association_helper_test.rb +7 -5
  54. data/test/helpers/inspection_helper_test.rb +6 -4
  55. data/test/helpers/serialization_helper_test.rb +16 -14
  56. data/test/helpers/validation_helper_test.rb +3 -1
  57. data/test/record/account_adapter_test.rb +2 -0
  58. data/test/record/address_adapter_test.rb +2 -0
  59. data/test/record/address_test.rb +2 -0
  60. data/test/record/company_adapter_test.rb +2 -0
  61. data/test/record/company_test.rb +2 -0
  62. data/test/record/contact_adapter_test.rb +2 -0
  63. data/test/record/contact_test.rb +3 -1
  64. data/test/record/currency_adapter_test.rb +2 -0
  65. data/test/record/currency_test.rb +2 -0
  66. data/test/record/fulfillment_adapter_test.rb +2 -0
  67. data/test/record/fulfillment_line_item_adapter_test.rb +2 -0
  68. data/test/record/fulfillment_line_item_test.rb +2 -0
  69. data/test/record/fulfillment_test.rb +4 -2
  70. data/test/record/image_adapter_test.rb +2 -0
  71. data/test/record/image_test.rb +18 -0
  72. data/test/record/invoice_adapter_test.rb +2 -0
  73. data/test/record/invoice_line_item_adapter_test.rb +2 -0
  74. data/test/record/invoice_line_item_test.rb +2 -0
  75. data/test/record/invoice_test.rb +2 -0
  76. data/test/record/location_adapter_test.rb +2 -0
  77. data/test/record/location_test.rb +2 -0
  78. data/test/record/note_test.rb +2 -0
  79. data/test/record/order_adapter_test.rb +2 -0
  80. data/test/record/order_line_item_adapter_test.rb +2 -0
  81. data/test/record/order_line_item_test.rb +2 -0
  82. data/test/record/order_test.rb +2 -0
  83. data/test/record/payment_method_adapter_test.rb +16 -0
  84. data/test/record/payment_method_test.rb +20 -0
  85. data/test/record/payment_term_adapter_test.rb +2 -0
  86. data/test/record/payment_term_test.rb +2 -0
  87. data/test/record/product_adapter_test.rb +2 -0
  88. data/test/record/product_test.rb +2 -0
  89. data/test/record/purchase_order_adapter_test.rb +2 -0
  90. data/test/record/purchase_order_line_item_adapter_test.rb +2 -0
  91. data/test/record/purchase_order_line_item_test.rb +2 -0
  92. data/test/record/purchase_order_test.rb +2 -0
  93. data/test/record/tax_type_adapter_test.rb +2 -0
  94. data/test/record/tax_type_test.rb +2 -0
  95. data/test/record/user_adapter_test.rb +2 -0
  96. data/test/record/user_test.rb +2 -0
  97. data/test/record/variant_adapter_test.rb +2 -0
  98. data/test/record/variant_test.rb +6 -4
  99. data/test/record/webhook_test.rb +2 -0
  100. data/test/support/let.rb +2 -0
  101. data/test/support/shared_adapter_examples.rb +35 -31
  102. data/test/support/shared_record_examples.rb +3 -1
  103. data/test/support/shared_sideloaded_data_parsing_examples.rb +2 -1
  104. data/test/support/testing_adapter.rb +2 -0
  105. data/test/support/vcr_support.rb +2 -0
  106. data/test/test_helper.rb +12 -0
  107. metadata +33 -23
  108. data/.travis.yml +0 -8
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko'
2
4
 
3
5
  class Gecko::Helpers::ValidationHelperTest < Minitest::Test
@@ -17,7 +19,7 @@ class Gecko::Helpers::ValidationHelperTest < Minitest::Test
17
19
 
18
20
  def test_from_response
19
21
  record = @klass.new(@client, name: "Gecko")
20
- record.errors.from_response({name: ["is not shiny"]})
22
+ record.errors.from_response({ name: ["is not shiny"] })
21
23
  assert(!record.valid?)
22
24
  assert_equal(record.errors[:name], ["is not shiny"])
23
25
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
  class Gecko::Record::AccountAdapterTest < Minitest::Test
3
5
  include TestingAdapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::AddressAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::AddressTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::CompanyAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::CompanyTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::ContactAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::ContactTest < Minitest::Test
@@ -15,4 +17,4 @@ class Gecko::ContactTest < Minitest::Test
15
17
  def test_initializes_record
16
18
  assert_instance_of(Gecko::Record::Contact, @record)
17
19
  end
18
- end
20
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::CurrencyAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::CurrencyTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::FulfillmentAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::FulfillmentLineItemAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::FulfillmentLineItemTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::FulfillmentTest < Minitest::Test
@@ -17,11 +19,11 @@ class Gecko::FulfillmentTest < Minitest::Test
17
19
  end
18
20
 
19
21
  def test_serialization
20
- json_keys = %w(
22
+ json_keys = %w[
21
23
  order_id shipping_address_id billing_address_id status stock_location_id exchange_rate
22
24
  delivery_type tracking_number notes tracking_url tracking_company packed_at
23
25
  service shipped_at received_at receipt
24
- ).map(&:to_sym)
26
+ ].map(&:to_sym)
25
27
  assert_equal json_keys.sort, @record.as_json[:fulfillment].keys.sort
26
28
  end
27
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::ImageAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::ImageTest < Minitest::Test
@@ -22,4 +24,20 @@ class Gecko::ImageTest < Minitest::Test
22
24
  assert_equal("https://example.com/Gecko.jpg", @record.url(:full))
23
25
  assert_equal("https://example.com/thumbnail_Gecko.jpg", @record.url(:thumbnail))
24
26
  end
27
+
28
+ def test_building_record # rubocop:disable Metrics/MethodLength
29
+ record = @client.adapter_for(record_class.demodulized_name).build({
30
+ variant_ids: 1,
31
+ product_id: 1,
32
+ url: "https://example.com/Gecko.jpg"
33
+ })
34
+ assert_equal(record.product_id, 1)
35
+ assert_equal(record.variant_ids, [1])
36
+ assert_equal(record.serializable_hash, {
37
+ product_id: 1,
38
+ variant_ids: [1],
39
+ name: nil,
40
+ url: "https://example.com/Gecko.jpg"
41
+ })
42
+ end
25
43
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::InvoiceAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::InvoiceLineItemAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::InvoiceLineItemTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::InvoiceTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::LocationAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::LocationTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::NoteTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::OrderAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::OrderLineItemAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::OrderLineItemTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::OrderTest < Minitest::Test
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class Gecko::Record::PaymentMethodAdapterTest < Minitest::Test
6
+ include TestingAdapter
7
+ include SharedAdapterExamples
8
+
9
+ let(:adapter) { @client.PaymentMethod }
10
+ let(:plural_name) { "payment_methods" }
11
+ let(:record_class) { Gecko::Record::PaymentMethod }
12
+
13
+ def test_initializes_adapter
14
+ assert_instance_of(Gecko::Record::PaymentMethodAdapter, @client.PaymentMethod)
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class Gecko::PaymentMethodTest < Minitest::Test
6
+ include VCRHelper
7
+ include SharedRecordExamples
8
+
9
+ let(:plural_name) { "payment_methods" }
10
+ let(:record_class) { Gecko::Record::PaymentMethod }
11
+
12
+ def setup
13
+ @json = load_vcr_hash("payment_methods", "payment_methods").first
14
+ @record = record_class.new(client, @json)
15
+ end
16
+
17
+ def test_initializes_record
18
+ assert_instance_of(Gecko::Record::PaymentMethod, @record)
19
+ end
20
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::PaymentTermAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::PaymentTermTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::ProductAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::ProductTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::PurchaseOrderAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::PurchaseOrderLineItemAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::PurchaseOrderLineItemTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::PurchaseOrderTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::TaxTypeAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::TaxTypeTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::UserAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::UserTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::Record::VariantAdapterTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::VariantTest < Minitest::Test
@@ -22,7 +24,7 @@ class Gecko::VariantTest < Minitest::Test
22
24
  end
23
25
 
24
26
  def test_variant_prices
25
- json = {variant_prices: [{price_list_id: "buy", value: "12.50"}, {price_list_id: 123, value: "14.00"}]}
27
+ json = { variant_prices: [{ price_list_id: "buy", value: "12.50" }, { price_list_id: 123, value: "14.00" }] }
26
28
  variant_prices = record_class.new(client, json).variant_prices
27
29
  assert_instance_of(Gecko::Record::Variant::VariantPrice, variant_prices.first)
28
30
  assert_equal(variant_prices[0].price_list_id, "buy")
@@ -31,10 +33,10 @@ class Gecko::VariantTest < Minitest::Test
31
33
  end
32
34
 
33
35
  def test_variant_locations
34
- json = {locations: [
36
+ json = { locations: [
35
37
  { location_id: 1, stock_on_hand: "12.50",
36
- committed: "0", bin_location: "AB-123" },
37
- ]}
38
+ committed: "0", bin_location: "AB-123" }
39
+ ] }
38
40
 
39
41
  locations = record_class.new(client, json).locations
40
42
  assert_instance_of(Gecko::Record::Variant::VariantLocation, locations.first)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class Gecko::WebhookTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Minitest
2
4
  module Let
3
5
  def let(name, &block)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Shared tests for Gecko::Record Adapters
2
4
  # requires definition of several variables
3
5
  # - adapter
@@ -5,7 +7,8 @@
5
7
  # - record_class
6
8
 
7
9
  require 'json'
8
- module SharedAdapterExamples
10
+
11
+ module SharedAdapterExamples # rubocop:disable Metrics/ModuleLength
9
12
  def test_adapter_all
10
13
  VCR.use_cassette(plural_name) do
11
14
  collection = adapter.where(limit: 5)
@@ -49,29 +52,29 @@ module SharedAdapterExamples
49
52
 
50
53
  def test_has_record_for_id
51
54
  mock_record = Object.new
52
- adapter.instance_variable_set(:@identity_map, {12 => mock_record})
55
+ adapter.instance_variable_set(:@identity_map, { 12 => mock_record })
53
56
  assert adapter.has_record_for_id?(12)
54
57
  assert !adapter.has_record_for_id?(12345)
55
58
  end
56
59
 
57
60
  def test_fetch
58
- request_stub = stub_request(:get, /#{plural_name}\/\d+/)
59
- .to_return({
60
- headers: {"Content-Type" => "application/json"},
61
- body: JSON.dump({plural_name.singularize => {id: 12345}})
62
- })
61
+ request_stub = stub_request(:get, %r{#{plural_name}/\d+})
62
+ .to_return({
63
+ headers: { "Content-Type" => "application/json" },
64
+ body: JSON.dump({ plural_name.singularize => { id: 12345 } })
65
+ })
63
66
  record = adapter.fetch(12345)
64
67
  assert_equal(12345, record.id)
65
68
  assert_requested(request_stub)
66
69
  end
67
70
 
68
- def test_fetch_miss
69
- stub_request(:get, /#{plural_name}\/\d+/)
71
+ def test_fetch_miss # rubocop:disable Metrics/MethodLength
72
+ stub_request(:get, %r{#{plural_name}/\d+})
70
73
  .to_return({
71
74
  status: 404,
72
- headers: {"Content-Type" => "application/json"},
73
- body: JSON.dump({
74
- type: "Not Found",
75
+ headers: { "Content-Type" => "application/json" },
76
+ body: JSON.dump({
77
+ type: "Not Found",
75
78
  message: "Couldn't find #{plural_name.singularize} with id 12345"
76
79
  })
77
80
  })
@@ -105,9 +108,8 @@ module SharedAdapterExamples
105
108
  def test_saving_new_record
106
109
  record = adapter.build
107
110
  mock_api_request(record,
108
- [:post, plural_name],
109
- [200, {plural_name.singularize => {id: 123}}]
110
- )
111
+ [:post, plural_name],
112
+ [200, { plural_name.singularize => { id: 123 } }])
111
113
  adapter.save(record)
112
114
  assert_equal(record.id, 123)
113
115
  assert(record.valid?)
@@ -116,9 +118,8 @@ module SharedAdapterExamples
116
118
  def test_saving_new_invalid_record
117
119
  record = adapter.build
118
120
  mock_api_request(record,
119
- [:post, plural_name],
120
- [422, {"errors" => {title: ["can not be bounced"]}}]
121
- )
121
+ [:post, plural_name],
122
+ [422, { "errors" => { title: ["can not be bounced"] } }])
122
123
  adapter.save(record)
123
124
  assert_nil(record.id)
124
125
  assert(!record.valid?)
@@ -127,9 +128,8 @@ module SharedAdapterExamples
127
128
  def test_saving_existing_record
128
129
  record = existing_record
129
130
  mock_api_request(record,
130
- [:put, "#{plural_name}/#{record.id}"],
131
- [204, '']
132
- )
131
+ [:put, "#{plural_name}/#{record.id}"],
132
+ [204, ''])
133
133
  adapter.save(record)
134
134
  assert(record.valid?)
135
135
  end
@@ -137,23 +137,22 @@ module SharedAdapterExamples
137
137
  def test_saving_existing_invalid_record
138
138
  record = existing_record
139
139
  mock_api_request(record,
140
- [:put, "#{plural_name}/#{record.id}"],
141
- [422, {"errors" => {title: ["can not be bounced"]}}]
142
- )
140
+ [:put, "#{plural_name}/#{record.id}"],
141
+ [422, { "errors" => { title: ["can not be bounced"] } }])
143
142
  adapter.save(record)
144
143
  assert(!record.valid?)
145
144
  assert(record.errors[:title].any?)
146
145
  end
147
146
 
148
- def test_saving_record_with_idempotency_key
147
+ def test_saving_record_with_idempotency_key # rubocop:disable Metrics/MethodLength
149
148
  record = adapter.build
150
149
  mock_token = mock
151
- mock_response = mock(status: 200, parsed: {plural_name.singularize => {id: 123}})
150
+ mock_response = mock(status: 200, parsed: { plural_name.singularize => { id: 123 } }, error: nil)
152
151
  mock_token.expects(:request)
153
152
  .with(:post, plural_name, {
154
- body: record.as_json.to_json,
153
+ body: record.as_json.to_json,
155
154
  raise_errors: false,
156
- headers: {
155
+ headers: {
157
156
  'Content-Type' => 'application/json',
158
157
  'Idempotency-Key' => 'abcdefghijkl'
159
158
  }
@@ -163,11 +162,16 @@ module SharedAdapterExamples
163
162
  end
164
163
 
165
164
  private
165
+
166
166
  def mock_api_request(record, request, response)
167
167
  mock_token = mock
168
- mock_response = mock(status: response[0], parsed: response[1])
168
+ mock_response = mock(status: response[0], parsed: response[1], error: nil)
169
169
  mock_token.expects(:request)
170
- .with(request[0], request[1], body: record.as_json.to_json, raise_errors: false, headers: {'Content-Type' => 'application/json'})
170
+ .with(request[0], request[1], {
171
+ body: record.as_json.to_json,
172
+ raise_errors: false,
173
+ headers: { 'Content-Type' => 'application/json' }
174
+ })
171
175
  .returns(mock_response)
172
176
  adapter.client.access_token = mock_token
173
177
  end
@@ -177,6 +181,6 @@ private
177
181
  end
178
182
 
179
183
  def random_attribute
180
- @rattr ||= record_class.attribute_set.find { |att| att.type == Axiom::Types::String }.name
184
+ @random_attribute ||= record_class.attribute_set.find { |att| att.type == Axiom::Types::String }.name
181
185
  end
182
186
  end