Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing tests on Ruby 3.4 because of hash inspect changes #1074

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/unit/matchers/hash_excluding_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Matchers
end

it 'describes itself properly' do
expect(HashExcludingMatcher.new(a: 1).inspect).to eq 'hash_excluding({"a"=>1})'
expect(HashExcludingMatcher.new(a: 1).inspect).to eq "hash_excluding(#{{"a" => 1}.inspect})"
end

describe 'success' do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/matchers/hash_including_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Matchers
end

it "describes itself properly" do
expect(HashIncludingMatcher.new(a: 1).inspect).to eq "hash_including({\"a\"=>1})"
expect(HashIncludingMatcher.new(a: 1).inspect).to eq "hash_including(#{{"a"=>1}.inspect})"
end

describe "success" do
Expand Down
15 changes: 9 additions & 6 deletions spec/unit/request_pattern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,25 @@
end

it "should report string describing itself with query params" do
expect(WebMock::RequestPattern.new(:get, /.*example.*/, query: {'a' => ['b', 'c']}).to_s).to eq(
"GET /.*example.*/ with query params {\"a\"=>[\"b\", \"c\"]}"
query = {'a' => ['b', 'c']}
expect(WebMock::RequestPattern.new(:get, /.*example.*/, query: query).to_s).to eq(
"GET /.*example.*/ with query params #{query.inspect}"
)
end

it "should report string describing itself with query params as hash including matcher" do
query = {'a' => ['b', 'c']}
expect(WebMock::RequestPattern.new(:get, /.*example.*/,
query: WebMock::Matchers::HashIncludingMatcher.new({'a' => ['b', 'c']})).to_s).to eq(
"GET /.*example.*/ with query params hash_including({\"a\"=>[\"b\", \"c\"]})"
query: WebMock::Matchers::HashIncludingMatcher.new(query)).to_s).to eq(
"GET /.*example.*/ with query params hash_including(#{query.inspect})"
)
end

it "should report string describing itself with body as hash including matcher" do
query = {'a' => ['b', 'c']}
expect(WebMock::RequestPattern.new(:get, /.*example.*/,
body: WebMock::Matchers::HashIncludingMatcher.new({'a' => ['b', 'c']})).to_s).to eq(
"GET /.*example.*/ with body hash_including({\"a\"=>[\"b\", \"c\"]})"
body: WebMock::Matchers::HashIncludingMatcher.new(query)).to_s).to eq(
"GET /.*example.*/ with body hash_including(#{query.inspect})"
)
end
end
Expand Down
7 changes: 4 additions & 3 deletions spec/unit/request_signature_snippet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@
end

describe "#request_stubs" do
let(:body) { {"a" => "b"} }
before :each do
WebMock.stub_request(:get, "https://www.example.com").with(body: {"a" => "b"})
WebMock.stub_request(:get, "https://www.example.com").with(body: body)
end

context "when showing the body diff is turned off" do
Expand All @@ -60,7 +61,7 @@
result = subject.request_stubs
result.sub!("registered request stubs:\n\n", "")
expect(result).to eq(
"stub_request(:get, \"https://www.example.com/\").\n with(\n body: {\"a\"=>\"b\"})"
"stub_request(:get, \"https://www.example.com/\").\n with(\n body: #{body.inspect})"
)
end

Expand All @@ -74,7 +75,7 @@
result = subject.request_stubs
result.sub!("registered request stubs:\n\n", "")
expect(result).to eq(
"stub_request(:get, \"https://www.example.com/\").\n with(\n body: {\"a\"=>\"b\"})\n\nBody diff:\n [[\"-\", \"key\", \"different value\"], [\"+\", \"a\", \"b\"]]\n"
"stub_request(:get, \"https://www.example.com/\").\n with(\n body: #{body.inspect})\n\nBody diff:\n [[\"-\", \"key\", \"different value\"], [\"+\", \"a\", \"b\"]]\n"
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/stub_request_snippet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
expected = <<-STUB
stub_request(:post, "http://www.example.com/").
with(
body: {"user"=>{"first_name"=>"Bartosz"}},
body: #{{"user"=>{"first_name"=>"Bartosz"}}.inspect},
headers: {
\t 'Content-Type'=>'application/x-www-form-urlencoded'
}).
Expand Down
Loading