mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Test response constraints
This commit is contained in:
parent
2e15686d2d
commit
ac007f8565
1 changed files with 18 additions and 0 deletions
|
@ -123,4 +123,22 @@ Spectator.describe Spectator::Double do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with arguments constraints" do
|
||||||
|
let(arguments) { Spectator::Arguments.capture(/foo/) }
|
||||||
|
let(response) { Spectator::Response.new(:foo, "bar", arguments).as(Spectator::AbstractResponse) }
|
||||||
|
subject(dbl) { Spectator::Double({foo: String}).new([response]) }
|
||||||
|
|
||||||
|
it "returns the response when constraint satisfied" do
|
||||||
|
expect(dbl.foo("foobar")).to eq("bar")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "raises an error when constraint unsatisfied" do
|
||||||
|
expect { dbl.foo("baz") }.to raise_error(Spectator::UnexpectedMessage)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "raises an error when argument count doesn't match" do
|
||||||
|
expect { dbl.foo }.to raise_error(Spectator::UnexpectedMessage)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue