konacha-chai-matchers 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
@@ -319,11 +319,14 @@
|
|
319
319
|
var args = arguments;
|
320
320
|
|
321
321
|
return makeAssertionPromiseToDoAsserter(assertionPromise, baseAssertion, function () {
|
322
|
-
|
322
|
+
// Due to https://github.com/chaijs/chai/commit/514dd6ce466d7b4110b38345e4073d586c017f3f
|
323
|
+
// we can't use `propertyDescriptor.get().apply`.
|
324
|
+
return Function.prototype.apply.call(propertyDescriptor.get(), assertionPromise, args);
|
323
325
|
});
|
324
326
|
},
|
325
327
|
function () {
|
326
|
-
|
328
|
+
// As above.
|
329
|
+
return Function.prototype.call.call(propertyDescriptor.get, assertionPromise);
|
327
330
|
}
|
328
331
|
);
|
329
332
|
} else {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Generated by CoffeeScript 1.
|
1
|
+
// Generated by CoffeeScript 1.4.0
|
2
2
|
(function() {
|
3
3
|
|
4
4
|
(function(chaiChanges) {
|
@@ -12,15 +12,9 @@
|
|
12
12
|
return chai.use(chaiChanges);
|
13
13
|
}
|
14
14
|
})(function(chai, utils) {
|
15
|
-
var changeBy, changeByAssert, changeFrom, changeFromAssert, changeFromBeginAssert, changeTo, changeToAssert, changeToBeginAssert, flag, formatFunction, inspect, noChangeAssert;
|
15
|
+
var byAtLeast, byAtMost, changeBy, changeByAssert, changeFrom, changeFromAssert, changeFromBeginAssert, changeTo, changeToAssert, changeToBeginAssert, flag, formatFunction, inspect, noChangeAssert;
|
16
16
|
inspect = utils.inspect;
|
17
17
|
flag = utils.flag;
|
18
|
-
/*
|
19
|
-
#
|
20
|
-
# Changes Matchers
|
21
|
-
#
|
22
|
-
*/
|
23
|
-
|
24
18
|
chai.Assertion.addMethod('when', function(val, options) {
|
25
19
|
var action, definedActions, done, isPromise, newPromise, object, promiseCallback, result, _i, _j, _len, _len1,
|
26
20
|
_this = this;
|
@@ -54,8 +48,8 @@
|
|
54
48
|
}
|
55
49
|
return done();
|
56
50
|
} catch (error) {
|
57
|
-
done(
|
58
|
-
throw
|
51
|
+
done(error);
|
52
|
+
throw error;
|
59
53
|
}
|
60
54
|
};
|
61
55
|
newPromise = result.then(promiseCallback, promiseCallback);
|
@@ -67,9 +61,7 @@
|
|
67
61
|
action.after(this);
|
68
62
|
}
|
69
63
|
}
|
70
|
-
flag(this, 'object', result);
|
71
64
|
}
|
72
|
-
flag(this, 'negate', false);
|
73
65
|
return this;
|
74
66
|
});
|
75
67
|
noChangeAssert = function(context) {
|
@@ -160,6 +152,112 @@
|
|
160
152
|
});
|
161
153
|
return flag(this, 'whenActions', definedActions);
|
162
154
|
});
|
155
|
+
chai.Assertion.addProperty('increase', function() {
|
156
|
+
var definedActions;
|
157
|
+
definedActions = flag(this, 'whenActions') || [];
|
158
|
+
definedActions.push({
|
159
|
+
negate: flag(this, 'negate'),
|
160
|
+
before: function(context) {
|
161
|
+
var startValue;
|
162
|
+
startValue = flag(context, 'whenObject')();
|
163
|
+
return flag(context, 'increaseStart', startValue);
|
164
|
+
},
|
165
|
+
after: function(context) {
|
166
|
+
var endValue, negate, object, startValue;
|
167
|
+
object = flag(context, 'whenObject');
|
168
|
+
endValue = object();
|
169
|
+
startValue = flag(context, 'increaseStart');
|
170
|
+
negate = flag(context, 'negate');
|
171
|
+
flag(context, 'negate', this.negate);
|
172
|
+
if (!negate) {
|
173
|
+
context.assert(startValue !== endValue, "expected `" + (formatFunction(object)) + "` to increase, but it did not change", "not supported");
|
174
|
+
}
|
175
|
+
context.assert(startValue < endValue, "expected `" + (formatFunction(object)) + "` to increase, but it decreased by " + (startValue - endValue), "expected `" + (formatFunction(object)) + "` not to increase, but it increased by " + (endValue - startValue));
|
176
|
+
return flag(context, 'negate', negate);
|
177
|
+
}
|
178
|
+
});
|
179
|
+
return flag(this, 'whenActions', definedActions);
|
180
|
+
});
|
181
|
+
chai.Assertion.addProperty('decrease', function() {
|
182
|
+
var definedActions;
|
183
|
+
definedActions = flag(this, 'whenActions') || [];
|
184
|
+
definedActions.push({
|
185
|
+
negate: flag(this, 'negate'),
|
186
|
+
before: function(context) {
|
187
|
+
var startValue;
|
188
|
+
startValue = flag(context, 'whenObject')();
|
189
|
+
return flag(context, 'decreaseStart', startValue);
|
190
|
+
},
|
191
|
+
after: function(context) {
|
192
|
+
var endValue, negate, object, startValue;
|
193
|
+
object = flag(context, 'whenObject');
|
194
|
+
endValue = object();
|
195
|
+
startValue = flag(context, 'decreaseStart');
|
196
|
+
negate = flag(context, 'negate');
|
197
|
+
flag(context, 'negate', this.negate);
|
198
|
+
if (!negate) {
|
199
|
+
context.assert(startValue !== endValue, "expected `" + (formatFunction(object)) + "` to decrease, but it did not change", "not supported");
|
200
|
+
}
|
201
|
+
context.assert(startValue > endValue, "expected `" + (formatFunction(object)) + "` to decrease, but it increased by " + (endValue - startValue), "expected `" + (formatFunction(object)) + "` not to decrease, but it decreased by " + (startValue - endValue));
|
202
|
+
return flag(context, 'negate', negate);
|
203
|
+
}
|
204
|
+
});
|
205
|
+
return flag(this, 'whenActions', definedActions);
|
206
|
+
});
|
207
|
+
byAtLeast = function(amount) {
|
208
|
+
var definedActions;
|
209
|
+
definedActions = flag(this, 'whenActions') || [];
|
210
|
+
definedActions.push({
|
211
|
+
negate: flag(this, 'negate'),
|
212
|
+
before: function(context) {
|
213
|
+
var startValue;
|
214
|
+
startValue = flag(context, 'whenObject')();
|
215
|
+
return flag(context, 'atLeastStart', startValue);
|
216
|
+
},
|
217
|
+
after: function(context) {
|
218
|
+
var difference, endValue, negate, object, startValue;
|
219
|
+
object = flag(context, 'whenObject');
|
220
|
+
endValue = object();
|
221
|
+
startValue = flag(context, 'atLeastStart');
|
222
|
+
negate = flag(context, 'negate');
|
223
|
+
flag(context, 'negate', this.negate);
|
224
|
+
difference = Math.abs(endValue - startValue);
|
225
|
+
context.assert(difference >= amount, "expected `" + (formatFunction(object)) + "` to change by at least " + amount + ", but changed by " + difference, "not supported");
|
226
|
+
return flag(context, 'negate', negate);
|
227
|
+
}
|
228
|
+
});
|
229
|
+
return flag(this, 'whenActions', definedActions);
|
230
|
+
};
|
231
|
+
chai.Assertion.addChainableMethod('atLeast', byAtLeast, function() {
|
232
|
+
return this;
|
233
|
+
});
|
234
|
+
byAtMost = function(amount) {
|
235
|
+
var definedActions;
|
236
|
+
definedActions = flag(this, 'whenActions') || [];
|
237
|
+
definedActions.push({
|
238
|
+
negate: flag(this, 'negate'),
|
239
|
+
before: function(context) {
|
240
|
+
var startValue;
|
241
|
+
startValue = flag(context, 'whenObject')();
|
242
|
+
return flag(context, 'atMostStart', startValue);
|
243
|
+
},
|
244
|
+
after: function(context) {
|
245
|
+
var difference, endValue, negate, object, startValue;
|
246
|
+
object = flag(context, 'whenObject');
|
247
|
+
endValue = object();
|
248
|
+
startValue = flag(context, 'atMostStart');
|
249
|
+
negate = flag(context, 'negate');
|
250
|
+
flag(context, 'negate', this.negate);
|
251
|
+
difference = Math.abs(endValue - startValue);
|
252
|
+
context.assert(difference <= amount, "expected `" + (formatFunction(object)) + "` to change by at most " + amount + ", but changed by " + difference, "not supported");
|
253
|
+
return flag(context, 'negate', negate);
|
254
|
+
}
|
255
|
+
});
|
256
|
+
return flag(this, 'whenActions', definedActions);
|
257
|
+
};
|
258
|
+
chai.Assertion.addChainableMethod('atMost', byAtMost, function() {
|
259
|
+
return this;
|
260
|
+
});
|
163
261
|
formatFunction = function(func) {
|
164
262
|
return func.toString().replace(/^\s*function \(\) {\s*/, '').replace(/\s+}$/, '').replace(/\s*return\s*/, '');
|
165
263
|
};
|
@@ -22,15 +22,14 @@
|
|
22
22
|
var _;
|
23
23
|
|
24
24
|
if (
|
25
|
-
typeof
|
26
|
-
&& typeof
|
27
|
-
&& typeof module === "object"
|
25
|
+
typeof window === "object"
|
26
|
+
&& typeof window._ == "function"
|
28
27
|
) {
|
29
|
-
// server-side
|
30
|
-
_ = require('underscore');
|
31
|
-
} else {
|
32
28
|
// browser-side
|
33
29
|
_ = window._;
|
30
|
+
} else {
|
31
|
+
// server-side
|
32
|
+
_ = require('underscore');
|
34
33
|
}
|
35
34
|
|
36
35
|
// contain => _.where, check _.isEqual
|
metadata
CHANGED
@@ -1,23 +1,28 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: konacha-chai-matchers
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.17
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.0.18
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Matthijs Groen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
12
|
+
|
13
|
+
date: 2013-02-14 00:00:00 Z
|
13
14
|
dependencies: []
|
15
|
+
|
14
16
|
description: A set of Chai.js libraries ready to use for Konacha
|
15
|
-
email:
|
17
|
+
email:
|
16
18
|
- matthijs.groen@gmail.com
|
17
19
|
executables: []
|
20
|
+
|
18
21
|
extensions: []
|
22
|
+
|
19
23
|
extra_rdoc_files: []
|
20
|
-
|
24
|
+
|
25
|
+
files:
|
21
26
|
- .gitignore
|
22
27
|
- .gitmodules
|
23
28
|
- Gemfile
|
@@ -43,29 +48,32 @@ files:
|
|
43
48
|
- vendor/assets/javascripts/mocha-as-promised.js
|
44
49
|
- vendor/assets/javascripts/sinon-chai.js
|
45
50
|
- vendor/assets/javascripts/sinon.js
|
46
|
-
homepage:
|
47
|
-
licenses:
|
51
|
+
homepage: ""
|
52
|
+
licenses:
|
48
53
|
- MIT
|
49
54
|
post_install_message:
|
50
55
|
rdoc_options: []
|
51
|
-
|
56
|
+
|
57
|
+
require_paths:
|
52
58
|
- lib
|
53
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
60
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version:
|
59
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
66
|
none: false
|
61
|
-
requirements:
|
62
|
-
- -
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version:
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
65
71
|
requirements: []
|
72
|
+
|
66
73
|
rubyforge_project: konacha-chai-matchers
|
67
|
-
rubygems_version: 1.8.
|
74
|
+
rubygems_version: 1.8.5
|
68
75
|
signing_key:
|
69
76
|
specification_version: 3
|
70
77
|
summary: Chai.js plugins collection for Konacha
|
71
78
|
test_files: []
|
79
|
+
|