Skip to content

Commit

Permalink
Stub constant in spec rather than defining it
Browse files Browse the repository at this point in the history
By defining it we may inadvertently overwrite an existing constant for
the whole test suite. Use RSpec's `stub_const` to only overwrite it for
this one test.
  • Loading branch information
tombruijn committed Mar 9, 2022
1 parent 89a6224 commit 2d8c525
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec/lib/appsignal/transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1350,8 +1350,8 @@ def session_exists?(_env)
end

context "with a PG::UniqueViolation" do
module PG
class UniqueViolation < StandardError; end
before do
stub_const("PG::UniqueViolation", Class.new(StandardError))
end

let(:error) do
Expand Down

0 comments on commit 2d8c525

Please sign in to comment.