konacha 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # master
2
2
 
3
+ # 1.2.2
4
+
5
+ * Update chai (1.0.3)
6
+ * Improve compatibility with WebKit driver
7
+ * Improve error reporting
8
+
3
9
  # 1.2.1
4
10
 
5
11
  * Update chai (1.0.1)
@@ -17,7 +17,7 @@ the asset pipeline and engines.}
17
17
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  gem.name = "konacha"
19
19
  gem.require_paths = ["lib"]
20
- gem.version = "1.2.1"
20
+ gem.version = "1.2.2"
21
21
 
22
22
  gem.add_dependency "rails", "~> 3.1"
23
23
  gem.add_dependency "capybara"
@@ -4,6 +4,8 @@ module Konacha
4
4
 
5
5
  def self.application(app)
6
6
  Rack::Builder.app do
7
+ use Rack::ShowExceptions
8
+
7
9
  map app.config.assets.prefix do
8
10
  run app.assets
9
11
  end
@@ -74,14 +74,18 @@ module Konacha
74
74
  begin
75
75
  sleep 0.1
76
76
  done, dots = session.evaluate_script('[Konacha.done, Konacha.dots]')
77
- io.write dots[dots_printed..-1]
78
- io.flush
79
- dots_printed = dots.length
77
+ if dots
78
+ io.write dots[dots_printed..-1]
79
+ io.flush
80
+ dots_printed = dots.length
81
+ end
80
82
  end until done
81
83
 
82
84
  @examples = JSON.parse(session.evaluate_script('Konacha.getResults()')).map do |row|
83
85
  Example.new(row)
84
86
  end
87
+ rescue => e
88
+ raise Konacha::Error, "Error communicating with browser process: #{e.inspect}"
85
89
  end
86
90
  end
87
91
 
@@ -104,4 +108,7 @@ module Konacha
104
108
  end
105
109
  end
106
110
  end
111
+
112
+ class Error < StandardError
113
+ end
107
114
  end
@@ -111,6 +111,10 @@ Assertion.addMethod = function (name, fn) {
111
111
  util.addMethod(this.prototype, name, fn);
112
112
  };
113
113
 
114
+ Assertion.addChainableMethod = function (name, fn, chainingBehavior) {
115
+ util.addChainableMethod(this.prototype, name, fn, chainingBehavior);
116
+ };
117
+
114
118
  Assertion.overwriteProperty = function (name, fn) {
115
119
  util.overwriteProperty(this.prototype, name, fn);
116
120
  };
