mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Capture and report arguments in exception message
This commit is contained in:
parent
75ccda0a86
commit
13f185b801
2 changed files with 27 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
|||
require "../../spec_helper"
|
||||
|
||||
Spectator.describe Spectator::Double do
|
||||
subject(dbl) { Spectator::Double({foo: Int32, bar: String}).new("foobar", foo: 42, bar: "baz") }
|
||||
subject(dbl) { Spectator::Double({foo: Int32, bar: String}).new("dbl-name", foo: 42, bar: "baz") }
|
||||
|
||||
it "responds to defined messages" do
|
||||
aggregate_failures do
|
||||
|
@ -11,11 +11,15 @@ Spectator.describe Spectator::Double do
|
|||
end
|
||||
|
||||
it "fails on undefined messages" do
|
||||
expect { dbl.baz }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.baz }.to raise_error(Spectator::UnexpectedMessage, /baz/)
|
||||
end
|
||||
|
||||
it "reports the name in errors" do
|
||||
expect { dbl.baz }.to raise_error(/foobar/)
|
||||
expect { dbl.baz }.to raise_error(/dbl-name/)
|
||||
end
|
||||
|
||||
it "reports arguments" do
|
||||
expect { dbl.baz(123, "qux", field: :value) }.to raise_error(Spectator::UnexpectedMessage, /\(123, "qux", field: :value\)/)
|
||||
end
|
||||
|
||||
context "without a double name" do
|
||||
|
@ -122,6 +126,10 @@ Spectator.describe Spectator::Double do
|
|||
expect { dbl.same?(nil) }.to raise_error(Spectator::UnexpectedMessage, /mask/)
|
||||
end
|
||||
end
|
||||
|
||||
it "reports arguments" do
|
||||
expect { dbl.same?(123) }.to raise_error(Spectator::UnexpectedMessage, /\(123\)/)
|
||||
end
|
||||
end
|
||||
|
||||
context "with arguments constraints" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue