gecko-ruby 0.9.1 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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/record/base'
2
4
 
3
5
  module Gecko
@@ -10,7 +12,6 @@ module Gecko
10
12
  end
11
13
 
12
14
  class PaymentTermAdapter < BaseAdapter
13
-
14
15
  end
15
16
  end
16
17
  end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko/record/base'
2
4
 
3
5
  module Gecko
4
6
  module Record
5
7
  class Product < Base
6
8
  has_many :variants
9
+ has_many :images
10
+
7
11
  attribute :name, String
8
12
  attribute :description, String
9
13
  attribute :product_type, String
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko/record/base'
2
4
 
3
5
  module Gecko
@@ -38,7 +40,6 @@ module Gecko
38
40
  end
39
41
 
40
42
  class PurchaseOrderAdapter < BaseAdapter
41
-
42
43
  end
43
44
  end
44
45
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko/record/base'
2
4
 
3
5
  module Gecko
@@ -23,7 +25,6 @@ module Gecko
23
25
  end
24
26
 
25
27
  class PurchaseOrderLineItemAdapter < BaseAdapter
26
-
27
28
  end
28
29
  end
29
30
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko/record/base'
2
4
 
3
5
  module Gecko
@@ -13,7 +15,6 @@ module Gecko
13
15
  end
14
16
 
15
17
  class TaxTypeAdapter < BaseAdapter
16
-
17
18
  end
18
19
  end
19
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko/record/base'
2
4
 
3
5
  module Gecko
@@ -32,7 +34,7 @@ module Gecko
32
34
  #
33
35
  # @api public
34
36
  def current
35
- if self.has_record_for_id?(:current)
37
+ if has_record_for_id?(:current)
36
38
  record_for_id(:current)
37
39
  else
38
40
  @identity_map[:current] = find(:current)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko/record/base'
2
4
 
3
5
  module Gecko
@@ -13,7 +15,7 @@ module Gecko
13
15
  attribute :committed, BigDecimal
14
16
  attribute :stock_on_hand, BigDecimal
15
17
 
16
- alias_method :committed_stock, :committed
18
+ alias committed_stock committed
17
19
  end
18
20
 
19
21
  class VariantPrice
@@ -84,12 +86,12 @@ module Gecko
84
86
  #
85
87
  # @api public
86
88
  def display_name
87
- if name.nil? || !name.include?(product_name)
88
- parts = [sku, product_name, name]
89
- else
90
- parts = [sku, name]
91
- end
92
- parts.select { |part| part && part.length }.join(' - ')
89
+ parts = if name.nil? || !name.include?(product_name)
90
+ [sku, product_name, name]
91
+ else
92
+ [sku, name]
93
+ end
94
+ parts.select { |part| part&.length }.join(' - ')
93
95
  end
94
96
 
95
97
  # attribute :is_online
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko/record/base'
2
4
 
3
5
  module Gecko
@@ -27,7 +29,7 @@ module Gecko
27
29
  stock_adjustment.create
28
30
  stock_transfer.create
29
31
  variant.create
30
- ]
32
+ ].freeze
31
33
 
32
34
  attribute :address, String
33
35
  attribute :event, String
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gecko
2
- VERSION = '0.9.1'
4
+ VERSION = '0.12.1'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class ClientTest < Minitest::Test
@@ -13,10 +15,10 @@ class ClientTest < Minitest::Test
13
15
  def test_custom_user_agent
14
16
  client = Gecko::Client.new("ABC", "DEF")
15
17
  agent = client.oauth_client.connection.headers["User-Agent"]