@@ -265,37 +269,23 @@ Object.defineProperty(Assertion.prototype, 'deep',
265
269
  * @api public
266
270
  */
267
271
 
268
- var an = function () {
269
- var assert = function(type) {
270
- var obj = flag(this, 'object')
271
- , klassStart = type.charAt(0).toUpperCase()
272
- , klass = klassStart + type.slice(1)
273
- , article = ~[ 'A', 'E', 'I', 'O', 'U' ].indexOf(klassStart) ? 'an ' : 'a ';
274
-
275
- this.assert(
276
- '[object ' + klass + ']' === toString.call(obj)
277
- , 'expected #{this} to be ' + article + type
278
- , 'expected #{this} not to be ' + article + type
279
- , '[object ' + klass + ']'
280
- , toString.call(obj)
281
- );
282
-
283
- return this;
284
- };
285
-
286
- assert.__proto__ = this;
287
- return assert;
288
- };
272
+ function an(type) {
273
+ var obj = flag(this, 'object')
274
+ , klassStart = type.charAt(0).toUpperCase()
275
+ , klass = klassStart + type.slice(1)
276
+ , article = ~[ 'A', 'E', 'I', 'O', 'U' ].indexOf(klassStart) ? 'an ' : 'a ';
289
277
 
290
- Object.defineProperty(Assertion.prototype, 'an',
291
- { get: an
292
- , configurable: true
293
- });
278
+ this.assert(
279
+ '[object ' + klass + ']' === toString.call(obj)
280
+ , 'expected #{this} to be ' + article + type
281
+ , 'expected #{this} not to be ' + article + type
282
+ , '[object ' + klass + ']'
283
+ , toString.call(obj)
284
+ );
285
+ }
294
286
 
295
- Object.defineProperty(Assertion.prototype, 'a',
296
- { get: an
297
- , configurable: true
298
- });
287
+ Assertion.addChainableMethod('an', an);
288
+ Assertion.addChainableMethod('a', an);
299
289
 
300
290
  /**
301
291
  * ### .include(value)
@@ -315,32 +305,20 @@ Object.defineProperty(Assertion.prototype, 'a',
315
305
  * @api public
316
306
  */
317
307
 
318
- var include = function () {
308
+ function includeChainingBehavior() {
319
309
  flag(this, 'contains', true);
310
+ }
320
311
 
321
- var assert = function(val) {
322
- var obj = flag(this, 'object')
323
- this.assert(
324
- ~obj.indexOf(val)
325
- , 'expected #{this} to include ' + util.inspect(val)
326
- , 'expected #{this} to not include ' + util.inspect(val));
327
-
328
- return this;
329
- };
330
-
331
- assert.__proto__ = this;
332
- return assert;
333
- };
334
-
335
- Object.defineProperty(Assertion.prototype, 'contain',
336
- { get: include
337
- , configurable: true
338
- });
312
+ function include(val) {
313
+ var obj = flag(this, 'object')
314
+ this.assert(
315
+ ~obj.indexOf(val)
316
+ , 'expected #{this} to include ' + util.inspect(val)
317
+ , 'expected #{this} to not include ' + util.inspect(val));
318
+ }
339
319
 
340
- Object.defineProperty(Assertion.prototype, 'include',
341
- { get: include
342
- , configurable: true
343
- });
320
+ Assertion.addChainableMethod('include', include, includeChainingBehavior);
321
+ Assertion.addChainableMethod('contain', include, includeChainingBehavior);
344
322
 
345
323
  /**
346
324
  * ### .ok
@@ -589,7 +567,7 @@ Object.defineProperty(Assertion.prototype, 'arguments',
589
567
  Assertion.prototype.equal = function (val) {
590
568
  var obj = flag(this, 'object');
591
569
  if (flag(this, 'deep')) {
592
- new Assertion(obj).to.eql(val);
570
+ return this.eql(val);
593
571
  } else {
594
572
  this.assert(
595
573
  val === obj
@@ -617,8 +595,8 @@ Assertion.prototype.equal = function (val) {
617
595
  Assertion.prototype.eql = function (obj) {
618
596
  this.assert(
619
597
  util.eql(obj, flag(this, 'object'))
620
- , 'expected #{this} to equal #{exp}'
621
- , 'expected #{this} to not equal #{exp}'
598
+ , 'expected #{this} to deeply equal #{exp}'
599
+ , 'expected #{this} to not deeply equal #{exp}'
622
600
  , obj );
623
601
 
624
602
  return this;
@@ -1205,7 +1183,7 @@ var used = []
1205
1183
  * Chai version
1206
1184
  */
1207
1185
 
1208
- exports.version = '1.0.1';
1186
+ exports.version = '1.0.3';
1209
1187
 
1210
1188
  /*!
1211
1189
  * Primary `Assertion` prototype
@@ -2316,6 +2294,86 @@ module.exports = function (chai, util) {
2316
2294
 
2317
2295
  }); // module: interface/should.js
2318
2296
 
2297
+ require.register("utils/addChainableMethod.js", function(module, exports, require){
2298
+ /*!
2299
+ * Chai - addChainingMethod utility
2300
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
2301
+ * MIT Licensed
2302
+ */
2303
+
2304
+ /*!
2305
+ * Module dependencies
2306
+ */
2307
+
2308
+ var transferFlags = require('./transferFlags');
2309
+
2310
+ /**
2311
+ * ### addChainableMethod (ctx, name, method, chainingBehavior)
2312
+ *
2313
+ * Adds a method to an object, such that the method can also be chained.
2314
+ *
2315
+ * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
2316
+ * var obj = utils.flag(this, 'object');
2317
+ * new chai.Assertion(obj).to.be.equal(str);
2318
+ * });
2319
+ *
2320
+ * Can also be accessed directly from `chai.Assertion`.
2321
+ *
2322
+ * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
2323
+ *
2324
+ * The result can then be used as both a method assertion, executing both `method` and
2325
+ * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
2326
+ *
2327
+ * expect(fooStr).to.be.foo('bar');
2328
+ * expect(fooStr).to.be.foo.equal('foo');
2329
+ *
2330
+ * @param {Object} ctx object to which the method is added
2331
+ * @param {String} name of method to add
2332
+ * @param {Function} method function to be used for `name`, when called
2333
+ * @param {Function} chainingBehavior function to be called every time the property is accessed
2334
+ * @name addChainableMethod
2335
+ * @api public
2336
+ */
2337
+
2338
+ module.exports = function (ctx, name, method, chainingBehavior) {
2339
+ if (typeof chainingBehavior !== 'function') {
2340
+ chainingBehavior = function () { };
2341
+ }
2342
+
2343
+ Object.defineProperty(ctx, name,
2344
+ { get: function () {
2345
+ chainingBehavior.call(this);
2346
+
2347
+ var assert = function () {
2348
+ var result = method.apply(this, arguments);
2349
+ return result === undefined ? this : result;
2350
+ };
2351
+
2352
+ // Re-enumerate every time to better accomodate plugins.
2353
+ var asserterNames = Object.getOwnPropertyNames(ctx);
2354
+ asserterNames.forEach(function (asserterName) {
2355
+ var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
2356
+
2357
+ // Avoid trying to overwrite things that we can't, like `length`
2358
+ // and `arguments`.
2359
+ var functionProtoPD = Object.getOwnPropertyDescriptor(Function.prototype, asserterName);
2360
+ if (functionProtoPD && !functionProtoPD.configurable) {
2361
+ return;
2362
+ }
2363
+
2364
+ Object.defineProperty(assert, asserterName, pd);
2365
+ });
2366
+
2367
+ transferFlags(this, assert);
2368
+
2369
+ return assert;
2370
+ }
2371
+ , configurable: true
2372
+ });
2373
+ };
2374
+
2375
+ }); // module: utils/addChainableMethod.js
2376
+
2319
2377
  require.register("utils/addMethod.js", function(module, exports, require){
2320
2378
  /*!
2321
2379
  * Chai - addMethod utility
@@ -2787,6 +2845,12 @@ exports.inspect = require('./inspect');
2787
2845
 
2788
2846
  exports.flag = require('./flag');
2789
2847
 
2848
+ /*!
2849
+ * Flag transferring utility
2850
+ */
2851
+
2852
+ exports.transferFlags = require('./transferFlags');
2853
+
2790
2854
  /*!
2791
2855
  * Deep equal utility
2792
2856
  */
@@ -2829,6 +2893,13 @@ exports.overwriteProperty = require('./overwriteProperty');
2829
2893
 
2830
2894
  exports.overwriteMethod = require('./overwriteMethod');
2831
2895
 
2896
+ /*!
2897
+ * Add a chainable method
2898
+ */
2899
+
2900
+ exports.addChainableMethod = require('./addChainableMethod');
2901
+
2902
+
2832
2903
  }); // module: utils/index.js
