konacha-chai-matchers 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  module Konacha
2
2
  module Chai
3
3
  module Matchers
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
6
6
  end
7
7
  end
@@ -54,30 +54,33 @@
54
54
  };
55
55
  }
56
56
 
57
- var fulfilledAsserter = function () {
58
- var transformedPromise = this._obj.then(
57
+ function fulfilledAsserter() {
58
+ /*jshint validthis:true */
59
+ var assertion = this;
60
+
61
+ var transformedPromise = assertion._obj.then(
59
62
  function (value) {
60
- if (utils.flag(this, "negate")) {
63
+ if (utils.flag(assertion, "negate")) {
61
64
  // If we're negated, `this.assert`'s behavior is actually flipped, so `this.assert(true, ...)` will
62
65
  // throw an error, as desired.
63
- this.assert(true, null, "expected promise to be rejected but it was fulfilled with " +
66
+ assertion.assert(true, null, "expected promise to be rejected but it was fulfilled with " +
64
67
  utils.inspect(value));
65
68
  }
66
69
 
67
70
  return value;
68
- }.bind(this),
71
+ },
69
72
  function (reason) {
70
73
  // If we're in a negated state (i.e. `.not.fulfilled`) then this assertion will get flipped and thus
71
74
  // pass, as desired.
72
- this.assert(false, "expected promise to be fulfilled but it was rejected with " +
75
+ assertion.assert(false, "expected promise to be fulfilled but it was rejected with " +
73
76
  utils.inspect(reason));
74
- }.bind(this)
77
+ }
75
78
  );
76
79
 
77
- return makeAssertionPromise(transformedPromise, this);
78
- };
80
+ return makeAssertionPromise(transformedPromise, assertion);
81
+ }
79
82
 
80
- var rejectedAsserter = function () {
83
+ function rejectedAsserter() {
81
84
  // THIS SHIT IS COMPLICATED. Best illustrated by exhaustive example.
82
85
  ////////////////////////////////////////////////////////////////////
83
86
  // `fulfilledPromise.should.be.rejected`:
@@ -101,27 +104,29 @@
101
104
  // `onOriginalFulfilled` → `this.assert(false, …)` does nothing → fulfills →
102
105
  // `with(xxx)` called → `onTransformedFulfilled` → fulfills
103
106
 
107
+ /*jshint validthis:true */
108
+ var assertion = this;
104
109
  var rejectionReason = null;
105
110
 
106
- var onOriginalFulfilled = function (value) {
107
- this.assert(false, "expected promise to be rejected but it was fulfilled with " + utils.inspect(value));
108
- }.bind(this);
111
+ function onOriginalFulfilled(value) {
112
+ assertion.assert(false, "expected promise to be rejected but it was fulfilled with " + utils.inspect(value));
113
+ }
109
114
 
110
- var onOriginalRejected = function (reason) {
115
+ function onOriginalRejected(reason) {
111
116
  // Store the reason so that `with` can look at it later. Be sure to do this before asserting, since
112
117
  // throwing an error from the assert would cancel the process.
113
118
  rejectionReason = reason;
114
119
 
115
- if (utils.flag(this, "negate")) {
116
- this.assert(true, null, "expected promise to be fulfilled but it was rejected with " +
120
+ if (utils.flag(assertion, "negate")) {
121
+ assertion.assert(true, null, "expected promise to be fulfilled but it was rejected with " +
117
122
  utils.inspect(reason));
118
123
  }
119
124
 
120
125
  // If we didn't throw from the assert, transform rejections into fulfillments, by not re-throwing the
121
126
  // reason.
122
- }.bind(this);
127
+ }
123
128
 
124
- var withMethod = function (Constructor, message) {
129
+ function withMethod(Constructor, message) {
125
130
  var desiredReason = null;
126
131
 
127
132
  if (Constructor instanceof RegExp || typeof Constructor === "string") {
@@ -156,76 +161,80 @@
156
161
  return rejectionReason === desiredReason;
157
162
  }
158
163
 
159
- var onTransformedFulfilled = function () {
160
- if (!utils.flag(this, "negate")) {
164
+ function onTransformedFulfilled() {
165
+ if (!utils.flag(assertion, "negate")) {
161
166
  if (desiredReason) {
162
- this.assert(matchesDesiredReason(),
167
+ assertion.assert(matchesDesiredReason(),
163
168
  null,
164
169
  "expected promise to be rejected with " + utils.inspect(desiredReason) + " but " +
165
170
  "it was rejected with " + utils.inspect(rejectionReason));
166
171
  }
167
172
 
168
173
  if (Constructor) {
169
- this.assert(constructorIsGood(),
174
+ assertion.assert(constructorIsGood(),
170
175
  "expected promise to be rejected with " + Constructor.prototype.name + " but it " +
171
176
  "was rejected with " + utils.inspect(rejectionReason));
172
177
  }
173
178
 
174
179
  if (message) {
175
- this.assert(messageIsGood(),
180
+ assertion.assert(messageIsGood(),
176
181
  "expected promise to be rejected with an error " + messageVerb + " " + message +
177
182
  " but got " + utils.inspect(rejectionReason.message));
178
183
  }
179
184
  }
180
- }.bind(this);
185
+ }
181
186
 
182
- var onTransformedRejected = function () {
183
- if (utils.flag(this, "negate")) {
187
+ function onTransformedRejected() {
188
+ if (utils.flag(assertion, "negate")) {
184
189
  if (desiredReason) {
185
- this.assert(matchesDesiredReason(),
190
+ assertion.assert(matchesDesiredReason(),
186
191
  null,
187
192
  "expected promise to not be rejected with " + utils.inspect(desiredReason));
188
193
  }
189
194
 
190
195
  if (Constructor) {
191
- this.assert(constructorIsGood(),
196
+ assertion.assert(constructorIsGood(),
192
197
  null,
193
198
  "expected promise to not be rejected with " + Constructor.prototype.name);
194
199
  }
195
200
 
196
201
  if (message) {
197
- this.assert(messageIsGood(),
202
+ assertion.assert(messageIsGood(),
198
203
  null,
199
204
  "expected promise to be not be rejected with an error " + messageVerb + " " +
200
205
  message);
201
206
  }
202
207
  } else {
203
208
  if (desiredReason) {
204
- this.assert(false,
209
+ assertion.assert(false,
205
210
  "expected promise to be rejected with " + utils.inspect(desiredReason) +
206
211
  " but it was fulfilled");
207
212
  }
208
213
 
209
214
  if (Constructor) {
210
- this.assert(false, "expected promise to be rejected with " + Constructor.prototype.name +
215
+ assertion.assert(false, "expected promise to be rejected with " + Constructor.prototype.name +
211
216
  " but it was fulfilled");
212
217
  }
213
218
 
214
219
  if (message) {
215
- this.assert(false, "expected promise to be rejected with an error " + messageVerb + " " +
220
+ assertion.assert(false, "expected promise to be rejected with an error " + messageVerb + " " +
216
221
  message + " but it was fulfilled");
217
222
  }
218
223
  }
219
- }.bind(this);
224
+ }
220
225
 
221
- return makeAssertionPromise(transformedPromise.then(onTransformedFulfilled, onTransformedRejected), this);
222
- }.bind(this);
226
+ return makeAssertionPromise(
227
+ transformedPromise.then(onTransformedFulfilled, onTransformedRejected),
228
+ assertion
229
+ );
230
+ }
223
231
 
224
- var transformedPromise = makeAssertionPromise(this._obj.then(onOriginalFulfilled, onOriginalRejected), this);
232
+ var derivedPromise = assertion._obj.then(onOriginalFulfilled, onOriginalRejected);
233
+ var transformedPromise = makeAssertionPromise(derivedPromise, assertion);
225
234
  Object.defineProperty(transformedPromise, "with", { enumerable: true, configurable: true, value: withMethod });
226
235
 
227
236
  return transformedPromise;
228
- };
237
+ }
229
238
 
230
239
  function isChaiAsPromisedAsserter(asserterName) {
231
240
  return ["fulfilled", "rejected", "broken", "eventually", "become"].indexOf(asserterName) !== -1;
@@ -363,7 +372,9 @@
363
372
  }
364
373
 
365
374
  var shouldBeRejectedPromise = (new Assertion(promise, message)).to.be.rejected;
366
- return toTestAgainst ? shouldBeRejectedPromise.with(toTestAgainst) : shouldBeRejectedPromise;
375
+
376
+ // Use `['with']` to handle crappy non-ES5 environments like PhantomJS.
377
+ return toTestAgainst ? shouldBeRejectedPromise['with'](toTestAgainst) : shouldBeRejectedPromise;
367
378
  };
368
379
 
369
380
  assert.eventually = {};
@@ -121,6 +121,9 @@
121
121
  done();
122
122
  }
123
123
  };
124
+ this._wrappedFn.toString = function() {
125
+ return fn.toString();
126
+ };
124
127
  }
125
128
  },
126
129
  async: {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Sinon.JS 1.5.2, 2013/01/09
2
+ * Sinon.JS 1.5.2, 2013/01/14
3
3
  *
4
4
  * @author Christian Johansen (christian@cjohansen.no)
5
5
  * @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
metadata CHANGED
@@ -1,33 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: konacha-chai-matchers
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 7
10
- version: 0.0.7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Matthijs Groen
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-01-10 00:00:00 Z
12
+ date: 2013-01-14 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: A set of Chai.js libraries ready to use for Konacha
22
- email:
15
+ email:
23
16
  - matthijs.groen@gmail.com
24
17
  executables: []
25
-
26
18
  extensions: []
27
-
28
19
  extra_rdoc_files: []
29
-
30
- files:
20
+ files:
31
21
  - .gitignore
32
22
  - .gitmodules
33
23
  - Gemfile
@@ -51,38 +41,29 @@ files:
51
41
  - vendor/assets/javascripts/mocha-as-promised.js
52
42
  - vendor/assets/javascripts/sinon-chai.js
53
43
  - vendor/assets/javascripts/sinon.js
54
- homepage: ""
55
- licenses:
44
+ homepage: ''
45
+ licenses:
56
46
  - MIT
57
47
  post_install_message:
58
48
  rdoc_options: []
59
-
60
- require_paths:
49
+ require_paths:
61
50
  - lib
62
- required_ruby_version: !ruby/object:Gem::Requirement
51
+ required_ruby_version: !ruby/object:Gem::Requirement
63
52
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- hash: 3
68
- segments:
69
- - 0
70
- version: "0"
71
- required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
58
  none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
- version: "0"
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
80
63
  requirements: []
81
-
82
64
  rubyforge_project: konacha-chai-matchers
83
- rubygems_version: 1.8.10
65
+ rubygems_version: 1.8.15
84
66
  signing_key:
85
67
  specification_version: 3
86
68
  summary: Chai.js plugins collection for Konacha
87
69
  test_files: []
88
-