Skip to content

Commit

Permalink
Fix testing hash output under old Ruby versions
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorrison committed Jan 14, 2025
1 parent 070151a commit e068abb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions spec/requests/haberdasher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def make_hat_success_request
expect(response.body).to eq('{"code":"invalid_argument","msg":"is too small","meta":{"argument":"inches"}}')

expect(::Rails.logger).to have_received(:info).with(/Twirp 400 in \d+ms as application\/json/)
expect(::Rails.logger).to have_received(:debug).with('Twirp Response: <Twirp::Error code:invalid_argument msg:"is too small" meta:{argument: "inches"}>')
expect(::Rails.logger).to have_received(:debug).with("Twirp Response: <Twirp::Error code:invalid_argument msg:\"is too small\" meta:#{{argument: "inches"}}>") # standard:disable Lint/LiteralInInterpolation
end

it "allows a before_action to return a Twirp::Error" do
Expand All @@ -57,7 +57,7 @@ def make_hat_success_request
expect(response.body).to eq('{"code":"invalid_argument","msg":"is too big","meta":{"argument":"inches"}}')

expect(::Rails.logger).to have_received(:info).with(/Twirp 400 in \d+ms as application\/json/)
expect(::Rails.logger).to have_received(:debug).with('Twirp Response: <Twirp::Error code:invalid_argument msg:"is too big" meta:{argument: "inches"}>')
expect(::Rails.logger).to have_received(:debug).with("Twirp Response: <Twirp::Error code:invalid_argument msg:\"is too big\" meta:#{{argument: "inches"}}>") # standard:disable Lint/LiteralInInterpolation
end

it "deals with unhandled exceptions" do
Expand All @@ -74,7 +74,7 @@ def make_hat_success_request
expect(response.body).to eq('{"code":"internal","msg":"Contrived Example Error","meta":{"cause":"RuntimeError"}}')

expect(::Rails.logger).to have_received(:info).with(/Twirp 500 in \d+ms as application\/json/)
expect(::Rails.logger).to have_received(:debug).with('Twirp Response: <Twirp::Error code:internal msg:"Contrived Example Error" meta:{cause: "RuntimeError"}>')
expect(::Rails.logger).to have_received(:debug).with("Twirp Response: <Twirp::Error code:internal msg:\"Contrived Example Error\" meta:#{{cause: "RuntimeError"}}>") # standard:disable Lint/LiteralInInterpolation
end
end

Expand Down Expand Up @@ -169,6 +169,7 @@ def make_hat_success_request
expect(response.etag).to be_present

expect(::Rails.logger).to have_received(:info).with(/Twirp 200 in \d+ms as application\/protobuf/)
expect(::Rails.logger).to have_received(:debug).with('Twirp Response: <Twirp::Example::Haberdasher::Hat: inches: 24, color: "Tan", name: "Pork Pie">')

post "/twirp/twirp.example.haberdasher.Haberdasher/MakeHat",
params: size.to_proto, headers: {
Expand Down

0 comments on commit e068abb

Please sign in to comment.