2833
2904
 
2834
2905
  require.register("utils/inspect.js", function(module, exports, require){
@@ -3255,6 +3326,54 @@ module.exports = function (obj, args) {
3255
3326
 
3256
3327
  }); // module: utils/test.js
3257
3328
 
3329
+ require.register("utils/transferFlags.js", function(module, exports, require){
3330
+ /*!
3331
+ * Chai - transferFlags utility
3332
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
3333
+ * MIT Licensed
3334
+ */
3335
+
3336
+ /**
3337
+ * ### transferFlags(assertion, object, includeAll = true)
3338
+ *
3339
+ * Transfer all the flags for `assertion` to `object`. If
3340
+ * `includeAll` is set to `false`, then the base Chai
3341
+ * assertion flags (namely `object`, `ssfi`, and `message`)
3342
+ * will not be transferred.
3343
+ *
3344
+ *
3345
+ * var newAssertion = new Assertion();
3346
+ * utils.transferFlags(assertion, newAssertion);
3347
+ *
3348
+ * var anotherAsseriton = new Assertion(myObj);
3349
+ * utils.transferFlags(assertion, anotherAssertion, false);
3350
+ *
3351
+ * @param {Assertion} assertion the assertion to transfer the flags from
3352
+ * @param {Object} object the object to transfer the flags too; usually a new assertion
3353
+ * @param {Boolean} includeAll
3354
+ * @name getAllFlags
3355
+ * @api private
3356
+ */
3357
+
3358
+ module.exports = function (assertion, object, includeAll) {
3359
+ var flags = assertion.__flags || (assertion.__flags = Object.create(null));
3360
+
3361
+ if (!object.__flags) {
3362
+ object.__flags = Object.create(null);
3363
+ }
3364
+
3365
+ includeAll = arguments.length === 3 ? includeAll : true;
3366
+
3367
+ for (var flag in flags) {
3368
+ if (includeAll ||
3369
+ (flag !== 'object' && flag !== 'ssfi' && flag != 'message')) {
3370
+ object.__flags[flag] = flags[flag];
3371
+ }
3372
+ }
3373
+ };
3374
+
3375
+ }); // module: utils/transferFlags.js
3376
+
3258
3377
 
3259
3378
  return require('chai');
3260
3379
  });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konacha
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.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: 2012-05-22 00:00:00.000000000 Z
12
+ date: 2012-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -224,21 +224,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
224
  - - ! '>='
225
225
  - !ruby/object:Gem::Version
226
226
  version: '0'
227
- segments:
228
- - 0
229
- hash: 4477410044413595969
230
227
  required_rubygems_version: !ruby/object:Gem::Requirement
231
228
  none: false
232
229
  requirements:
233
230
  - - ! '>='
234
231
  - !ruby/object:Gem::Version
235
232
  version: '0'
236
- segments:
237
- - 0
238
- hash: 4477410044413595969
239
233
  requirements: []
240
234
  rubyforge_project:
241
- rubygems_version: 1.8.24
235
+ rubygems_version: 1.8.23
242
236
  signing_key:
243
237
  specification_version: 3
244
238
  summary: Unit-test your Rails JavaScript with the mocha test framework and chai assertion