Compare commits

..

12 Commits

Author SHA1 Message Date
Gregg Van Hove
6816bc4252 Update to 2.5.2 2016-09-16 17:19:59 -07:00
Gregg Van Hove
04bb56a5b5 Allow currently registered reporters to be cleared
- jasmine/jasmine-npm#88
2016-09-16 16:02:08 -07:00
Greg Cobb
ed31b9b844 Add ISSUE_TEMPLATE for github issues 2016-09-16 10:26:11 -07:00
Gregg Van Hove
4e47b78f1f Use isFunction to check for functionness in callFake
- Fixes #1191
2016-09-14 16:06:44 -07:00
Gregg Van Hove
8624a52ee0 Don't auto install phantom since it doesn't seem to work on travis 2016-09-07 15:48:20 -07:00
Gregg Van Hove
a4b92b34f4 Update to 2.5.1 2016-09-07 14:31:18 -07:00
Gregg Van Hove
3486e8d166 Merge branch '1189' of https://github.com/seanparmelee/jasmine into seanparmelee-1189
- Merges #1193 from @seanparmlee
- Fixes #1189
2016-09-01 21:11:07 -07:00
Gregg Van Hove
8366ef9be5 Merge branch 'fix' of https://github.com/logankd/jasmine into logankd-fix
- Merges #1192 from @logankd
- Fixes #1188
2016-09-01 20:44:13 -07:00
Gregg Van Hove
ab0567c665 Generated file for date tick fix 2016-09-01 20:41:51 -07:00
Sean Parmelee
8676bbf11a fallback on assignment when a spy cannot be deleted 2016-09-01 13:39:25 -05:00
Kevin Logan
c0a9d20a02 fix for issue #1188 2016-09-01 10:59:19 -05:00
Gregg Van Hove
c7cc3b4a29 Properly tick date along with clock
- Specifically when there aren't functions scheduled at the ticks

Fixes #1190
2016-08-31 21:24:01 -07:00
21 changed files with 177 additions and 33 deletions

17
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,17 @@
### Are you creating an issue in the correct repository?
- When in doubt, create an issue here.
- If you have an issue with the Jasmine docs, file an issue in the docs repo
here: https://github.com/jasmine/jasmine.github.io
- This repository is for the core Jasmine framework
- If you are using a test runner that wraps Jasmine (Jasmine npm, karma, etc),
consider filing an issue with that library if appropriate
### When submitting an issue, please answer the following:
- What version are you using?
- What environment are you running Jasmine in (node, browser, etc)?
- How are you running Jasmine (standalone, npm, karma, etc)?
- If possible, include an example spec that demonstrates your issue.
Thanks for using Jasmine!

View File

