Browse Source

Fix rubocop conflicts

Paulo Margarido 4 years ago
parent
commit
a6644c283d

+ 0 - 10
.rubocop.yml

@@ -2,16 +2,6 @@ inherit_from:
   - https://shopify.github.io/ruby-style-guide/rubocop.yml
   - .rubocop_todo.yml
 
-# The entries below are not included automatically in the TODO file, they should be fixed and removed as well
-Layout/SpaceInsideHashLiteralBraces:
-  Enabled: false
-Layout/SpaceBeforeBlockBraces:
-  Enabled: false
-Layout/SpaceAroundEqualsInParameterDefault:
-  Enabled: false
-Style/RaiseArgs:
-  Enabled: false
-
 AllCops:
   TargetRubyVersion: 2.4
 

+ 9 - 50
.rubocop_todo.yml

@@ -1,6 +1,6 @@
 # This configuration was generated by
 # `rubocop --auto-gen-config`
-# on 2020-10-05 18:45:45 UTC using RuboCop version 0.92.0.
+# on 2020-10-05 19:12:07 UTC using RuboCop version 0.92.0.
 # The point is for the user to remove these configuration records
 # one by one as the offenses are removed from the code base.
 # Note that changes in the inspected code, or installation of new
@@ -106,13 +106,6 @@ Layout/IndentationWidth:
   Exclude:
     - 'test/fulfillment_service_test.rb'
 
-# Offense count: 83
-# Cop supports --auto-correct.
-# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
-# URISchemes: http, https
-Layout/LineLength:
-  Max: 320
-
 # Offense count: 2
 # Cop supports --auto-correct.
 # Configuration parameters: EnforcedStyle.
@@ -145,14 +138,6 @@ Layout/SpaceAfterComma:
     - 'test/recurring_application_charge_test.rb'
     - 'test/session_test.rb'
 
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: space, no_space
-Layout/SpaceAroundEqualsInParameterDefault:
-  Exclude:
-    - 'lib/shopify_api/limits.rb'
-
 # Offense count: 9
 # Cop supports --auto-correct.
 # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
@@ -165,14 +150,6 @@ Layout/SpaceAroundOperators:
     - 'test/shop_test.rb'
     - 'test/test_helper.rb'
 
-# Offense count: 7
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyleForEmptyBraces.
-# SupportedStyles: space, no_space
-# SupportedStylesForEmptyBraces: space, no_space
-Layout/SpaceBeforeBlockBraces:
-  EnforcedStyle: space
-
 # Offense count: 4
 # Cop supports --auto-correct.
 Layout/SpaceBeforeComma:
@@ -200,14 +177,6 @@ Layout/SpaceInsideBlockBraces:
     - 'test/location_test.rb'
     - 'test/shop_test.rb'
 
-# Offense count: 93
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyleForEmptyBraces.
-# SupportedStyles: space, no_space, compact
-# SupportedStylesForEmptyBraces: space, no_space
-Layout/SpaceInsideHashLiteralBraces:
-  EnforcedStyle: space
-
 # Offense count: 1
 # Cop supports --auto-correct.
 # Configuration parameters: EnforcedStyle.
@@ -227,14 +196,12 @@ Layout/TrailingEmptyLines:
     - 'lib/shopify_api/resources/cart.rb'
     - 'test/cart_test.rb'
 
-# Offense count: 8
+# Offense count: 5
 # Cop supports --auto-correct.
 # Configuration parameters: AllowInHeredoc.
 Layout/TrailingWhitespace:
   Exclude:
-    - 'lib/shopify_api/resources/product.rb'
     - 'lib/shopify_api/resources/variant.rb'
-    - 'test/product_test.rb'
     - 'test/storefront_access_token_test.rb'
     - 'test/user_test.rb'
 
@@ -304,14 +271,6 @@ Style/PreferredHashMethods:
   Exclude:
     - 'test/test_helper.rb'
 
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: compact, exploded
-Style/RaiseArgs:
-  Exclude:
-    - 'lib/shopify_api/pagination_link_headers.rb'
-
 # Offense count: 1
 # Cop supports --auto-correct.
 Style/RedundantException:
