Skip to content

Commit

Permalink
chore(deps-dev): bump rack-test from 1.1.0 to 2.1.0 (#54) (#61)
Browse files Browse the repository at this point in the history
* 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](rack/rack-test@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] <support@github.com>
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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
drstrangelooker and dependabot[bot] authored Aug 27, 2024
1 parent 5cb90f9 commit eb34ade
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 35 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 8 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 10 additions & 4 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions test/looker/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/looker/test_dynamic_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

require_relative '../helper'

class LookerDynamicClientTest < MiniTest::Spec
class LookerDynamicClienttest < Minitest::Spec

def access_token
'87614b09dd141c22800f96f11737ade5226d7ba8'
Expand Down Expand Up @@ -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

Expand All @@ -86,30 +86,30 @@ 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

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
end

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
Expand Down
55 changes: 44 additions & 11 deletions test/looker/test_dynamic_client_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,87 +64,120 @@ 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
end
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
end
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
end
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
end
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
end
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
end
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
end
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
end
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
end
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
end
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
Expand Down

0 comments on commit eb34ade

Please sign in to comment.