Skip to content

Commit

Permalink
Add tests for messages about calledWithMatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Dec 16, 2012
1 parent b3ac4d4 commit 709d773
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sinon-chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
sinonMethod("calledOn", "been called with %1 as this", ", but it was called with %t instead");
sinonMethod("calledWith", "been called with arguments %*", "%C");
sinonMethod("calledWithExactly", "been called with exact arguments %*", "%C");
sinonMethod("calledWithMatch", "been called with matching arguments %*", "%C");
sinonMethod("calledWithMatch", "been called with arguments matching %*", "%C");
sinonMethod("returned", "returned %1");
exceptionalSinonMethod("thrown", "threw", "thrown %1");
}));
13 changes: 13 additions & 0 deletions test/messages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,15 @@
.throw("expected spy to have been called with arguments a, b, c\n spy(1, 2, 3)")
expect(-> spy.should.have.been.calledWithExactly("a", "b", "c")).to
.throw("expected spy to have been called with exact arguments a, b, c\n spy(1, 2, 3)")
expect(-> spy.should.have.been.calledWithMatch(sinon.match("foo"))).to
.throw("expected spy to have been called with arguments matching match(\"foo\")\n spy(1, 2, 3)")

expect(-> spy.getCall(0).should.have.been.calledWith("a", "b", "c")).to
.throw("expected spy to have been called with arguments a, b, c\n spy(1, 2, 3)")
expect(-> spy.getCall(0).should.have.been.calledWithExactly("a", "b", "c")).to
.throw("expected spy to have been called with exact arguments a, b, c\n spy(1, 2, 3)")
expect(-> spy.getCall(0).should.have.been.calledWithMatch(sinon.match("foo"))).to
.throw("expected spy to have been called with arguments matching match(\"foo\")\n spy(1, 2, 3)")

it "should be correct for the negated cases", ->
spy = sinon.spy()
Expand All @@ -148,11 +152,15 @@
.throw("expected spy to not have been called with arguments 1, 2, 3")
expect(-> spy.should.not.have.been.calledWithExactly(1, 2, 3)).to
.throw("expected spy to not have been called with exact arguments 1, 2, 3")
expect(-> spy.should.not.have.been.calledWithMatch(sinon.match(1))).to
.throw("expected spy to not have been called with arguments matching match(1)")

expect(-> spy.getCall(0).should.not.have.been.calledWith(1, 2, 3)).to
.throw("expected spy to not have been called with arguments 1, 2, 3")
expect(-> spy.getCall(0).should.not.have.been.calledWithExactly(1, 2, 3)).to
.throw("expected spy to not have been called with exact arguments 1, 2, 3")
expect(-> spy.getCall(0).should.not.have.been.calledWithMatch(sinon.match(1))).to
.throw("expected spy to not have been called with arguments matching match(1)")

it "should be correct for the always cases", ->
spy = sinon.spy()
Expand All @@ -169,6 +177,11 @@
expect(-> spy.should.always.have.been.calledWithExactly(1, 2, 3)).to
.throw(expectedExactly)

expectedMatch = "expected spy to always have been called with arguments matching match(1)\n" +
" spy(1, 2, 3)\n spy(a, b, c)"
expect(-> spy.should.always.have.been.calledWithMatch(sinon.match(1))).to
.throw(expectedMatch)

describe "about returning", ->
it "should be correct for the basic case", ->
spy = sinon.spy.create(-> 1)
Expand Down

0 comments on commit 709d773

Please sign in to comment.