@@ -324,13 +283,6 @@ Style/RedundantPercentQ:
   Exclude:
     - 'shopify_api.gemspec'
 
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: AllowMultipleReturnValues.
-Style/RedundantReturn:
-  Exclude:
-    - 'lib/shopify_api/resources/base.rb'
-
 # Offense count: 11
 # Cop supports --auto-correct.
 Style/RedundantSelf:
@@ -415,3 +367,10 @@ Style/TrailingCommaInHashLiteral:
 Style/TrivialAccessors:
   Exclude:
     - 'lib/shopify_api/graphql.rb'
+
+# Offense count: 83
+# Cop supports --auto-correct.
+# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
+# URISchemes: http, https
+Layout/LineLength:
+  Max: 320

+ 1 - 1
lib/shopify_api/events.rb

@@ -1,7 +1,7 @@
 module ShopifyAPI
   module Events
     def events
-      Event.find(:all, :params => {:resource => self.class.collection_name, :resource_id => id})
+      Event.find(:all, :params => { :resource => self.class.collection_name, :resource_id => id })
     end
   end
 end

+ 2 - 2
lib/shopify_api/limits.rb

@@ -38,7 +38,7 @@ module ShopifyAPI
       # @param {Symbol} scope [:shop]
       # @return {Integer}
       #
-      def credit_limit(scope=:shop)
+      def credit_limit(scope = :shop)
         api_credit_limit_param(scope).pop.to_i - 1
       end
       alias_method :call_limit, :credit_limit
@@ -48,7 +48,7 @@ module ShopifyAPI
       # @param {Symbol} scope [:shop]
       # @return {Integer}
       #
-      def credit_used(scope=:shop)
+      def credit_used(scope = :shop)
         api_credit_limit_param(scope).shift.to_i
       end
       alias_method :call_count, :credit_used

+ 1 - 1
lib/shopify_api/pagination_link_headers.rb

@@ -18,7 +18,7 @@ module ShopifyAPI
       links = link_header.split(',')
       links.map do |link|
         parts = link.split('; ')
-        raise ShopifyAPI::InvalidPaginationLinksError.new("Invalid link header: url and rel expected") unless parts.length == 2
+        raise ShopifyAPI::InvalidPaginationLinksError, "Invalid link header: url and rel expected" unless parts.length == 2
 
         url = parts[0][/<(.*)>/, 1]
         rel = parts[1][/rel="(.*)"/, 1]&.to_sym

+ 1 - 1
lib/shopify_api/resources/access_scope.rb

@@ -2,7 +2,7 @@
 module ShopifyAPI
   class AccessScope < Base
     class << self
-      def prefix(_options={})
+      def prefix(_options = {})
         '/admin/oauth/'
       end
     end

+ 1 - 1
lib/shopify_api/resources/article.rb

@@ -14,7 +14,7 @@ module ShopifyAPI
       get(:authors, options)
     end
 
-    def self.tags(options={})
+    def self.tags(options = {})
       get(:tags, options)
     end
   end

+ 1 - 1
lib/shopify_api/resources/asset.rb

@@ -75,7 +75,7 @@ module ShopifyAPI
     end
 
     def destroy
-      connection.delete(element_path(prefix_options.merge(:asset => {:key => key})), self.class.headers)
+      connection.delete(element_path(prefix_options.merge(:asset => { :key => key })), self.class.headers)
     end
 
     def new?

+ 2 - 2
lib/shopify_api/resources/base.rb

@@ -15,7 +15,7 @@ module ShopifyAPI
 
     def encode(options = {})
       same = dup
-      same.attributes = {self.class.element_name => same.attributes} if self.class.format.extension == 'json'
+      same.attributes = { self.class.element_name => same.attributes } if self.class.format.extension == 'json'
 
       same.send("to_#{self.class.format.extension}", options)
     end
@@ -43,7 +43,7 @@ module ShopifyAPI
       end
 
       def activate_session(session)
-        raise InvalidSessionError.new("Session cannot be nil") if session.nil?
+        raise InvalidSessionError, "Session cannot be nil" if session.nil?
         self.site = session.site
         self.headers.merge!('X-Shopify-Access-Token' => session.token)
         self.api_version = session.api_version

