From eb34adef1f7210a483930ae7db0fe04089dc4093 Mon Sep 17 00:00:00 2001 From: "Dr. Strangelove" Date: Tue, 27 Aug 2024 18:37:06 -0400 Subject: [PATCH] chore(deps-dev): bump rack-test from 1.1.0 to 2.1.0 (#54) (#61) * chore(deps-dev): bump rack-test from 1.1.0 to 2.1.0 (#54) Bumps [rack-test](https://github.com/rack/rack-test) from 1.1.0 to 2.1.0. - [Release notes](https://github.com/rack/rack-test/releases) - [Changelog](https://github.com/rack/rack-test/blob/main/History.md) - [Commits](https://github.com/rack/rack-test/compare/v1.1.0...v2.1.0) --- updated-dependencies: - dependency-name: rack-test dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: upgrade deps and fix tests for new format Change-Id: I7eb31a94ee2aaca875bbafda82da11e074ae9b74 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 6 +-- Gemfile.lock | 17 ++++---- test/helper.rb | 14 ++++-- test/looker/test_client.rb | 8 +++- test/looker/test_dynamic_client.rb | 12 +++--- test/looker/test_dynamic_client_agent.rb | 55 +++++++++++++++++++----- 6 files changed, 77 insertions(+), 35 deletions(-) diff --git a/Gemfile b/Gemfile index 1f7c471..f7ce597 100644 --- a/Gemfile +++ b/Gemfile @@ -11,11 +11,11 @@ end group :test do # gem 'json', '~> 1.7', :platforms => [:jruby] look TODO needed? - gem 'minitest', '~> 5.11.0' - gem 'mocha', '~> 1.1.0' + gem 'minitest', '~> 5.25.1' + gem 'mocha', '~> 2.4.5' gem 'rack', '~> 2.2.8' - gem 'rack-test', '~> 1' gem 'netrc', '~> 0.11.0' + gem 'rack-test', '~> 2' gem 'simplecov', '~> 0.22.0', :require => false end diff --git a/Gemfile.lock b/Gemfile.lock index fde23b2..f8e6608 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,16 +29,15 @@ GEM faraday-net_http (3.0.2) faraday-rack (2.0.0) faraday (~> 2.0) - metaclass (0.0.4) - minitest (5.11.3) - mocha (1.1.0) - metaclass (~> 0.0.1) + minitest (5.25.1) + mocha (2.4.5) + ruby2_keywords (>= 0.0.5) multipart-post (2.3.0) netrc (0.11.0) public_suffix (5.0.1) rack (2.2.8.1) - rack-test (1.1.0) - rack (>= 1.0, < 3) + rack-test (2.1.0) + rack (>= 1.3) rake (13.2.1) redcarpet (3.5.1) rexml (3.3.6) @@ -66,11 +65,11 @@ DEPENDENCIES faraday-multipart (~> 1.0) faraday-rack (~> 2) looker-sdk! - minitest (~> 5.11.0) - mocha (~> 1.1.0) + minitest (~> 5.25.1) + mocha (~> 2.4.5) netrc (~> 0.11.0) rack (~> 2.2.8) - rack-test (~> 1) + rack-test (~> 2) rake (~> 13.2.1) redcarpet (~> 3.5.1) simplecov (~> 0.22.0) diff --git a/test/helper.rb b/test/helper.rb index 4beb731..6c9e79e 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -23,9 +23,7 @@ ############################################################################################ require 'simplecov' -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ - SimpleCov::Formatter::HTMLFormatter -] +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new SimpleCov::Formatter::HTMLFormatter SimpleCov.start require 'rubygems' @@ -38,12 +36,20 @@ require 'minitest/autorun' require 'minitest/spec' require 'minitest/mock' -require 'mocha/mini_test' +require 'mocha/minitest' require "rack/test" require "rack/request" require "faraday/rack" require "faraday/multipart" if ENV['USE_FARADAY_MULTIPART'] == 'true' +module Minitest + class Mock + def is_a?( _a ) + false + end + end +end + def fixture_path File.expand_path("../fixtures", __FILE__) end diff --git a/test/looker/test_client.rb b/test/looker/test_client.rb index 19d073e..b54e9f0 100644 --- a/test/looker/test_client.rb +++ b/test/looker/test_client.rb @@ -304,7 +304,11 @@ expected_path = '/api/4.0/users/foo%252Fbar' resp = OpenStruct.new(:data => "hi", :status => 204) - mock = MiniTest::Mock.new.expect(:call, resp, [method, expected_path, nil, {}]) + #mock = Minitest::Mock.new.expect(:call, resp, [method, expected_path, nil]) + mock = Minitest::Mock.new.expect :call, resp do | verb, route, body, h=nil, **kw | + verb == method && route == expected_path + end + Sawyer::Agent.stubs(:new).returns(mock, mock) sdk = LookerSDK::Client.new @@ -314,7 +318,7 @@ args = [method, path, nil, nil, encoded] end sdk.without_authentication do - value = sdk.public_send *args + value = sdk.public_send(*args) assert_equal "hi", value end mock.verify diff --git a/test/looker/test_dynamic_client.rb b/test/looker/test_dynamic_client.rb index 4f7c221..01235b1 100644 --- a/test/looker/test_dynamic_client.rb +++ b/test/looker/test_dynamic_client.rb @@ -24,7 +24,7 @@ require_relative '../helper' -class LookerDynamicClientTest < MiniTest::Spec +class LookerDynamicClienttest < Minitest::Spec def access_token '87614b09dd141c22800f96f11737ade5226d7ba8' @@ -70,7 +70,7 @@ def confirm_env(env, method, path, body, query, content_type) begin JSON.parse(req_body, :symbolize_names => true).must_equal body - rescue JSON::ParserError => e + rescue JSON::ParserError req_body.must_equal body end @@ -86,7 +86,7 @@ def confirm_env(env, method, path, body, query, content_type) end def verify(response, method, path, body='', query={}, content_type = nil) - mock = MiniTest::Mock.new.expect(:call, response){|env| confirm_env(env, method, path, body, query, content_type)} + mock = Minitest::Mock.new.expect(:call, response){|env| confirm_env(env, method, path, body, query, content_type)} yield sdk_client(default_swagger, mock) mock.verify end @@ -94,7 +94,7 @@ def verify(response, method, path, body='', query={}, content_type = nil) describe "swagger" do it "raises when swagger.json can't be loaded" do - mock = MiniTest::Mock.new.expect(:call, nil) {raise "no swagger for you"} + mock = Minitest::Mock.new.expect(:call, nil) {raise "no swagger for you"} mock.expect(:call, nil) {raise "still no swagger for you"} err = assert_raises(RuntimeError) { sdk_client(nil, mock) } assert_equal "still no swagger for you", err.message @@ -102,14 +102,14 @@ def verify(response, method, path, body='', query={}, content_type = nil) it "loads swagger without authentication" do resp = [200, {'Content-Type' => 'application/json'}, [default_swagger.to_json]] - mock = MiniTest::Mock.new.expect(:call, resp, [Hash]) + mock = Minitest::Mock.new.expect(:call, resp, [Hash]) sdk = sdk_client(nil, mock) assert_equal default_swagger, sdk.swagger end it "loads swagger with authentication" do resp = [200, {'Content-Type' => 'application/json'}, [default_swagger.to_json]] - mock = MiniTest::Mock.new.expect(:call, nil) {raise "login first!"} + mock = Minitest::Mock.new.expect(:call, nil) {raise "login first!"} mock.expect(:call, resp, [Hash]) sdk = sdk_client(nil, mock) assert_equal default_swagger, sdk.swagger diff --git a/test/looker/test_dynamic_client_agent.rb b/test/looker/test_dynamic_client_agent.rb index 53c93d4..619b229 100644 --- a/test/looker/test_dynamic_client_agent.rb +++ b/test/looker/test_dynamic_client_agent.rb @@ -64,7 +64,10 @@ def delete_response describe "swagger" do it "get" do - mock = MiniTest::Mock.new.expect(:call, response, [:get, '/api/4.0/user', nil, {}]) + #mock = Minitest::Mock.new.expect(:call, response, [:get, '/api/4.0/user', nil]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw | + verb == :get && route == '/api/4.0/user' && body.nil? + end with_stub(Sawyer::Agent, :new, mock) do sdk.me mock.verify @@ -72,7 +75,10 @@ def delete_response end it "get with params" do - mock = MiniTest::Mock.new.expect(:call, response, [:get, '/api/4.0/users/25', nil, {}]) + #mock = Minitest::Mock.new.expect(:call, response, [:get, '/api/4.0/users/25', nil, {}]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body | + verb == :get && route == '/api/4.0/users/25' && body.nil? + end with_stub(Sawyer::Agent, :new, mock) do sdk.user(25) mock.verify @@ -80,7 +86,10 @@ def delete_response end it "get with query" do - mock = MiniTest::Mock.new.expect(:call, response, [:get, '/api/4.0/user', nil, {query:{bar:"foo"}}]) + #mock = Minitest::Mock.new.expect(:call, response, [:get, '/api/4.0/user', nil, {query:{bar:"foo"}}]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw | + verb == :get && route == '/api/4.0/user' && body.nil? && ( h={query:{bar:"foo"}} || kw = {query:{bar:"foo"}} ) + end with_stub(Sawyer::Agent, :new, mock) do sdk.me({bar:'foo'}) mock.verify @@ -88,7 +97,10 @@ def delete_response end it "get with params and query" do - mock = MiniTest::Mock.new.expect(:call, response, [:get, '/api/4.0/users/25', nil, {query:{bar:"foo"}}]) + #mock = Minitest::Mock.new.expect(:call, response, [:get, '/api/4.0/users/25', nil, {query:{bar:"foo"}}]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body,h=nil, **kw | + verb == :get && route == '/api/4.0/users/25' && body.nil? && ( h={query:{bar:"foo"}} || kw = {query:{bar:"foo"}} ) + end with_stub(Sawyer::Agent, :new, mock) do sdk.user(25, {bar:'foo'}) mock.verify @@ -96,7 +108,10 @@ def delete_response end it "post" do - mock = MiniTest::Mock.new.expect(:call, response, [:post, '/api/4.0/users', {first_name:'Joe'}, {:headers=>{:content_type=>"application/json"}}]) + #mock = Minitest::Mock.new.expect(:call, response, [:post, '/api/4.0/users', {first_name:'Joe'}, {:headers=>{:content_type=>"application/json"}}]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw | + verb == :post && route == '/api/4.0/users' && body == {first_name:'Joe'} && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} ) + end with_stub(Sawyer::Agent, :new, mock) do sdk.create_user({first_name:'Joe'}) mock.verify @@ -104,7 +119,10 @@ def delete_response end it "post with default body" do - mock = MiniTest::Mock.new.expect(:call, response, [:post, '/api/4.0/users', {}, {:headers=>{:content_type=>"application/json"}}]) + #mock = Minitest::Mock.new.expect(:call, response, [:post, '/api/4.0/users', {}, {:headers=>{:content_type=>"application/json"}}]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw | + verb == :post && route == '/api/4.0/users' && body.empty? && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} ) + end with_stub(Sawyer::Agent, :new, mock) do sdk.create_user() mock.verify @@ -112,7 +130,10 @@ def delete_response end it "patch" do - mock = MiniTest::Mock.new.expect(:call, response, [:patch, '/api/4.0/users/25', {first_name:'Jim'}, {:headers=>{:content_type=>"application/json"}}]) + #mock = Minitest::Mock.new.expect(:call, response, [:patch, '/api/4.0/users/25', {first_name:'Jim'}, {:headers=>{:content_type=>"application/json"}}]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw | + verb == :patch && route == '/api/4.0/users/25' && body == {first_name:'Jim'} && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} ) + end with_stub(Sawyer::Agent, :new, mock) do sdk.update_user(25, {first_name:'Jim'}) mock.verify @@ -120,7 +141,10 @@ def delete_response end it "put" do - mock = MiniTest::Mock.new.expect(:call, response, [:put, '/api/4.0/users/25/roles', [10, 20], {:headers=>{:content_type=>"application/json"}}]) + #mock = Minitest::Mock.new.expect(:call, response, [:put, '/api/4.0/users/25/roles', [10, 20], {:headers=>{:content_type=>"application/json"}}]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw | + verb == :put && route == '/api/4.0/users/25/roles' && body == [10, 20] && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} ) + end with_stub(Sawyer::Agent, :new, mock) do sdk.set_user_roles(25, [10,20]) mock.verify @@ -128,7 +152,10 @@ def delete_response end it "put with nil body" do - mock = MiniTest::Mock.new.expect(:call, response, [:put, '/api/4.0/users/25/roles', nil, {}]) + #mock = Minitest::Mock.new.expect(:call, response, [:put, '/api/4.0/users/25/roles', nil]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw | + verb == :put && route == '/api/4.0/users/25/roles' && body.nil? + end with_stub(Sawyer::Agent, :new, mock) do sdk.set_user_roles(25, nil) mock.verify @@ -136,7 +163,10 @@ def delete_response end it "put with empty body" do - mock = MiniTest::Mock.new.expect(:call, response, [:put, '/api/4.0/users/25/roles', {}, {:headers=>{:content_type=>"application/json"}}]) + #mock = Minitest::Mock.new.expect(:call, response, [:put, '/api/4.0/users/25/roles', {}, {:headers=>{:content_type=>"application/json"}}]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw | + verb == :put && route == '/api/4.0/users/25/roles' && body.empty? && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} ) + end with_stub(Sawyer::Agent, :new, mock) do sdk.set_user_roles(25, {}) mock.verify @@ -144,7 +174,10 @@ def delete_response end it "delete" do - mock = MiniTest::Mock.new.expect(:call, delete_response, [:delete, '/api/4.0/users/25', nil, {}]) + #mock = Minitest::Mock.new.expect(:call, delete_response, [:delete, '/api/4.0/users/25', nil]) + mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw | + verb == :delete && route == '/api/4.0/users/25' && body.nil? + end with_stub(Sawyer::Agent, :new, mock) do sdk.delete_user(25) mock.verify