@@ -67,7 +67,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
j$.ReportDispatcher = jRequire.ReportDispatcher();
j$.Spec = jRequire.Spec(j$);
j$.SpyRegistry = jRequire.SpyRegistry(j$);
j$.SpyStrategy = jRequire.SpyStrategy();
j$.SpyStrategy = jRequire.SpyStrategy(j$);
j$.StringMatching = jRequire.StringMatching(j$);
j$.Suite = jRequire.Suite(j$);
j$.Timer = jRequire.Timer();
@@ -147,6 +147,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return j$.isA_('Number', value);
};
j$.isFunction_ = function(value) {
return j$.isA_('Function', value);
};
j$.isA_ = function(typeName, value) {
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
};
@@ -788,6 +792,10 @@ getJasmineRequireObj().Env = function(j$) {
reporter.provideFallbackReporter(reporterToAdd);
};
this.clearReporters = function() {
reporter.clearReporters();
};
var spyRegistry = new j$.SpyRegistry({currentSpies: function() {
if(!currentRunnable()) {
throw new Error('Spies must be created in a before function or a spec');
@@ -1428,7 +1436,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
function runScheduledFunctions(endTime, tickDate) {
tickDate = tickDate || function() {};
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
tickDate(endTime);
tickDate(endTime - currentTime);
return;
}
@@ -1455,6 +1463,11 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
// scheduled in a funcToRun from forcing an extra iteration
currentTime !== endTime &&
scheduledLookup[0] <= endTime);
// ran out of functions to call, but still time left on the clock
if (currentTime !== endTime) {
tickDate(endTime - currentTime);
}
}
}
@@ -2008,11 +2021,14 @@ getJasmineRequireObj().ReportDispatcher = function() {
this.addReporter = function(reporter) {
reporters.push(reporter);
};
this.provideFallbackReporter = function(reporter) {
fallbackReporter = reporter;
};
this.clearReporters = function() {
reporters = [];
};
return this;
@@ -2088,7 +2104,9 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
};
} else {
restoreStrategy = function() {
delete obj[methodName];
if (!delete obj[methodName]) {
obj[methodName] = originalMethod;
}
};
}
@@ -2113,7 +2131,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
return SpyRegistry;
};
getJasmineRequireObj().SpyStrategy = function() {
getJasmineRequireObj().SpyStrategy = function(j$) {
function SpyStrategy(options) {
options = options || {};
@@ -2160,7 +2178,7 @@ getJasmineRequireObj().SpyStrategy = function() {
};
this.callFake = function(fn) {
if(!(fn instanceof Function)) {
if(!j$.isFunction_(fn)) {
throw new Error('Argument passed to callFake should be a function, got ' + fn);
}
plan = fn;
@@ -2984,16 +3002,20 @@ getJasmineRequireObj().matchersUtil = function(j$) {
}
var extraKeys = [];
for (var i in allKeys) {
if (!allKeys[i].match(/^[0-9]+$/)) {
extraKeys.push(allKeys[i]);
}
if (allKeys.length === 0) {
return allKeys;
}
for (var x = 0; x < allKeys.length; x++) {
if (!allKeys[x].match(/^[0-9]+$/)) {
extraKeys.push(allKeys[x]);
}
}
return extraKeys;
}
}
function has(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
@@ -3629,5 +3651,5 @@ getJasmineRequireObj().interface = function(jasmine, env) {
};
getJasmineRequireObj().version = function() {
return '2.5.0';
return '2.5.2';
};

View File

@@ -4,6 +4,6 @@
#
module Jasmine
module Core
VERSION = "2.5.0"
VERSION = "2.5.2"
end
end

View File

@@ -1,7 +1,7 @@
{
"name": "jasmine-core",
"license": "MIT",
"version": "2.5.0",
"version": "2.5.2",
"repository": {
"type": "git",
"url": "https://github.com/jasmine/jasmine.git"

19
release_notes/2.5.1.md Normal file
View File

@@ -0,0 +1,19 @@
# Jasmine 2.5.1 Release Notes
## Pull Requests & Issues
* fallback on assignment when a spy cannot be deleted
- Merges [#1193](https://github.com/jasmine/jasmine/issues/1193) from @seanparmlee
- Fixes [#1189](https://github.com/jasmine/jasmine/issues/1189)
* Fix issue with equality of Arrays in PhantomJS
- Merges [#1192](https://github.com/jasmine/jasmine/issues/1192) from @logankd
- Fixes [#1188](https://github.com/jasmine/jasmine/issues/1188)
* Properly tick date along with clock
- Fixes [#1190](https://github.com/jasmine/jasmine/issues/1190)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

14
release_notes/2.5.2.md Normal file
View File

@@ -0,0 +1,14 @@
# Jasmine 2.5.2 Release Notes
## Pull Requests & Issues
* Allow currently registered reporters to be cleared
- [jasmine/jasmine-npm#88](https://github.com/jasmine/jasmine-npm/issues/88)
* Use `isFunction` to check for functionness in `callFake`
- Fixes [#1191](https://github.com/jasmine/jasmine/issues/1191)
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

View File

@@ -666,9 +666,17 @@ describe("Clock (acceptance)", function() {
var pushCurrentTime = function() { actualTimes.push(global.Date().getTime()); };
delayedFunctionScheduler.scheduleFunction(pushCurrentTime);
delayedFunctionScheduler.scheduleFunction(pushCurrentTime, 1);
delayedFunctionScheduler.scheduleFunction(pushCurrentTime, 3);
clock.tick(1);
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 1);
expect(actualTimes).toEqual([baseTime.getTime(), baseTime.getTime() + 1]);
clock.tick(3);
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 4);
clock.tick(1);
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 5);
expect(actualTimes).toEqual([baseTime.getTime(), baseTime.getTime() + 1, baseTime.getTime() + 3]);
})
});

View File

@@ -45,7 +45,6 @@ describe("ReportDispatcher", function() {
dispatcher.provideFallbackReporter(reporter);
dispatcher.foo(123, 456);
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
});
it("does not call fallback reporting methods when another report is provided", function() {
@@ -59,6 +58,22 @@ describe("ReportDispatcher", function() {
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456);
});
it("allows registered reporters to be cleared", function() {
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']),
reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
dispatcher.addReporter(reporter1);
dispatcher.foo(123);
expect(reporter1.foo).toHaveBeenCalledWith(123);
dispatcher.clearReporters();
dispatcher.addReporter(reporter2);
dispatcher.bar(456);
expect(reporter1.bar).not.toHaveBeenCalled();
expect(reporter2.bar).toHaveBeenCalledWith(456);
});
});

View File

@@ -127,6 +127,29 @@ describe("SpyRegistry", function() {
expect(subject.hasOwnProperty('spiedFunc')).toBe(false);
expect(subject.spiedFunc).toBe(originalFunction);
})
});
it("restores the original function when it\'s inherited and cannot be deleted", function() {
// IE 8 doesn't support `Object.create` or `Object.defineProperty`
if (jasmine.getEnv().ieVersion < 9) { return; }
var spies = [],
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
originalFunction = function() {},
subjectParent = {spiedFunc: originalFunction};
var subject = Object.create(subjectParent);
spyRegistry.spyOn(subject, 'spiedFunc');
// simulate a spy that cannot be deleted
Object.defineProperty(subject, 'spiedFunc', {
configurable: false
});
spyRegistry.clearSpies();
expect(jasmineUnderTest.isSpy(subject.spiedFunc)).toBe(false);
});
});
});

View File

@@ -94,14 +94,14 @@ describe("SpyStrategy", function() {
it('throws an error when a non-function is passed to callFake strategy', function() {
var originalFn = jasmine.createSpy('original'),
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
invalidFakes = [5, 'foo', {}, true, false, null, void 0, new Date(), /.*/];
for (var i=0; i<invalidFakes.length; i++) {
var invalidFake = invalidFakes[i],
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn});
spyOn(jasmineUnderTest, 'isFunction_').and.returnValue(false);
expect(function() {spyStrategy.callFake(invalidFake);}).toThrowError('Argument passed to callFake should be a function, got ' + invalidFake);
}
expect(function () {
spyStrategy.callFake(function() {});
}).toThrowError(/^Argument passed to callFake should be a function, got/);
});
it("allows a return to plan stubbing after another strategy", function() {

View File

@@ -23,4 +23,5 @@ spec_files:
- '!npmPackage/**/*'
spec_dir: spec
random: true
spec_helper: spec/support/jasmine_helper.rb

View File

@@ -0,0 +1,3 @@
Jasmine.configure do |config|
config.prevent_phantom_js_auto_install = true
end

View File

@@ -116,7 +116,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
function runScheduledFunctions(endTime, tickDate) {
tickDate = tickDate || function() {};
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
tickDate(endTime);
tickDate(endTime - currentTime);
return;
}
@@ -143,6 +143,11 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
// scheduled in a funcToRun from forcing an extra iteration
currentTime !== endTime &&
scheduledLookup[0] <= endTime);
// ran out of functions to call, but still time left on the clock
if (currentTime !== endTime) {
tickDate(endTime - currentTime);
}
}
}

View File

@@ -278,6 +278,10 @@ getJasmineRequireObj().Env = function(j$) {
reporter.provideFallbackReporter(reporterToAdd);
};
this.clearReporters = function() {
reporter.clearReporters();
};
var spyRegistry = new j$.SpyRegistry({currentSpies: function() {
if(!currentRunnable()) {
throw new Error('Spies must be created in a before function or a spec');

View File

@@ -18,11 +18,14 @@ getJasmineRequireObj().ReportDispatcher = function() {
this.addReporter = function(reporter) {
reporters.push(reporter);
};
this.provideFallbackReporter = function(reporter) {
fallbackReporter = reporter;
};
this.clearReporters = function() {
reporters = [];
};
return this;

View File

@@ -53,7 +53,9 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
};
} else {
restoreStrategy = function() {
delete obj[methodName];
if (!delete obj[methodName]) {
obj[methodName] = originalMethod;
}
};
}

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().SpyStrategy = function() {
getJasmineRequireObj().SpyStrategy = function(j$) {
function SpyStrategy(options) {
options = options || {};
@@ -45,7 +45,7 @@ getJasmineRequireObj().SpyStrategy = function() {
};
this.callFake = function(fn) {
if(!(fn instanceof Function)) {
if(!j$.isFunction_(fn)) {
throw new Error('Argument passed to callFake should be a function, got ' + fn);
}
plan = fn;

View File

@@ -29,6 +29,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return j$.isA_('Number', value);
};
j$.isFunction_ = function(value) {
return j$.isA_('Function', value);
};
j$.isA_ = function(typeName, value) {
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
};

View File

@@ -223,16 +223,20 @@ getJasmineRequireObj().matchersUtil = function(j$) {
}
var extraKeys = [];
for (var i in allKeys) {
if (!allKeys[i].match(/^[0-9]+$/)) {
extraKeys.push(allKeys[i]);
}
if (allKeys.length === 0) {
return allKeys;
}
for (var x = 0; x < allKeys.length; x++) {
if (!allKeys[x].match(/^[0-9]+$/)) {
extraKeys.push(allKeys[x]);
}
}
return extraKeys;
}
}
function has(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}

View File

@@ -45,7 +45,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
j$.ReportDispatcher = jRequire.ReportDispatcher();
j$.Spec = jRequire.Spec(j$);
j$.SpyRegistry = jRequire.SpyRegistry(j$);
j$.SpyStrategy = jRequire.SpyStrategy();
j$.SpyStrategy = jRequire.SpyStrategy(j$);
j$.StringMatching = jRequire.StringMatching(j$);
j$.Suite = jRequire.Suite(j$);
j$.Timer = jRequire.Timer();