+ 2 - 2
lib/shopify_api/resources/custom_collection.rb

@@ -4,7 +4,7 @@ module ShopifyAPI
     include Metafields
 
     def products
-      Product.find(:all, :params => {:collection_id => self.id})
+      Product.find(:all, :params => { :collection_id => self.id })
     end
 
     def add_product(product)
@@ -12,7 +12,7 @@ module ShopifyAPI
     end
 
     def remove_product(product)
-      collect = Collect.find(:first, :params => {:collection_id => self.id, :product_id => product.id})
+      collect = Collect.find(:first, :params => { :collection_id => self.id, :product_id => product.id })
       collect.destroy if collect
     end
   end

+ 1 - 1
lib/shopify_api/resources/customer.rb

@@ -3,7 +3,7 @@ module ShopifyAPI
     include Metafields
 
     def orders
-      Order.find(:all, params: {customer_id: self.id})
+      Order.find(:all, params: { customer_id: self.id })
     end
 
     def self.search(params)

+ 1 - 1
lib/shopify_api/resources/customer_saved_search.rb

@@ -5,7 +5,7 @@ module ShopifyAPI
     early_july_pagination_release!
 
     def customers(params = {})
-      Customer.search(params.merge({:customer_saved_search_id => self.id}))
+      Customer.search(params.merge({ :customer_saved_search_id => self.id }))
     end
   end
 end

+ 4 - 4
lib/shopify_api/resources/product.rb

@@ -15,7 +15,7 @@ module ShopifyAPI
         format % prices.min
       end
     end
-    
+
     def total_inventory=(new_value)
       raise_deprecated_inventory_call('total_inventory') unless allow_inventory_params?
       super
@@ -26,11 +26,11 @@ module ShopifyAPI
     end
 
     def collections
-      CustomCollection.find(:all, :params => {:product_id => self.id})
+      CustomCollection.find(:all, :params => { :product_id => self.id })
     end
 
     def smart_collections
-      SmartCollection.find(:all, :params => {:product_id => self.id})
+      SmartCollection.find(:all, :params => { :product_id => self.id })
     end
 
     def add_to_collection(collection)
@@ -40,7 +40,7 @@ module ShopifyAPI
     def remove_from_collection(collection)
       collection.remove_product(self)
     end
-    
+
     private
 
     def raise_deprecated_inventory_call(parameter)

+ 1 - 1
lib/shopify_api/resources/resource_feedback.rb

@@ -13,7 +13,7 @@ module ShopifyAPI
 
     def save
       return super unless persisted?
-      raise ExistingFeedbackSaved.new(EXISTING_FEEDBACK_SAVED_ERROR_MESSAGE)
+      raise ExistingFeedbackSaved, EXISTING_FEEDBACK_SAVED_ERROR_MESSAGE
     end
   end
 end

+ 1 - 1
lib/shopify_api/resources/smart_collection.rb

@@ -7,7 +7,7 @@ module ShopifyAPI
       Product.find(:all, params: { collection_id: id })
     end
 
-    def order(options={})
+    def order(options = {})
       load_attributes_from_response(put(:order, options, only_id))
     end
 

+ 1 - 1
lib/shopify_api/session.rb

@@ -78,7 +78,7 @@ module ShopifyAPI
 
       def encoded_params_for_signature(params)
         params = params.except(:signature, :hmac, :action, :controller)
-        params.map{|k,v| "#{URI.escape(k.to_s, '&=%')}=#{URI.escape(v.to_s, '&%')}"}.sort.join('&')
+        params.map { |k,v| "#{URI.escape(k.to_s, '&=%')}=#{URI.escape(v.to_s, '&%')}" }.sort.join('&')
       end
 
       def extract_current_session

+ 2 - 2
test/active_resource/json_errors_test.rb

@@ -5,13 +5,13 @@ module ActiveResource
 
     def test_parsing_of_error_json_hash
       @model = ShopifyAPI::Order.new