16
- assert_match(%r|Gecko/#{Gecko::VERSION} OAuth2/\d\.\d\.\d Faraday/\d\.\d+\.\d Ruby/\d\.\d\.\d|, agent)
18
+ assert_match(%r{Gecko/#{Gecko::VERSION} OAuth2/\d\.\d\.\d Faraday/\d\.\d+\.\d Ruby/\d\.\d\.\d}, agent)
17
19
  end
18
20
 
19
- def test_allows_test_URLs
21
+ def test_allows_test_urls
20
22
  client = Gecko::Client.new("ABC", "DEF", site: "localhost:3000")
21
23
  assert_equal "localhost:3000", client.oauth_client.site
22
24
  end
@@ -53,7 +53,7 @@ http_interactions:
53
53
  - chunked
54
54
  body:
55
55
  encoding: UTF-8
56
- string: '{"images":[{"id":204,"variant_id":1035,"uploader_id":26,"name":"p17e54uam11hmn11g019qg16gj1lvh4.jpeg","position":1,"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/204","file_name":"Dead_Cool.jpeg","versions":["thumbnail"],"image_processing":null},{"id":5140,"variant_id":1995,"uploader_id":26,"name":"p17hgbcgn413jf2pi9h415jjjc74.jpeg","position":1,"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/5140","file_name":"Broken_heart_copy.jpeg","versions":["thumbnail"],"image_processing":null},{"id":59274,"variant_id":92694,"uploader_id":"Shopify","name":null,"position":1,"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/59274","file_name":"dellMON.jpg","versions":["thumbnail"],"image_processing":null},{"id":206,"variant_id":1034,"uploader_id":26,"name":"p17e54urld1ffth831j3ct6a1gl1e.jpeg","position":1,"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/206","file_name":"Dead_Cool.jpeg","versions":["thumbnail"],"image_processing":null},{"id":251,"variant_id":5252,"uploader_id":213,"name":"p17eh9kpij1u771kg1rdc103vn5i.jpg","position":1,"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/251","file_name":"Chance_PerfectBoatneck_WhiteW.Navy.jpg","versions":["thumbnail"],"image_processing":null}]}'
56
+ string: '{"images":[{"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/204","created_at":"2013-12-19T03:55:45.973Z","file_name":"Dead_Cool.jpeg","id":204,"image_processing":false,"name":"p17e54uam11hmn11g019qg16gj1lvh4.jpeg","position":1,"product_id":27,"updated_at":"2013-12-19T03:55:45.973Z","uploader_id":26,"variant_ids":[1035],"versions":["thumbnail"]},{"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/5140","created_at":"2013-12-19T03:55:45.973Z","file_name":"Broken_heart_copy.jpeg","id":5140,"image_processing":false,"name":"p17hgbcgn413jf2pi9h415jjjc74.jpeg","position":1,"product_id":27,"updated_at":"2013-12-19T03:55:45.973Z","uploader_id":26,"variant_id":1995,"variant_ids":[1995],"versions":["thumbnail"]},{"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/59274","created_at":"2013-12-19T03:55:45.973Z","file_name":"dellMON.jpg","id":59274,"image_processing":false,"name":null,"position":1,"product_id":28,"updated_at":"2013-12-19T03:55:45.973Z","uploader_id":"Shopify","variant_id":92694,"variant_ids":[92694],"versions":["thumbnail"]},{"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/206","created_at":"2013-12-19T03:55:45.973Z","file_name":"Dead_Cool.jpeg","id":206,"image_processing":false,"name":"p17e54urld1ffth831j3ct6a1gl1e.jpeg","position":1,"product_id":1034,"updated_at":"2013-12-19T03:55:45.973Z","uploader_id":26,"variant_id":1034,"variant_ids":[1034],"versions":["thumbnail"]},{"base_path":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/251","created_at":"2013-12-19T03:55:45.973Z","file_name":"Chance_PerfectBoatneck_WhiteW.Navy.jpg","id":251,"image_processing":false,"name":"p17eh9kpij1u771kg1rdc103vn5i.jpg","position":1,"product_id":5252,"updated_at":"2013-12-19T03:55:45.973Z","uploader_id":213,"variant_id":5252,"variant_ids":[5252],"versions":["thumbnail"]}]}'
57
57
  http_version:
58
58
  recorded_at: Wed, 12 Mar 2014 11:39:39 GMT
59
59
  recorded_with: VCR 2.8.0
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.lvh.me:3000/payment_methods?limit=5
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Gecko/0.12.0 OAuth2/1.4.1 Faraday/0.15.4 Ruby/2.5.7
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Bearer <__ACCESS_TOKEN__>
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ X-Download-Options:
32
+ - noopen
33
+ X-Permitted-Cross-Domain-Policies:
34
+ - none
35
+ Referrer-Policy:
36
+ - strict-origin-when-cross-origin
37
+ X-Rate-Limit-Limit:
38
+ - '300'
39
+ X-Rate-Limit-Remaining:
40
+ - '299'
41
+ X-Rate-Limit-Reset:
42
+ - '1594871400'
43
+ Cache-Control:
44
+ - no-cache, no-store
45
+ X-Pagination:
46
+ - '{"total_records":11,"total_pages":3,"first_page":true,"last_page":false,"out_of_bounds":false,"offset":0}'
47
+ Link:
48
+ - <http://api.lvh.me:3000/ajax/payment_methods?limit=5&page=2>; rel="next",
49
+ <http://api.lvh.me:3000/ajax/payment_methods?limit=5&page=3>; rel="last"
50
+ Content-Type:
51
+ - application/json; charset=utf-8
52
+ Etag:
53
+ - W/"7462907dae56049f84e55abca4a15c5e"
54
+ X-Request-Id:
55
+ - ac553ee8-d518-404c-bd7b-215a168d164c
56
+ X-Runtime:
57
+ - '0.108324'
58
+ Connection:
59
+ - close
60
+ Server:
61
+ - thin
62
+ body:
63
+ encoding: UTF-8
64
+ string: '{"payment_methods":[{"id":32,"created_at":"2020-07-16T03:46:03.946Z","updated_at":"2020-07-16T03:46:03.946Z","name":"PayNow","is_default":false},{"id":31,"created_at":"2020-07-16T03:45:50.096Z","updated_at":"2020-07-16T03:45:50.096Z","name":"Singtel
65
+ Dash","is_default":false},{"id":30,"created_at":"2020-07-16T03:45:36.276Z","updated_at":"2020-07-16T03:45:36.276Z","name":"eNets","is_default":false},{"id":29,"created_at":"2020-07-16T03:45:21.473Z","updated_at":"2020-07-16T03:45:21.473Z","name":"Voucher","is_default":false},{"id":28,"created_at":"2020-07-16T03:45:15.160Z","updated_at":"2020-07-16T03:45:15.160Z","name":"Credit
66
+ Note","is_default":false}]}'
67
+ http_version: null
68
+ recorded_at: Thu, 16 Jul 2020 03:48:15 GMT
69
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.lvh.me:3000/payment_methods?limit=0
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Gecko/0.12.0 OAuth2/1.4.1 Faraday/0.15.4 Ruby/2.5.7
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Bearer <__ACCESS_TOKEN__>
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ X-Download-Options:
32
+ - noopen
33
+ X-Permitted-Cross-Domain-Policies:
34
+ - none
35
+ Referrer-Policy:
36
+ - strict-origin-when-cross-origin
37
+ X-Rate-Limit-Limit:
38
+ - '300'
39
+ X-Rate-Limit-Remaining:
40
+ - '299'
41
+ X-Rate-Limit-Reset:
42
+ - '1594871400'
43
+ Cache-Control:
44
+ - no-cache, no-store
45
+ X-Pagination:
46
+ - '{"total_records":11,"total_pages":1,"first_page":true,"last_page":true,"out_of_bounds":false,"offset":0}'
47
+ Link:
48
+ - <http://api.lvh.me:3000/ajax/payment_methods?limit=0&page=1>; rel="last"
49
+ Content-Type:
50
+ - application/json; charset=utf-8
51
+ Etag:
52
+ - W/"98c458ef2a733afd7d9fbf88e776e5c2"
53
+ X-Request-Id:
54
+ - 89f1b27c-35d7-4b3c-a356-d87c0a1d4cc1
55
+ X-Runtime:
56
+ - '0.160860'
57
+ Connection:
58
+ - close
59
+ Server:
60
+ - thin
61
+ body:
62
+ encoding: UTF-8
63
+ string: '{"payment_methods":[]}'
64
+ http_version: null
65
+ recorded_at: Thu, 16 Jul 2020 03:48:14 GMT
66
+ recorded_with: VCR 5.1.0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class GeckoTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko'
2
4
 
3
5
  class Gecko::Helpers::AssociationHelperTest < Minitest::Test
@@ -25,31 +27,31 @@ class Gecko::Helpers::AssociationHelperTest < Minitest::Test
25
27
  end
26
28
 
27
29
  def test_has_many
28
- record = @klass.new(@client, {order_ids: [123]})
30
+ record = @klass.new(@client, { order_ids: [123] })
29
31
  @client.Order.expects(:find_many).with([123])
30
32
  record.orders
31
33
  end
32
34
 
33
35
  def test_has_many_without_ids
34
- record = @klass.new(@client, {order_ids: []})
36
+ record = @klass.new(@client, { order_ids: [] })
35
37
  @client.Order.expects(:find_many).never
36
38
  assert_empty(record.orders)
37
39
  end
38
40
 
39
41
  def test_belongs_to
40
- record = @klass.new(@client, {order_id: 4})
42
+ record = @klass.new(@client, { order_id: 4 })
41
43
  @client.Order.expects(:find).with(4)
42
44
  record.order
43
45
  end
44
46
 
45
47
  def test_belongs_to_without_id
46
- record = @klass.new(@client, {order_id: nil})
48
+ record = @klass.new(@client, { order_id: nil })
47
49
  @client.Order.expects(:find).never
48
50
  assert_nil record.order
49
51
  end
50
52
 
51
53
  def test_belongs_to_with_class
52
- record = @klass.new(@client, {small_order_id: 56})
54
+ record = @klass.new(@client, { small_order_id: 56 })
53
55
  @client.Order.expects(:find).with(56)
54
56
  record.small_order
55
57
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko'
2
4
 
3
5
  class Gecko::Helpers::InspectionHelperTest < Minitest::Test
@@ -12,9 +14,9 @@ class Gecko::Helpers::InspectionHelperTest < Minitest::Test
12
14
 
13
15
  def test_inspect_times
14
16
  record = @klass.new(@client, {
15
- published_date: Date.new(2014),
16
- published_time: Time.new(2014),
17
- published_datetime: DateTime.new(2014),
17
+ published_date: Date.new(2014),
18
+ published_time: Time.new(2014),
19
+ published_datetime: DateTime.new(2014)
18
20
  })
19
21
  assert_equal("2014-01-01 00:00:00", get_timestamp(record.inspect, :published_time))
20
22
  assert_equal("2014-01-01 00:00:00", get_timestamp(record.inspect, :published_datetime))
@@ -22,6 +24,6 @@ class Gecko::Helpers::InspectionHelperTest < Minitest::Test
22
24
  end
23
25
 
24
26
  def get_timestamp(inspect_string, attribute)
25
- inspect_string.match(%r|#{attribute}: \"(?<timestamp>[\d:\s-]+)\"|)[:timestamp]
27
+ inspect_string.match(/#{attribute}: \"(?<timestamp>[\d:\s-]+)\"/)[:timestamp]
26
28
  end
27
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko'
2
4
  require 'test_helper'
3
5
 
@@ -27,14 +29,14 @@ class Gecko::Helpers::SerializationHelperTest < Minitest::Test
27
29
 
28
30
  let(:record) do
29
31
  Widget.new(@client, {
30
- name: "Gecko",
31
- secret: "Iguana",
32
+ name: "Gecko",
33
+ secret: "Iguana",
32
34
  initial_stock: 10.0,
33
- update_stock: 10.0,
34
- score: 1.234,
35
- started_at: DateTime.now,
36
- started_on: Date.today,
37
- wodgets: [Wodget.new(@client, name: "Hi")]
35
+ update_stock: 10.0,
36
+ score: 1.234,
37
+ started_at: DateTime.now,
38
+ started_on: Date.today,
39
+ wodgets: [Wodget.new(@client, name: "Hi")]
38
40
  })
39
41
  end
40
42
 
@@ -48,7 +50,7 @@ class Gecko::Helpers::SerializationHelperTest < Minitest::Test
48
50
  end
49
51
 
50
52
  def test_as_json
51
- assert_equal({widget: record.serializable_hash}, record.as_json)
53
+ assert_equal({ widget: record.serializable_hash }, record.as_json)
52
54
  end
53
55
 
54
56
  def test_writeable_on_create
@@ -72,7 +74,7 @@ class Gecko::Helpers::SerializationHelperTest < Minitest::Test
72
74
  end
73
75
 
74
76
  def test_serializes_arrays
75
- assert_equal([{name: "Hi"}], record.serializable_hash[:wodgets])
77
+ assert_equal([{ name: "Hi" }], record.serializable_hash[:wodgets])
76
78
  end
77
79
 
78
80
  def test_root_key
@@ -100,12 +102,12 @@ private
100
102
 
101
103
  def serialized_record
102
104
  {
103
- name: "Gecko",
105
+ name: "Gecko",
104
106
  initial_stock: "10.0",
105
- score: "1.234",
106
- started_on: Date.today,
107
- started_at: DateTime.now,
108
- wodgets: [{name: "Hi"}]
107
+ score: "1.234",
108
+ started_on: Date.today,
109
+ started_at: DateTime.now,
110
+ wodgets: [{ name: "Hi" }]
109
111
  }
110
112
  end
111
113
  end