Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(jasminewd): allow use of custom matchers
Browse files Browse the repository at this point in the history
Using jasmine.Matchers.prototype to generate the chained methods for
expect() calls is flawed because it does not pick up custom matchers
defined using addMatcher.  Instead, use either the matchersClass for
the current spec or from the environment.
  • Loading branch information
Jeremy Morony authored and juliemr committed Sep 23, 2013
1 parent c22fc38 commit 6223825
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion jasminewd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ function wrapMatcher(matcher, actualPromise) {
*/
function promiseMatchers(actualPromise) {
var promises = {};
for (matcher in jasmine.Matchers.prototype) {
var env = jasmine.getEnv();
var matchersClass = env.currentSpec.matchersClass || env.matchersClass;

for (matcher in matchersClass.prototype) {
promises[matcher] = wrapMatcher(matcher, actualPromise);
};

Expand Down
13 changes: 12 additions & 1 deletion jasminewd/spec/adapterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ var getFakeDriver = function() {
return flow.execute(function() {
return webdriver.promise.fulfilled('b');
});
},
getBigNumber: function() {
return flow.execute(function() {
return webdriver.promise.fulfilled(1111);
});
}
};
};
Expand Down Expand Up @@ -96,7 +101,13 @@ describe('webdriverJS Jasmine adapter', function() {
it('should allow scheduling of tasks', function() {
fakeDriver.sleep(300);
expect(fakeDriver.getValueB()).toEqual('b');
})
});

it('should allow the use of custom matchers', function() {
expect(500).toBeLotsMoreThan(3);
expect(fakeDriver.getBigNumber()).toBeLotsMoreThan(33);
});


// Uncomment to see timeout failures.
// it('should timeout after 200ms', function() {
Expand Down

0 comments on commit 6223825

Please sign in to comment.