-      @model.errors.from_json({errors: {name: ['missing']}}.to_json)
+      @model.errors.from_json({ errors: { name: ['missing'] } }.to_json)
       assert_equal ['missing'], @model.errors[:name]
     end
 
     def test_parsing_of_error_json_plain_string
       @model = ShopifyAPI::Order.new
-      @model.errors.from_json({errors: 'some generic error'}.to_json)
+      @model.errors.from_json({ errors: 'some generic error' }.to_json)
       assert_equal ['some generic error'], @model.errors[:base]
       assert_equal 'some generic error', @model.errors.full_messages.to_sentence
     end

+ 2 - 2
test/article_test.rb

@@ -25,14 +25,14 @@ class ArticleTest < Test::Unit::TestCase
 
   def test_get_articles_namespaced
     fake "blogs/1008414260/articles", :method => :get, :body => load_fixture('articles')
-    articles = ShopifyAPI::Article.find(:all, :params => {:blog_id => 1008414260})
+    articles = ShopifyAPI::Article.find(:all, :params => { :blog_id => 1008414260 })
     assert_equal 3, articles.length
     assert_equal 1008414260, articles.first.blog_id
   end
 
   def test_get_article_namespaced
     fake "blogs/1008414260/articles/6242736", :method => :get, :body => load_fixture('article')
-    article = ShopifyAPI::Article.find(6242736, :params => {:blog_id => 1008414260})
+    article = ShopifyAPI::Article.find(6242736, :params => { :blog_id => 1008414260 })
     assert_equal "First Post", article.title
     assert_equal 1008414260, article.blog_id
   end

+ 2 - 2
test/asset_test.rb

@@ -3,12 +3,12 @@ require 'test_helper'
 class AssetTest < Test::Unit::TestCase
   def test_get_assetss
     fake "themes/1/assets", :method => :get, :body => load_fixture('assets')
-    ShopifyAPI::Asset.find(:all, :params => {:theme_id => 1})
+    ShopifyAPI::Asset.find(:all, :params => { :theme_id => 1 })
   end
 
   def test_get_asset_namespaced
     fake "themes/1/assets.json?asset%5Bkey%5D=templates%2Findex.liquid&theme_id=1", :extension=> false, :method => :get, :body => load_fixture('asset')
-    ShopifyAPI::Asset.find('templates/index.liquid', :params => {:theme_id => 1})
+    ShopifyAPI::Asset.find('templates/index.liquid', :params => { :theme_id => 1 })
   end
 
   def test_get_asset

+ 1 - 1
test/discount_code_test.rb

@@ -5,7 +5,7 @@ class DiscountCodeTest < Test::Unit::TestCase
     super
     fake 'price_rules/102586120/discount_codes/1002091923', body: load_fixture('discount_code')
 
-    @discount_code = ShopifyAPI::DiscountCode.find(1002091923, params: {price_rule_id: 102586120})
+    @discount_code = ShopifyAPI::DiscountCode.find(1002091923, params: { price_rule_id: 102586120 })
   end
 
   def test_get_discount_code

+ 1 - 1
test/draft_order_test.rb

@@ -121,7 +121,7 @@ class DraftOrderTest < Test::Unit::TestCase
     metafields = @draft_order.metafields limit: 2
 
     assert_equal 2, metafields.length
-    assert metafields.all?{ |m| m.is_a? ShopifyAPI::Metafield }
+    assert metafields.all? { |m| m.is_a? ShopifyAPI::Metafield }
   end
 
   def test_complete_draft_order_with_no_params

+ 4 - 4
test/fulfillment_test.rb

@@ -12,7 +12,7 @@ class FulFillmentTest < Test::Unit::TestCase
   context "Fulfillment" do
     context "#complete" do
       should "be able to complete fulfillment" do
-        fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
+        fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => { :order_id => 450789469 })
 
         success = ActiveSupport::JSON.decode(load_fixture('fulfillment'))
         success['fulfillment']['status'] = 'success'
@@ -26,7 +26,7 @@ class FulFillmentTest < Test::Unit::TestCase
 
     context "#cancel" do
       should "be able to cancel fulfillment" do
-        fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
+        fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => { :order_id => 450789469 })
 
         cancelled = ActiveSupport::JSON.decode(load_fixture('fulfillment'))
         cancelled['fulfillment']['status'] = 'cancelled'
