Browse Source

supress warnings in test

Jon G 5 years ago
parent
commit
73837c5c89
5 changed files with 12 additions and 13 deletions
  1. 1 1
      Rakefile
  2. 0 1
      shopify_api.gemspec
  3. 6 5
      test/base_test.rb
  4. 3 4
      test/recurring_application_charge_test.rb
  5. 2 2
      test/test_helper.rb

+ 1 - 1
Rakefile

@@ -5,7 +5,7 @@ require 'rake/testtask'
 Rake::TestTask.new(:test) do |test|
   test.libs << 'lib' << 'test'
   test.pattern = 'test/**/*_test.rb'
-  test.verbose = true
+  test.warning = false
 end
 
 begin

+ 0 - 1
shopify_api.gemspec

@@ -30,7 +30,6 @@ Gem::Specification.new do |s|
   s.add_runtime_dependency("graphql-client")
 
   s.add_development_dependency("mocha", ">= 0.9.8")
-  # s.add_development_dependency("fakeweb")
   s.add_development_dependency("webmock")
   s.add_development_dependency("minitest", ">= 4.0")
   s.add_development_dependency("rake")

+ 6 - 5
test/base_test.rb

@@ -33,9 +33,9 @@ class BaseTest < Test::Unit::TestCase
 
     ShopifyAPI::Base.clear_session
 
-    assert_equal nil, ShopifyAPI::Base.user
-    assert_equal nil, ShopifyAPI::Base.password
-    assert_equal nil, ShopifyAPI::Base.site
+    assert_nil ShopifyAPI::Base.user
+    assert_nil ShopifyAPI::Base.password
+    assert_nil ShopifyAPI::Base.site
   end
 
   test '#clear_session should clear site and headers from Base' do
@@ -92,8 +92,9 @@ class BaseTest < Test::Unit::TestCase
   test "prefix= will forward to resource when the value does not start with admin" do
     session = ShopifyAPI::Session.new(domain: 'shop1.myshopify.com', token: 'token1', api_version: '2019-01')
     ShopifyAPI::Base.activate_session(session)
-
-    TestResource.prefix = 'a/regular/path/'
+    silence_warnings do
+      TestResource.prefix = 'a/regular/path/'
+    end
 
     assert_equal('/admin/api/2019-01/a/regular/path/', TestResource.prefix)
   end

+ 3 - 4
test/recurring_application_charge_test.rb

@@ -129,15 +129,14 @@ class RecurringApplicationChargeTest < Test::Unit::TestCase
     fake "recurring_application_charges", body: {recurring_application_charges: []}.to_json
 
     assert_equal 0, ShopifyAPI::RecurringApplicationCharge.all.count
-    assert_equal nil, ShopifyAPI::RecurringApplicationCharge.current
+    assert_nil ShopifyAPI::RecurringApplicationCharge.current
     assert_equal [], ShopifyAPI::RecurringApplicationCharge.pending
   end
 
   def test_recurring_application_charge_not_found_error
     fake "recurring_application_charges", body: '{"errors":"Not Found"}', status: 404
-
-    assert_equal(nil, ShopifyAPI::RecurringApplicationCharge.all)
-    assert_equal(nil, ShopifyAPI::RecurringApplicationCharge.current)
+    assert_nil ShopifyAPI::RecurringApplicationCharge.all
+    assert_nil ShopifyAPI::RecurringApplicationCharge.current
     assert_equal([], ShopifyAPI::RecurringApplicationCharge.pending)
   end
 end

+ 2 - 2
test/test_helper.rb

@@ -90,7 +90,7 @@ module Test
         method = options.delete(:method) || :get
         api_version = options.delete(:api_version) || ShopifyAPI::ApiVersion.coerce_to_version('2019-01')
         extension = ".#{options.delete(:extension)||'json'}" unless options[:extension]==false
-
+        status = options.delete(:status) || 200
         url = if options.has_key?(:url)
           options[:url]
         else
@@ -98,7 +98,7 @@ module Test
         end
 
         WebMock.stub_request(method, url).to_return(
-          body: body, status: 200, headers: { content_type: "text/#{format}", content_length: 1 }.merge(options)
+          body: body, status: status, headers: { content_type: "text/#{format}", content_length: 1 }.merge(options)
         )
       end