Skip to content

Commit

Permalink
Make the toString of mock argument matchers match the API for them.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoglan committed Nov 4, 2013
1 parent 7da6afc commit 2107131
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
11 changes: 5 additions & 6 deletions source/test/mocking/matchers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Test.Mocking.extend({
Anything: new JS.Class({
equals: function() { return true },
toString: function() { return 'anything' }
toString: function() { return 'anything()' }
}),

AnyArgs: new JS.Class({
equals: function() { return Enumerable.ALL_EQUAL },
toString: function() { return '*arguments' }
toString: function() { return 'anyArgs()' }
}),

ArrayIncluding: new JS.Class({
Expand Down Expand Up @@ -64,9 +64,8 @@ Test.Mocking.extend({
},

toString: function() {
var name = Console.convert(this._type),
an = /^[aeiou]/i.test(name) ? 'an' : 'a';
return an + '(' + name + ')';
var name = Console.convert(this._type);
return 'instanceOf(' + name + ')';
}
}),

Expand All @@ -81,7 +80,7 @@ Test.Mocking.extend({

toString: function() {
var name = Console.convert(this._type);
return 'matching(' + name + ')';
return 'match(' + name + ')';
}
})
});
Expand Down
18 changes: 9 additions & 9 deletions test/specs/test/mocking_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Test.MockingSpec = JS.Test.describe(JS.Test.Mocking, function() { with(this) {
"testExpectMethod(TestedSuite):\n" +
"Mock expectation not met\n" +
"<[OBJECT]> expected to receive call\n" +
"getName( *arguments )" )
"getName( anyArgs() )" )
})})
}})

Expand Down Expand Up @@ -315,7 +315,7 @@ Test.MockingSpec = JS.Test.describe(JS.Test.Mocking, function() { with(this) {
"testExpectMethod(TestedSuite):\n" +
"Mock expectation not met\n" +
"<[OBJECT]> expected to receive call\n" +
"getName( *arguments )\n" +
"getName( anyArgs() )\n" +
"at least 3 times\n" +
"but 2 calls were made" )
})})
Expand All @@ -332,7 +332,7 @@ Test.MockingSpec = JS.Test.describe(JS.Test.Mocking, function() { with(this) {
"testExpectMethod(TestedSuite):\n" +
"Mock expectation not met\n" +
"<[OBJECT]> expected to receive call\n" +
"getName( *arguments )" )
"getName( anyArgs() )" )
})})
}})
}})
Expand Down Expand Up @@ -366,7 +366,7 @@ Test.MockingSpec = JS.Test.describe(JS.Test.Mocking, function() { with(this) {
"testExpectMethod(TestedSuite):\n" +
"Mock expectation not met\n" +
"<[OBJECT]> expected to receive call\n" +
"getName( *arguments )\n" +
"getName( anyArgs() )\n" +
"at most 3 times\n" +
"but 4 calls were made" )
})})
Expand Down Expand Up @@ -418,7 +418,7 @@ Test.MockingSpec = JS.Test.describe(JS.Test.Mocking, function() { with(this) {
"testExpectMethod(TestedSuite):\n" +
"Mock expectation not met\n" +
"<[OBJECT]> expected to receive call\n" +
"getName( *arguments )\n" +
"getName( anyArgs() )\n" +
"exactly 0 times\n" +
"but 1 call was made" )
})})
Expand All @@ -438,7 +438,7 @@ Test.MockingSpec = JS.Test.describe(JS.Test.Mocking, function() { with(this) {
"testExpectMethod(TestedSuite):\n" +
"Mock expectation not met\n" +
"<[OBJECT]> expected to receive call\n" +
"getName( *arguments )\n" +
"getName( anyArgs() )\n" +
"exactly 2 times\n" +
"but 3 calls were made" )
})})
Expand All @@ -456,7 +456,7 @@ Test.MockingSpec = JS.Test.describe(JS.Test.Mocking, function() { with(this) {
"testExpectMethod(TestedSuite):\n" +
"Mock expectation not met\n" +
"<[OBJECT]> expected to receive call\n" +
"getName( *arguments )\n" +
"getName( anyArgs() )\n" +
"exactly 2 times\n" +
"but 1 call was made" )
})})
Expand Down Expand Up @@ -620,7 +620,7 @@ Test.MockingSpec = JS.Test.describe(JS.Test.Mocking, function() { with(this) {
"testExpectWithYields(TestedSuite):\n" +
"Mock expectation not met\n" +
"<[OBJECT]> expected to receive call\n" +
"getName( *arguments, a(Function) )" )
"getName( anyArgs(), instanceOf(Function) )" )
})})
}})

Expand Down Expand Up @@ -654,7 +654,7 @@ Test.MockingSpec = JS.Test.describe(JS.Test.Mocking, function() { with(this) {
"testExpectWithYields(TestedSuite):\n" +
"Mock expectation not met\n" +
"<[OBJECT]> expected to receive call\n" +
"getName( 5, 6, a(Function) )" )
"getName( 5, 6, instanceOf(Function) )" )
})})
}})
}})
Expand Down

0 comments on commit 2107131

Please sign in to comment.