@@ -40,7 +40,7 @@ class FulFillmentTest < Test::Unit::TestCase
 
     context "#open" do
       should "be able to open a fulfillment" do
-        fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
+        fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => { :order_id => 450789469 })
 
         open_fulfillment = ActiveSupport::JSON.decode(load_fixture('fulfillment'))
         open_fulfillment['fulfillment']['status'] = 'open'
@@ -54,7 +54,7 @@ class FulFillmentTest < Test::Unit::TestCase
 
     context "#find" do
       should "be able to find fulfillment" do
-        fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
+        fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => { :order_id => 450789469 })
         assert_equal 255858046, fulfillment.id
         assert_equal 450789469, fulfillment.order_id
       end

+ 3 - 3
test/image_test.rb

@@ -14,20 +14,20 @@ class ImageTest < Test::Unit::TestCase
 
   def test_get_images
     fake "products/632910392/images", :method => :get, :body => load_fixture('images')
-    image = ShopifyAPI::Image.find(:all, :params => {:product_id => 632910392})
+    image = ShopifyAPI::Image.find(:all, :params => { :product_id => 632910392 })
     assert_equal 2, image.size
   end
 
   def test_get_image
     fake "products/632910392/images/850703190", :method => :get, :body => load_fixture('image')
-    image = ShopifyAPI::Image.find(850703190, :params => {:product_id => 632910392})
+    image = ShopifyAPI::Image.find(850703190, :params => { :product_id => 632910392 })
     assert_equal 850703190, image.id
   end
 
   def test_delete_image
     fake "products/632910392/images/850703190", :method => :get, :body => load_fixture('image')
     fake "products/632910392/images/850703190", :method => :delete, :body => "destroyed"
-    image = ShopifyAPI::Image.find(850703190, :params => {:product_id => 632910392})
+    image = ShopifyAPI::Image.find(850703190, :params => { :product_id => 632910392 })
     assert image.destroy
   end
 

+ 1 - 1
test/metafield_test.rb

@@ -13,7 +13,7 @@ class MetafieldTest < Test::Unit::TestCase
 
   def test_get_metafield_of_a_blog
     fake "blogs/1008414260/metafields/721389482", :method => :get, :body => load_fixture('metafield')
-    metafield = ShopifyAPI::Metafield.find(721389482, :params => {:resource => "blogs", :resource_id => 1008414260})
+    metafield = ShopifyAPI::Metafield.find(721389482, :params => { :resource => "blogs", :resource_id => 1008414260 })
     assert_equal 1008414260, metafield.prefix_options[:resource_id]
   end
 

+ 4 - 4
test/order_risk_test.rb

@@ -18,20 +18,20 @@ class OrderRiskTest < Test::Unit::TestCase
 
   def test_get_order_risks
     fake "orders/450789469/risks", :method => :get, :body => load_fixture('order_risks')
-    v = ShopifyAPI::OrderRisk.find(:all, :params => {:order_id => 450789469})
+    v = ShopifyAPI::OrderRisk.find(:all, :params => { :order_id => 450789469 })
     assert_equal 2, v.size
   end
 
   def test_get_order_risk
     fake "orders/450789469/risks/284138680", :method => :get, :body => load_fixture('order_risk')
-    v = ShopifyAPI::OrderRisk.find(284138680, :params => {:order_id => 450789469})
+    v = ShopifyAPI::OrderRisk.find(284138680, :params => { :order_id => 450789469 })
     assert_equal 284138680, v.id
   end
 
   def test_delete_order_risk
     fake "orders/450789469/risks/284138680", :method => :get, :body => load_fixture('order_risk')
     fake "orders/450789469/risks/284138680", :method => :delete, :body => "destroyed"
-    v = ShopifyAPI::OrderRisk.find(284138680, :params => {:order_id => 450789469})
+    v = ShopifyAPI::OrderRisk.find(284138680, :params => { :order_id => 450789469 })
     assert v.destroy
   end
 
