konacha-chai-matchers 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -5
- data/lib/konacha-chai-matchers/version.rb +1 -1
- data/vendor/assets/javascripts/chai-backbone.js +13 -6
- data/vendor/assets/javascripts/chai-changes.js +198 -166
- data/vendor/assets/javascripts/chai-jquery.js +18 -13
- data/vendor/assets/javascripts/sinon-chai.js +1 -0
- data/vendor/assets/javascripts/sinon.js +37 -4
- metadata +4 -4
data/README.md
CHANGED
@@ -21,11 +21,11 @@ Usage
|
|
21
21
|
|
22
22
|
Example:
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
#= require sinon
|
25
|
+
#= require chai-changes
|
26
|
+
#= require js-factories
|
27
|
+
#= require chai-backbone
|
28
|
+
#= require chai-jquery
|
29
29
|
|
30
30
|
Contribution
|
31
31
|
------------
|
@@ -1,3 +1,4 @@
|
|
1
|
+
// Generated by CoffeeScript 1.3.3
|
1
2
|
(function() {
|
2
3
|
|
3
4
|
(function(chaiBackbone) {
|
@@ -16,7 +17,9 @@
|
|
16
17
|
flag = utils.flag;
|
17
18
|
chai.Assertion.addMethod('trigger', function(trigger, options) {
|
18
19
|
var definedActions;
|
19
|
-
if (options == null)
|
20
|
+
if (options == null) {
|
21
|
+
options = {};
|
22
|
+
}
|
20
23
|
definedActions = flag(this, 'whenActions') || [];
|
21
24
|
definedActions.push({
|
22
25
|
negate: flag(this, 'negate'),
|
@@ -28,7 +31,7 @@
|
|
28
31
|
var negate, _ref;
|
29
32
|
negate = flag(context, 'negate');
|
30
33
|
flag(context, 'negate', this.negate);
|
31
|
-
context.assert(this.callback.
|
34
|
+
context.assert(this.callback.called, "expected to trigger " + trigger, "expected not to trigger " + trigger);
|
32
35
|
if (options["with"] != null) {
|
33
36
|
context.assert((_ref = this.callback).calledWith.apply(_ref, options["with"]), "expected trigger to be called with " + (inspect(options["with"])) + ", but was called with " + (inspect(this.callback.args[0])) + ".", "expected trigger not to be called with " + (inspect(options["with"])) + ", but was");
|
34
37
|
}
|
@@ -42,7 +45,9 @@
|
|
42
45
|
});
|
43
46
|
routeTo = function(router, methodName, options) {
|
44
47
|
var consideredRouter, current_history, route, spy, _i, _len, _ref;
|
45
|
-
if (options == null)
|
48
|
+
if (options == null) {
|
49
|
+
options = {};
|
50
|
+
}
|
46
51
|
current_history = Backbone.history;
|
47
52
|
Backbone.history = new Backbone.History;
|
48
53
|
spy = sinon.spy(router, methodName);
|
@@ -63,8 +68,8 @@
|
|
63
68
|
Backbone.history = current_history;
|
64
69
|
router[methodName].restore();
|
65
70
|
this.assert(spy.calledOnce, "expected `" + route + "` to route to " + methodName, "expected `" + route + "` not to route to " + methodName);
|
66
|
-
if (options
|
67
|
-
return this.assert(spy.calledWith.apply(spy, options
|
71
|
+
if (options["arguments"] != null) {
|
72
|
+
return this.assert(spy.calledWith.apply(spy, options["arguments"]), "expected `" + methodName + "` to be called with " + (inspect(options["arguments"])) + ", but was called with " + (inspect(spy.args[0])) + " instead", "expected `" + methodName + "` not to be called with " + (inspect(options["arguments"])) + ", but was");
|
68
73
|
}
|
69
74
|
};
|
70
75
|
chai.Assertion.overwriteProperty('to', function(_super) {
|
@@ -90,7 +95,9 @@
|
|
90
95
|
},
|
91
96
|
after: function(context) {
|
92
97
|
object[methodName] = this.originalMethod;
|
93
|
-
if (typeof object.delegateEvents === "function")
|
98
|
+
if (typeof object.delegateEvents === "function") {
|
99
|
+
object.delegateEvents();
|
100
|
+
}
|
94
101
|
return context.assert(this.spy.callCount > 0, this.spy.printf("expected %n to have been called at least once"), this.spy.printf("expected %n to not have been called"));
|
95
102
|
}
|
96
103
|
});
|
@@ -1,173 +1,205 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return module.exports = chaiChanges;
|
4
|
-
} else if (typeof define === "function" && define.amd) {
|
5
|
-
return define(function() {
|
6
|
-
return chaiChanges;
|
7
|
-
});
|
8
|
-
} else {
|
9
|
-
return chai.use(chaiChanges);
|
10
|
-
}
|
11
|
-
})(function(chai, utils) {
|
12
|
-
var changeBy, changeByAssert, changeFrom, changeFromAssert, changeFromBeginAssert, changeTo, changeToAssert, changeToBeginAssert, flag, formatFunction, inspect, noChangeAssert;
|
13
|
-
inspect = utils.inspect;
|
14
|
-
flag = utils.flag;
|
15
|
-
/*
|
16
|
-
#
|
17
|
-
# Changes Matchers
|
18
|
-
#
|
19
|
-
*/
|
1
|
+
// Generated by CoffeeScript 1.3.3
|
2
|
+
(function() {
|
20
3
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
val();
|
31
|
-
_results = [];
|
32
|
-
for (_j = 0, _len1 = definedActions.length; _j < _len1; _j++) {
|
33
|
-
action = definedActions[_j];
|
34
|
-
_results.push(typeof action.after === "function" ? action.after(this) : void 0);
|
35
|
-
}
|
36
|
-
return _results;
|
37
|
-
});
|
38
|
-
noChangeAssert = function(context) {
|
39
|
-
var endValue, negate, object, relevant, result, startValue;
|
40
|
-
relevant = flag(context, 'no-change');
|
41
|
-
if (!relevant) {
|
42
|
-
return;
|
4
|
+
(function(chaiChanges) {
|
5
|
+
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
|
6
|
+
return module.exports = chaiChanges;
|
7
|
+
} else if (typeof define === "function" && define.amd) {
|
8
|
+
return define(function() {
|
9
|
+
return chaiChanges;
|
10
|
+
});
|
11
|
+
} else {
|
12
|
+
return chai.use(chaiChanges);
|
43
13
|
}
|
44
|
-
|
45
|
-
flag
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
changeFromAssert = function(context) {
|
98
|
-
var endValue, negate, object, result, startValue;
|
99
|
-
negate = flag(context, 'negate');
|
100
|
-
flag(context, 'negate', this.negate);
|
101
|
-
object = flag(context, 'object');
|
102
|
-
startValue = flag(context, 'changeStart');
|
103
|
-
endValue = object();
|
104
|
-
result = !utils.eql(startValue, endValue);
|
105
|
-
if (negate) {
|
106
|
-
result = !result;
|
107
|
-
}
|
108
|
-
context.assert(result, "expected `" + (formatFunction(object)) + "` to change from " + (utils.inspect(this.expectedStartValue)) + ", but it did not change", "not supported");
|
109
|
-
return flag(context, 'negate', negate);
|
110
|
-
};
|
111
|
-
chai.Assertion.addProperty('change', function() {
|
112
|
-
var definedActions;
|
113
|
-
flag(this, 'no-change', true);
|
114
|
-
definedActions = flag(this, 'whenActions') || [];
|
115
|
-
definedActions.push({
|
116
|
-
negate: flag(this, 'negate'),
|
117
|
-
before: function(context) {
|
118
|
-
var startValue;
|
119
|
-
startValue = flag(context, 'object')();
|
120
|
-
return flag(context, 'changeStart', startValue);
|
121
|
-
},
|
122
|
-
after: noChangeAssert
|
14
|
+
})(function(chai, utils) {
|
15
|
+
var changeBy, changeByAssert, changeFrom, changeFromAssert, changeFromBeginAssert, changeTo, changeToAssert, changeToBeginAssert, flag, formatFunction, inspect, noChangeAssert;
|
16
|
+
inspect = utils.inspect;
|
17
|
+
flag = utils.flag;
|
18
|
+
/*
|
19
|
+
#
|
20
|
+
# Changes Matchers
|
21
|
+
#
|
22
|
+
*/
|
23
|
+
|
24
|
+
chai.Assertion.addMethod('when', function(val, options) {
|
25
|
+
var action, definedActions, done, _i, _j, _len, _len1, _results,
|
26
|
+
_this = this;
|
27
|
+
if (options == null) {
|
28
|
+
options = {};
|
29
|
+
}
|
30
|
+
definedActions = flag(this, 'whenActions') || [];
|
31
|
+
for (_i = 0, _len = definedActions.length; _i < _len; _i++) {
|
32
|
+
action = definedActions[_i];
|
33
|
+
if (typeof action.before === "function") {
|
34
|
+
action.before(this);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
if (val.then != null) {
|
38
|
+
done = options != null ? options.notify : void 0;
|
39
|
+
if (done == null) {
|
40
|
+
done = function() {};
|
41
|
+
}
|
42
|
+
return val.then(function() {
|
43
|
+
var _j, _len1;
|
44
|
+
try {
|
45
|
+
for (_j = 0, _len1 = definedActions.length; _j < _len1; _j++) {
|
46
|
+
action = definedActions[_j];
|
47
|
+
if (typeof action.after === "function") {
|
48
|
+
action.after(_this);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return done();
|
52
|
+
} catch (error) {
|
53
|
+
return done(error);
|
54
|
+
}
|
55
|
+
});
|
56
|
+
} else {
|
57
|
+
if (typeof val === "function") {
|
58
|
+
val();
|
59
|
+
}
|
60
|
+
_results = [];
|
61
|
+
for (_j = 0, _len1 = definedActions.length; _j < _len1; _j++) {
|
62
|
+
action = definedActions[_j];
|
63
|
+
_results.push(typeof action.after === "function" ? action.after(this) : void 0);
|
64
|
+
}
|
65
|
+
return _results;
|
66
|
+
}
|
123
67
|
});
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
68
|
+
noChangeAssert = function(context) {
|
69
|
+
var endValue, negate, object, relevant, result, startValue;
|
70
|
+
relevant = flag(context, 'no-change');
|
71
|
+
if (!relevant) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
negate = flag(context, 'negate');
|
75
|
+
flag(context, 'negate', this.negate);
|
76
|
+
object = flag(context, 'object');
|
77
|
+
startValue = flag(context, 'changeStart');
|
78
|
+
endValue = object();
|
79
|
+
result = !utils.eql(endValue, startValue);
|
80
|
+
context.assert(result, "expected `" + (formatFunction(object)) + "` to change, but it stayed " + (utils.inspect(startValue)), "expected `" + (formatFunction(object)) + "` not to change, but it changed from " + (utils.inspect(startValue)) + " to " + (utils.inspect(endValue)));
|
81
|
+
return flag(context, 'negate', negate);
|
82
|
+
};
|
83
|
+
changeByAssert = function(context) {
|
84
|
+
var actualDelta, endValue, negate, object, startValue;
|
85
|
+
negate = flag(context, 'negate');
|
86
|
+
flag(context, 'negate', this.negate);
|
87
|
+
object = flag(context, 'object');
|
88
|
+
startValue = flag(context, 'changeStart');
|
89
|
+
endValue = object();
|
90
|
+
actualDelta = endValue - startValue;
|
91
|
+
context.assert(this.expectedDelta === actualDelta, "expected `" + (formatFunction(object)) + "` to change by " + this.expectedDelta + ", but it changed by " + actualDelta, "expected `" + (formatFunction(object)) + "` not to change by " + this.expectedDelta + ", but it did");
|
92
|
+
return flag(context, 'negate', negate);
|
93
|
+
};
|
94
|
+
changeToBeginAssert = function(context) {
|
95
|
+
var negate, object, result, startValue;
|
96
|
+
negate = flag(context, 'negate');
|
97
|
+
flag(context, 'negate', this.negate);
|
98
|
+
object = flag(context, 'object');
|
99
|
+
startValue = object();
|
100
|
+
result = !utils.eql(startValue, this.expectedEndValue);
|
101
|
+
if (negate) {
|
102
|
+
result = !result;
|
103
|
+
}
|
104
|
+
context.assert(result, "expected `" + (formatFunction(object)) + "` to change to " + (utils.inspect(this.expectedEndValue)) + ", but it was already " + (utils.inspect(startValue)), "not supported");
|
105
|
+
return flag(context, 'negate', negate);
|
106
|
+
};
|
107
|
+
changeToAssert = function(context) {
|
108
|
+
var endValue, negate, object, result;
|
109
|
+
negate = flag(context, 'negate');
|
110
|
+
flag(context, 'negate', this.negate);
|
111
|
+
object = flag(context, 'object');
|
112
|
+
endValue = object();
|
113
|
+
result = utils.eql(endValue, this.expectedEndValue);
|
114
|
+
context.assert(result, "expected `" + (formatFunction(object)) + "` to change to " + (utils.inspect(this.expectedEndValue)) + ", but it changed to " + (utils.inspect(endValue)), "expected `" + (formatFunction(object)) + "` not to change to " + (utils.inspect(this.expectedEndValue)) + ", but it did");
|
115
|
+
return flag(context, 'negate', negate);
|
116
|
+
};
|
117
|
+
changeFromBeginAssert = function(context) {
|
118
|
+
var negate, object, result, startValue;
|
119
|
+
negate = flag(context, 'negate');
|
120
|
+
flag(context, 'negate', this.negate);
|
121
|
+
object = flag(context, 'object');
|
122
|
+
startValue = object();
|
123
|
+
result = utils.eql(startValue, this.expectedStartValue);
|
124
|
+
context.assert(result, "expected the change of `" + (formatFunction(object)) + "` to start from " + (utils.inspect(this.expectedStartValue)) + ", but it started from " + (utils.inspect(startValue)), "expected the change of `" + (formatFunction(object)) + "` not to start from " + (utils.inspect(this.expectedStartValue)) + ", but it did");
|
125
|
+
return flag(context, 'negate', negate);
|
126
|
+
};
|
127
|
+
changeFromAssert = function(context) {
|
128
|
+
var endValue, negate, object, result, startValue;
|
129
|
+
negate = flag(context, 'negate');
|
130
|
+
flag(context, 'negate', this.negate);
|
131
|
+
object = flag(context, 'object');
|
132
|
+
startValue = flag(context, 'changeStart');
|
133
|
+
endValue = object();
|
134
|
+
result = !utils.eql(startValue, endValue);
|
135
|
+
if (negate) {
|
136
|
+
result = !result;
|
137
|
+
}
|
138
|
+
context.assert(result, "expected `" + (formatFunction(object)) + "` to change from " + (utils.inspect(this.expectedStartValue)) + ", but it did not change", "not supported");
|
139
|
+
return flag(context, 'negate', negate);
|
140
|
+
};
|
141
|
+
chai.Assertion.addProperty('change', function() {
|
142
|
+
var definedActions;
|
143
|
+
flag(this, 'no-change', true);
|
144
|
+
definedActions = flag(this, 'whenActions') || [];
|
145
|
+
definedActions.push({
|
146
|
+
negate: flag(this, 'negate'),
|
147
|
+
before: function(context) {
|
148
|
+
var startValue;
|
149
|
+
startValue = flag(context, 'object')();
|
150
|
+
return flag(context, 'changeStart', startValue);
|
151
|
+
},
|
152
|
+
after: noChangeAssert
|
153
|
+
});
|
154
|
+
return flag(this, 'whenActions', definedActions);
|
137
155
|
});
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
156
|
+
formatFunction = function(func) {
|
157
|
+
return func.toString().replace(/^\s*function \(\) {\s*/, '').replace(/\s+}$/, '').replace(/\s*return\s*/, '');
|
158
|
+
};
|
159
|
+
changeBy = function(delta) {
|
160
|
+
var definedActions;
|
161
|
+
flag(this, 'no-change', false);
|
162
|
+
definedActions = flag(this, 'whenActions') || [];
|
163
|
+
definedActions.push({
|
164
|
+
negate: flag(this, 'negate'),
|
165
|
+
expectedDelta: delta,
|
166
|
+
after: changeByAssert
|
167
|
+
});
|
168
|
+
return flag(this, 'whenActions', definedActions);
|
169
|
+
};
|
170
|
+
chai.Assertion.addChainableMethod('by', changeBy, function() {
|
171
|
+
return this;
|
152
172
|
});
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
173
|
+
changeTo = function(endValue) {
|
174
|
+
var definedActions;
|
175
|
+
flag(this, 'no-change', false);
|
176
|
+
definedActions = flag(this, 'whenActions') || [];
|
177
|
+
definedActions.push({
|
178
|
+
negate: flag(this, 'negate'),
|
179
|
+
expectedEndValue: endValue,
|
180
|
+
before: changeToBeginAssert,
|
181
|
+
after: changeToAssert
|
182
|
+
});
|
183
|
+
return flag(this, 'whenActions', definedActions);
|
184
|
+
};
|
185
|
+
chai.Assertion.addChainableMethod('to', changeTo, function() {
|
186
|
+
return this;
|
187
|
+
});
|
188
|
+
changeFrom = function(startValue) {
|
189
|
+
var definedActions;
|
190
|
+
flag(this, 'no-change', false);
|
191
|
+
definedActions = flag(this, 'whenActions') || [];
|
192
|
+
definedActions.push({
|
193
|
+
negate: flag(this, 'negate'),
|
194
|
+
expectedStartValue: startValue,
|
195
|
+
before: changeFromBeginAssert,
|
196
|
+
after: changeFromAssert
|
197
|
+
});
|
198
|
+
return flag(this, 'whenActions', definedActions);
|
199
|
+
};
|
200
|
+
return chai.Assertion.addChainableMethod('from', changeFrom, function() {
|
201
|
+
return this;
|
167
202
|
});
|
168
|
-
return flag(this, 'whenActions', definedActions);
|
169
|
-
};
|
170
|
-
return chai.Assertion.addChainableMethod('from', changeFrom, function() {
|
171
|
-
return this;
|
172
203
|
});
|
173
|
-
|
204
|
+
|
205
|
+
}).call(this);
|
@@ -5,19 +5,24 @@
|
|
5
5
|
module.exports = chaiJquery;
|
6
6
|
} else if (typeof define === "function" && define.amd) {
|
7
7
|
// AMD
|
8
|
-
define(function () {
|
9
|
-
return
|
8
|
+
define(['jquery'], function ($) {
|
9
|
+
return function (chai, utils) {
|
10
|
+
return chaiJquery(chai, utils, $);
|
11
|
+
};
|
10
12
|
});
|
11
13
|
} else {
|
12
14
|
// Other environment (usually <script> tag): plug in to global chai instance directly.
|
13
|
-
chai.use(
|
15
|
+
chai.use(function (chai, utils) {
|
16
|
+
return chaiJquery(chai, utils, jQuery);
|
17
|
+
});
|
14
18
|
}
|
15
|
-
}(function (chai, utils) {
|
19
|
+
}(function (chai, utils, $) {
|
16
20
|
var inspect = utils.inspect,
|
17
21
|
flag = utils.flag;
|
22
|
+
$ = $ || jQuery;
|
18
23
|
|
19
|
-
|
20
|
-
var el =
|
24
|
+
$.fn.inspect = function (depth) {
|
25
|
+
var el = $('<div />').append(this.clone());
|
21
26
|
if (depth !== undefined) {
|
22
27
|
var children = el.children();
|
23
28
|
while (depth-- > 0)
|
@@ -114,7 +119,7 @@
|
|
114
119
|
);
|
115
120
|
});
|
116
121
|
|
117
|
-
|
122
|
+
$.each(['visible', 'hidden', 'selected', 'checked', 'disabled'], function (i, attr) {
|
118
123
|
chai.Assertion.addProperty(attr, function () {
|
119
124
|
this.assert(
|
120
125
|
flag(this, 'object').is(':' + attr)
|
@@ -126,7 +131,7 @@
|
|
126
131
|
chai.Assertion.overwriteProperty('exist', function (_super) {
|
127
132
|
return function () {
|
128
133
|
var obj = flag(this, 'object');
|
129
|
-
if (obj instanceof
|
134
|
+
if (obj instanceof $) {
|
130
135
|
this.assert(
|
131
136
|
obj.length > 0
|
132
137
|
, 'expected ' + inspect(obj.selector) + ' to exist'
|
@@ -140,7 +145,7 @@
|
|
140
145
|
chai.Assertion.overwriteProperty('empty', function (_super) {
|
141
146
|
return function () {
|
142
147
|
var obj = flag(this, 'object');
|
143
|
-
if (obj instanceof
|
148
|
+
if (obj instanceof $) {
|
144
149
|
this.assert(
|
145
150
|
obj.is(':empty')
|
146
151
|
, 'expected #{this} to be empty'
|
@@ -155,7 +160,7 @@
|
|
155
160
|
return function () {
|
156
161
|
var be = function (selector) {
|
157
162
|
var obj = flag(this, 'object');
|
158
|
-
if (obj instanceof
|
163
|
+
if (obj instanceof $) {
|
159
164
|
this.assert(
|
160
165
|
obj.is(selector)
|
161
166
|
, 'expected #{this} to be #{exp}'
|
@@ -174,7 +179,7 @@
|
|
174
179
|
chai.Assertion.overwriteMethod('match', function (_super) {
|
175
180
|
return function (selector) {
|
176
181
|
var obj = flag(this, 'object');
|
177
|
-
if (obj instanceof
|
182
|
+
if (obj instanceof $) {
|
178
183
|
this.assert(
|
179
184
|
obj.is(selector)
|
180
185
|
, 'expected #{this} to match #{exp}'
|
@@ -192,7 +197,7 @@
|
|
192
197
|
_super.call(this);
|
193
198
|
var contain = function (text) {
|
194
199
|
var obj = flag(this, 'object');
|
195
|
-
if (obj instanceof
|
200
|
+
if (obj instanceof $) {
|
196
201
|
this.assert(
|
197
202
|
obj.is(':contains(\'' + text + '\')')
|
198
203
|
, 'expected #{this} to contain #{exp}'
|
@@ -211,7 +216,7 @@
|
|
211
216
|
chai.Assertion.overwriteProperty('have', function (_super) {
|
212
217
|
return function () {
|
213
218
|
var obj = flag(this, 'object');
|
214
|
-
if (obj instanceof
|
219
|
+
if (obj instanceof $) {
|
215
220
|
var have = function (selector) {
|
216
221
|
this.assert(
|
217
222
|
// Using find() rather than has() to work around a jQuery bug:
|
@@ -101,6 +101,7 @@
|
|
101
101
|
sinonMethod("calledOn", "been called with %1 as this", ", but it was called with %t instead");
|
102
102
|
sinonMethod("calledWith", "been called with arguments %*", "%C");
|
103
103
|
sinonMethod("calledWithExactly", "been called with exact arguments %*", "%C");
|
104
|
+
sinonMethod("calledWithMatch", "been called with arguments matching %*", "%C");
|
104
105
|
sinonMethod("returned", "returned %1");
|
105
106
|
exceptionalSinonMethod("thrown", "threw", "thrown %1");
|
106
107
|
}));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Sinon.JS 1.5.
|
2
|
+
* Sinon.JS 1.5.2, 2013/01/06
|
3
3
|
*
|
4
4
|
* @author Christian Johansen (christian@cjohansen.no)
|
5
5
|
* @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
|
@@ -326,6 +326,13 @@ var sinon = (function (buster) {
|
|
326
326
|
}
|
327
327
|
var string = Object.prototype.toString.call(value);
|
328
328
|
return string.substring(8, string.length - 1).toLowerCase();
|
329
|
+
},
|
330
|
+
|
331
|
+
createStubInstance: function (constructor) {
|
332
|
+
if (typeof constructor !== "function") {
|
333
|
+
throw new TypeError("The constructor should be a function.");
|
334
|
+
}
|
335
|
+
return sinon.stub(sinon.create(constructor.prototype));
|
329
336
|
}
|
330
337
|
};
|
331
338
|
|
@@ -949,7 +956,11 @@ var sinon = (function (buster) {
|
|
949
956
|
var calls = [];
|
950
957
|
|
951
958
|
for (var i = 0, l = spy.callCount; i < l; ++i) {
|
952
|
-
|
959
|
+
var stringifiedCall = " " + spy.getCall(i).toString();
|
960
|
+
if (/\n/.test(calls[i - 1])) {
|
961
|
+
stringifiedCall = "\n" + stringifiedCall;
|
962
|
+
}
|
963
|
+
push.call(calls, stringifiedCall);
|
953
964
|
}
|
954
965
|
|
955
966
|
return calls.length > 0 ? "\n" + calls.join("\n") : "";
|
@@ -1346,12 +1357,23 @@ var sinon = (function (buster) {
|
|
1346
1357
|
return functionStub;
|
1347
1358
|
},
|
1348
1359
|
|
1349
|
-
|
1350
|
-
|
1360
|
+
resetBehavior: function () {
|
1361
|
+
var i;
|
1362
|
+
|
1351
1363
|
this.callArgAts = [];
|
1352
1364
|
this.callbackArguments = [];
|
1353
1365
|
this.callbackContexts = [];
|
1354
1366
|
this.callArgProps = [];
|
1367
|
+
|
1368
|
+
delete this.returnValue;
|
1369
|
+
delete this.returnArgAt;
|
1370
|
+
this.returnThis = false;
|
1371
|
+
|
1372
|
+
if (this.fakes) {
|
1373
|
+
for (i = 0; i < this.fakes.length; i++) {
|
1374
|
+
this.fakes[i].resetBehavior();
|
1375
|
+
}
|
1376
|
+
}
|
1355
1377
|
},
|
1356
1378
|
|
1357
1379
|
returns: function returns(value) {
|
@@ -3057,6 +3079,15 @@ sinon.fakeServer = (function () {
|
|
3057
3079
|
return false;
|
3058
3080
|
}
|
3059
3081
|
|
3082
|
+
function log(response, request) {
|
3083
|
+
var str;
|
3084
|
+
|
3085
|
+
str = "Request:\n" + sinon.format(request) + "\n\n";
|
3086
|
+
str += "Response:\n" + sinon.format(response) + "\n\n";
|
3087
|
+
|
3088
|
+
sinon.log(str);
|
3089
|
+
}
|
3090
|
+
|
3060
3091
|
return {
|
3061
3092
|
create: function () {
|
3062
3093
|
var server = create(this);
|
@@ -3163,6 +3194,8 @@ sinon.fakeServer = (function () {
|
|
3163
3194
|
}
|
3164
3195
|
|
3165
3196
|
if (request.readyState != 4) {
|
3197
|
+
log(response, request);
|
3198
|
+
|
3166
3199
|
request.respond(response[0], response[1], response[2]);
|
3167
3200
|
}
|
3168
3201
|
} catch (e) {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konacha-chai-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A set of Chai.js libraries ready to use for Konacha
|
15
15
|
email:
|
@@ -55,7 +55,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
55
|
version: '0'
|
56
56
|
segments:
|
57
57
|
- 0
|
58
|
-
hash:
|
58
|
+
hash: 500102349
|
59
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
60
|
none: false
|
61
61
|
requirements:
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
version: '0'
|
65
65
|
segments:
|
66
66
|
- 0
|
67
|
-
hash:
|
67
|
+
hash: 500102349
|
68
68
|
requirements: []
|
69
69
|
rubyforge_project: konacha-chai-matchers
|
70
70
|
rubygems_version: 1.8.15
|