Support double names

This commit is contained in:
Michael Miller 2022-03-03 22:31:40 -07:00
parent 26deea3d20
commit 5644d54470
No known key found for this signature in database
GPG key ID: AC78B32D30CE34A2
2 changed files with 26 additions and 6 deletions

View file

@ -1,7 +1,7 @@
require "../../spec_helper"
Spectator.describe Spectator::Double do
subject(dbl) { Spectator::Double.new(foo: 42, bar: "baz") }
subject(dbl) { Spectator::Double.new("foobar", foo: 42, bar: "baz") }
it "responds to defined messages" do
aggregate_failures do
@ -14,6 +14,18 @@ Spectator.describe Spectator::Double do
expect { dbl.baz }.to raise_error(Spectator::UnexpectedMessage)
end
it "reports the name in errors" do
expect { dbl.baz }.to raise_error(/foobar/)
end
context "without a double name" do
subject(dbl) { Spectator::Double.new(foo: 42) }
it "reports as anonymous" do
expect { dbl.baz }.to raise_error(/anonymous/i)
end
end
context "with common object methods" do
subject(dbl) do
Spectator::Double.new(