@@ -39,7 +39,7 @@ class OrderRiskTest < Test::Unit::TestCase
     fake "orders/450789469/risks/284138680", :method => :get, :body => load_fixture('order_risk')
     fake "orders/450789469/risks/284138680", :method => :put, :body => load_fixture('order_risk')
 
-    v = ShopifyAPI::OrderRisk.find(284138680, :params => {:order_id => 450789469})
+    v = ShopifyAPI::OrderRisk.find(284138680, :params => { :order_id => 450789469 })
     v.position = 3
     v.save
   end

+ 4 - 4
test/order_test.rb

@@ -6,14 +6,14 @@ class OrderTest < Test::Unit::TestCase
 
   test "create should create order" do
     fake 'orders', :method => :post, :status => 201, :body => load_fixture('order')
-    order = ShopifyAPI::Order.create(line_items: [{quantity:1, variant_id:39072856}], financial_status:"authorized")
+    order = ShopifyAPI::Order.create(line_items: [{ quantity:1, variant_id:39072856 }], financial_status:"authorized")
     assert_equal 39072856, order.line_items.first.variant_id
   end
 
   test "create should create an order with custom properties" do
-    props = [{ :"By default may label with \"Roasted for " => { :"Your First Name" => { :"\". If you want something specific on the label, enter it here:" => "" }}}]
+    props = [{ :"By default may label with \"Roasted for " => { :"Your First Name" => { :"\". If you want something specific on the label, enter it here:" => "" } } }]
     fake 'orders', :method => :post, :status => 201, :body => load_fixture('order_with_properties')
-    order = ShopifyAPI::Order.create(line_items: [{quantity:1, variant_id:39072856, properties:props}], financial_status:"authorized")
+    order = ShopifyAPI::Order.create(line_items: [{ quantity:1, variant_id:39072856, properties:props }], financial_status:"authorized")
     assert_equal 39072856, order.line_items.first.variant_id
   end
 
@@ -56,7 +56,7 @@ class OrderTest < Test::Unit::TestCase
     fake 'orders/450789469/cancel', :method => :post, :body => load_fixture('order')
     order = ShopifyAPI::Order.find(450789469)
     order.cancel(email: false, restock: true)
-    assert_request_body({'email' => false, 'restock' => true}.to_json)
+    assert_request_body({ 'email' => false, 'restock' => true }.to_json)
   end
 
   test "capture an order with currency param" do

+ 6 - 6
test/product_test.rb

@@ -25,7 +25,7 @@ class ProductTest < Test::Unit::TestCase
     metafields = @product.metafields
 
     assert_equal 3, metafields.length
-    assert metafields.all?{ |m| m.is_a? ShopifyAPI::Metafield }
+    assert metafields.all? { |m| m.is_a? ShopifyAPI::Metafield }
   end
 
   def test_get_2_metafields_for_product
@@ -37,7 +37,7 @@ class ProductTest < Test::Unit::TestCase
     metafields = @product.metafields limit: 2
 
     assert_equal 2, metafields.length
-    assert metafields.all?{ |m| m.is_a? ShopifyAPI::Metafield }
+    assert metafields.all? { |m| m.is_a? ShopifyAPI::Metafield }
   end
 
   def test_update_loaded_variant
@@ -57,7 +57,7 @@ class ProductTest < Test::Unit::TestCase
 
     assert_equal('100.00 - 199.00', @product.price_range)
   end
-  
+
   def test_deprecated_variant_inventory_fields_are_included_in_2019_07
     ShopifyAPI::Base.api_version = '2019-07'
     variant = @product.variants.first
@@ -77,13 +77,13 @@ class ProductTest < Test::Unit::TestCase
 
   def test_setting_product_total_inventory_passes_in_api_before_2019_10
     ShopifyAPI::Base.api_version = '2019-07'
-    fake("products/632910392", {:body => load_fixture('product')})
+    fake("products/632910392", { :body => load_fixture('product') })
     @product.total_inventory = 8
   end
 
   def test_setting_product_total_inventory_fails_in_2019_10_api
     ShopifyAPI::Base.api_version = '2019-10'
-    fake("products/632910392", {:body => load_fixture('product')})
+    fake("products/632910392", { :body => load_fixture('product') })
     assert_raises(ShopifyAPI::ValidationException) do
       @product.total_inventory = 8
     end
@@ -91,7 +91,7 @@ class ProductTest < Test::Unit::TestCase
 
   def test_setting_product_total_inventory_fails_in_the_unstable_api
     ShopifyAPI::Base.api_version = :unstable
-    fake("products/632910392", {:body => load_fixture('product')})
+    fake("products/632910392", { :body => load_fixture('product') })
     assert_raises(ShopifyAPI::ValidationException) do
       @product.total_inventory = 8
     end

+ 1 - 1
test/recurring_application_charge_test.rb

@@ -126,7 +126,7 @@ class RecurringApplicationChargeTest < Test::Unit::TestCase
   end
 
   def test_no_recurring_application_charge_found
-    fake "recurring_application_charges", body: {recurring_application_charges: []}.to_json
+    fake "recurring_application_charges", body: { recurring_application_charges: [] }.to_json
 
     assert_equal 0, ShopifyAPI::RecurringApplicationCharge.all.count
     assert_nil ShopifyAPI::RecurringApplicationCharge.current

+ 2 - 2
test/refund_test.rb

@@ -17,7 +17,7 @@ class RefundTest < Test::Unit::TestCase
   test '#find should return a refund' do
     fake "orders/450789469/refunds/509562969.json?order_id=450789469", :extension => false, :method => :get, :body => load_fixture('refund')
     fake "orders/450789469/refunds/509562969", :method => :get, :body => load_fixture('refund')
-    refund = ShopifyAPI::Refund.find(509562969, :params => {:order_id => 450789469})
+    refund = ShopifyAPI::Refund.find(509562969, :params => { :order_id => 450789469 })
     assert_equal 509562969, refund.id
   end
 
@@ -25,7 +25,7 @@ class RefundTest < Test::Unit::TestCase
     fake "orders/450789469/refunds/calculate", :method => :post, :body => load_fixture('refund')
     data = { :shipping => { :amount => 0 } }
 
-    refund = ShopifyAPI::Refund.calculate(data, :params => {:order_id => 450789469})
+    refund = ShopifyAPI::Refund.calculate(data, :params => { :order_id => 450789469 })
     assert_equal 2, refund.refund_line_items.count
     assert_equal 703073504, refund.refund_line_items.first.line_item_id
   end

+ 3 - 3
test/session_test.rb

@@ -81,7 +81,7 @@ class SessionTest < Test::Unit::TestCase
   test "raise error if params passed but signature omitted" do
     assert_raises(ShopifyAPI::ValidationException) do
       session = ShopifyAPI::Session.new(domain: "testshop.myshopify.com", token: nil, api_version: any_api_version)
-      session.request_token({'code' => 'any-code'})
+      session.request_token({ 'code' => 'any-code' })
     end
   end
 
@@ -337,7 +337,7 @@ class SessionTest < Test::Unit::TestCase
   end
 
   test "raise error if signature does not match expected" do
-    params = {:code => "any-code", :timestamp => Time.now}
+    params = { :code => "any-code", :timestamp => Time.now }
     signature = generate_signature(params)
     params[:foo] = 'world'
     assert_raises(ShopifyAPI::ValidationException) do
@@ -347,7 +347,7 @@ class SessionTest < Test::Unit::TestCase
   end
 
   test "raise error if timestamp is too old" do
-    params = {:code => "any-code", :timestamp => Time.now - 2.days}
+    params = { :code => "any-code", :timestamp => Time.now - 2.days }
     signature = generate_signature(params)
     params[:foo] = 'world'
     assert_raises(ShopifyAPI::ValidationException) do

+ 4 - 4
test/shop_test.rb

@@ -19,7 +19,7 @@ class ShopTest < Test::Unit::TestCase
   def test_current_with_options_should_return_current_shop
     fake "shop.json?fields%5B%5D=name&fields%5B%5D=myshopify_domain", :extension => false, :method => :get, :status => 201, :body => load_fixture('shop')
 
-    @shop = ShopifyAPI::Shop.current(params: { fields: [:name, :myshopify_domain]})
+    @shop = ShopifyAPI::Shop.current(params: { fields: [:name, :myshopify_domain] })
     assert @shop.is_a?(ShopifyAPI::Shop)
     assert_equal "Apple Computers", @shop.name
     assert_equal "apple.myshopify.com", @shop.myshopify_domain
@@ -31,7 +31,7 @@ class ShopTest < Test::Unit::TestCase
     metafields = @shop.metafields
 
     assert_equal 3, metafields.length
-    assert metafields.all?{|m| m.is_a?(ShopifyAPI::Metafield)}
+    assert metafields.all? { |m| m.is_a?(ShopifyAPI::Metafield) }
   end
 
   def test_get_2_metafields_for_shop
@@ -43,7 +43,7 @@ class ShopTest < Test::Unit::TestCase
     metafields = @shop.metafields limit: 2
 
     assert_equal 2, metafields.length
-    assert metafields.all?{ |m| m.is_a? ShopifyAPI::Metafield }
+    assert metafields.all? { |m| m.is_a? ShopifyAPI::Metafield }
   end
 
   def test_add_metafield
@@ -63,6 +63,6 @@ class ShopTest < Test::Unit::TestCase
     events = @shop.events
 
     assert_equal 3, events.length
-    assert events.all?{|m| m.is_a?(ShopifyAPI::Event)}
+    assert events.all? { |m| m.is_a?(ShopifyAPI::Event) }
   end
 end

+ 2 - 2
test/test_helper.rb

@@ -84,7 +84,7 @@ module Test
         assert array.include?(value)
       end
 
-      def load_fixture(name, format=:json)
+      def load_fixture(name, format = :json)
         File.read(File.dirname(__FILE__) + "/fixtures/#{name}.#{format}")
       end
 
@@ -92,7 +92,7 @@ module Test
         assert_equal expected, WebMock.last_request.body
       end
 
-      def fake(endpoint, options={})
+      def fake(endpoint, options = {})
         request_body = options.has_key?(:request_body) ? options.delete(:request_body) : nil
         body   = options.has_key?(:body) ? options.delete(:body) : load_fixture(endpoint)
         format = options.delete(:format) || :json

+ 1 - 1
test/transaction_test.rb

@@ -9,7 +9,7 @@ class TransactionTest < Test::Unit::TestCase
   context "Transaction" do
     context "#find" do
       should "find a specific transaction" do
-        transaction = ShopifyAPI::Transaction.find(389404469, :params => {:order_id => 450789469})
+        transaction = ShopifyAPI::Transaction.find(389404469, :params => { :order_id => 450789469 })
         assert_equal "409.94", transaction.amount
       end
     end

+ 2 - 2
test/usage_charge_test.rb

@@ -6,14 +6,14 @@ class UsageChargeTest < Test::Unit::TestCase
     fake "recurring_application_charges/654381177/usage_charges", method: :post, body: load_fixture('usage_charge')
 
     usage_charge = ShopifyAPI::UsageCharge.new(description: '1000 emails', price: 1.0)
-    usage_charge.prefix_options = {recurring_application_charge_id: 654381177}
+    usage_charge.prefix_options = { recurring_application_charge_id: 654381177 }
     assert usage_charge.save
   end
 
   def test_get_usage_charges
     fake "recurring_application_charges/654381177/usage_charges/359376002", method: :get, status: 201, body: load_fixture('usage_charge')
 
-    usage_charge = ShopifyAPI::UsageCharge.find(359376002, params: {recurring_application_charge_id: 654381177})
+    usage_charge = ShopifyAPI::UsageCharge.find(359376002, params: { recurring_application_charge_id: 654381177 })
 
     assert_equal "1000 emails", usage_charge.description
   end

+ 1 - 1
test/variant_test.rb

@@ -4,7 +4,7 @@ class VariantTest < Test::Unit::TestCase
   def setup
     super
     fake "products/632910392/variants/808950810", method: :get, body: load_fixture('variant')
-    @variant = ShopifyAPI::Variant.find(808950810, :params => {:product_id => 632910392})
+    @variant = ShopifyAPI::Variant.find(808950810, :params => { :product_id => 632910392 })
   end
 
   def test_get_variants