konacha-chai-matchers 0.1.7 → 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7846ed3732b6b9ce3c5d0d37b4cdfeece59545c1
4
+ data.tar.gz: 27b0b95a6be691ad3b3d1a454dc2f65980ce2416
5
+ SHA512:
6
+ metadata.gz: 28873ea28cdbe4b63c5f7c14c0dcf055df0592de429738c92b2bc0a1bdb34e455242f94c4e9e190a0148d5c3d2ff08e92416ff65156dac1b97a58c478ef53d28
7
+ data.tar.gz: 0ade1f615cf3e634355d9ec2a00f24f745288f8e85c8560471a1d73d12a0aa07ed92d0bb43e266d58a880f9bd24643e96f0a036373695281302cba6bbd530b1a
data/VERSIONS CHANGED
@@ -1,7 +1,7 @@
1
1
  chai-spies: 0.5.1
2
- sinon-chai: 2.4.0
2
+ sinon-chai: 2.5.0
3
3
  chai-as-promised: 4.1.0
4
- chai-jquery: 1.1.2
4
+ chai-jquery: 1.2.1
5
5
  chai-timers: 0.2.0
6
6
  chai-stats: 0.3.0
7
7
  chai-null: 0.1.0
@@ -9,7 +9,7 @@ chai-factories: 0.1.0
9
9
  chai-changes: 1.3.4
10
10
  chai-backbone: 0.9.2
11
11
  js-factories: 1.0.1
12
- mocha-as-promised: 1.4.1
12
+ mocha-as-promised: 2.0.0
13
13
  chai-things: 0.2.0
14
14
  chai-fuzzy: 1.4.0
15
15
  sinon: 1.7.3
data/VERSIONS.lock ADDED
@@ -0,0 +1 @@
1
+ sinon: v1.7.3
@@ -1,10 +1,14 @@
1
+ require 'yaml'
1
2
 
2
3
  module Konacha
3
4
  module Chai
4
5
  module Matchers
5
6
  class Collector
6
7
 
8
+
7
9
  def update_libraries
10
+ `git submodule init`
11
+ `git submodule update`
8
12
  modules = collect_libraries
9
13
 
10
14
  modules.each(&:update)
@@ -18,20 +22,22 @@ module Konacha
18
22
  end
19
23
 
20
24
  private
21
-
22
25
  def collect_libraries
23
- libs = []
24
- File.open('.gitmodules') do |f|
25
- contents = f.read
26
- contents.each_line do |line|
27
- if matches = /\[submodule "(.*)"\]/.match(line)
28
- libs << Library.new(matches[1])
29
- end
30
- end
26
+ locked_versions = YAML.load_file 'VERSIONS.lock'
27
+
28
+ urls = `cat .gitmodules | grep 'url =' | awk '{print $3}'`.split("\n")
29
+ paths = `cat .gitmodules | grep 'path =' | awk '{print $3}'`.split("\n")
30
+ @libs ||= urls.each_with_index.map do |url, i|
31
+ name = paths[i]
32
+ `cd ./#{name} && git fetch && cd ..`
33
+ latest_tag = `cd ./#{name} && git describe --tags --abbrev=0 && cd ..`.split.first
34
+ library_tag = locked_versions[name] || latest_tag
35
+
36
+ latest_commit = `cd ./#{name} && git rev-parse #{library_tag || 'HEAD'} && cd ..`.split.first
37
+
38
+ Library.new url: url, name: name, tag: library_tag, commit: latest_commit
31
39
  end
32
- libs
33
40
  end
34
-
35
41
  end
36
42
  end
37
43
  end
@@ -4,15 +4,25 @@ module Konacha
4
4
  module Matchers
5
5
  class Library
6
6
 
7
- attr_reader :name
7
+ attr_reader :data, :name
8
8
 
9
- def initialize(name)
10
- @name = name
9
+ def initialize(data)
10
+ @data = data
11
+ @name = data[:name]
12
+ end
13
+
14
+ def to_s
15
+ "#{@data[:name]} => #{@data[:tag]}"
16
+ end
17
+
18
+ def latest_version
19
+ `cd ./#@name && git fetch`
20
+ @data[:tag]
11
21
  end
12
22
 
13
23
  def update
14
- `cd ./#@name && git pull origin master`
15
- `cd ./#@name && ./build` if File.exist? "./#@name/build"
24
+ puts "Updating #{@data[:name]} to #{latest_version}"
25
+ `cd ./#{@data[:name]} && git checkout #{@data[:commit]}`
16
26
  end
17
27
 
18
28
  def vendor
@@ -1,7 +1,7 @@
1
1
  module Konacha
2
2
  module Chai
3
3
  module Matchers
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end
6
6
  end
7
7
  end
@@ -52,7 +52,7 @@
52
52
  return el.html();
53
53
  };
54
54
 
55
- var props = {attr: 'attribute', css: 'CSS property'};
55
+ var props = {attr: 'attribute', css: 'CSS property', prop: 'property'};
56
56
  for (var prop in props) {
57
57
  (function (prop, description) {
58
58
  chai.Assertion.addMethod(prop, function (name, val) {
@@ -139,7 +139,7 @@
139
139
  );
140
140
  });
141
141
 
142
- $.each(['visible', 'hidden', 'selected', 'checked', 'disabled'], function (i, attr) {
142
+ $.each(['visible', 'hidden', 'selected', 'checked', 'enabled', 'disabled'], function (i, attr) {
143
143
  chai.Assertion.addProperty(attr, function () {
144
144
  this.assert(
145
145
  flag(this, 'object').is(':' + attr)
@@ -225,7 +225,7 @@
225
225
  , text
226
226
  );
227
227
  } else {
228
- Function.prototype.apply.call(_super.call(this), this, arguments);
228
+ return Function.prototype.apply.call(_super.call(this), this, arguments);
229
229
  }
230
230
  };
231
231
  setPrototypeOf(contain, this);
@@ -1,16 +1,9 @@
1
- !function (context, definition) {
2
- if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
3
- module.exports = definition();
4
- } else if (typeof define === 'function' && typeof define.amd === 'object') {
5
- define(definition);
6
- } else {
7
- if (!context.chai) throw new Error('Chai cannot be found in current scope.');
8
- context.chai.use(definition());
9
- }
10
- }(this, function () {
11
-
12
-
13
- function require(p) {
1
+ !function (name, definition) {
2
+ if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
3
+ else this[name] = definition();
4
+ }('chai_timers', function () {
5
+ // CommonJS require()
6
+ function require(p){
14
7
  var path = require.resolve(p)
15
8
  , mod = require.modules[path];
16
9
  if (!mod) throw new Error('failed to require "' + p + '"');
@@ -23,7 +16,7 @@
23
16
 
24
17
  require.modules = {};
25
18
 
26
- require.resolve = function (path) {
19
+ require.resolve = function (path){
27
20
  var orig = path
28
21
  , reg = path + '.js'
29
22
  , index = path + '/index.js';
@@ -32,7 +25,7 @@
32
25
  || orig;
33
26
  };
34
27
 
35
- require.register = function (path, fn) {
28
+ require.register = function (path, fn){
36
29
  require.modules[path] = fn;
37
30
  };
38
31
 
@@ -54,121 +47,110 @@
54
47
  };
55
48
  };
56
49
 
57
- require.alias = function (from, to) {
58
- var fn = require.modules[from];
59
- require.modules[to] = fn;
60
- };
61
50
 
51
+ require.register("timers", function (module, exports, require) {
62
52
 
63
- require.register("chai-timers.js", function(module, exports, require){
64
- var Timer = require('./timer');
65
-
66
- module.exports = function (chai, _) {
67
- var Assertion = chai.Assertion;
68
-
69
- chai.Timer = Timer;
70
-
71
- chai.timer = function (name) {
72
- return new Timer(name);
73
- };
74
-
75
- Assertion.addProperty('timer', function () {
76
- this.assert(
77
- this._obj instanceof Timer
78
- , 'expected #{this} to be a chai timer'
79
- , 'expected #{this} to not be a chai timer' );
80
- });
81
-
82
- [ 'started', 'stopped', 'created' ].forEach(function (when) {
83
- Assertion.overwriteProperty(when, function (_super) {
84
- return function () {
85
- if (this._obj instanceof Timer) {
86
- _.flag(this, 'timer_when', when);
87
- } else {
88
- _super.call(this);
89
- }
90
- }
91
- });
92
- });
93
-
94
- Assertion.overwriteMethod('before', function (_super) {
95
- return function assertBefore (timer2, when2) {
96
- var timer1 = this._obj;
97
- new Assertion(timer1).to.be.a.timer;
98
- new Assertion(timer2).to.be.a.timer;
99
-
100
- var when1 = _.flag(this, 'timer_when') || 'started';
101
- when2 = when2 || when1;
102
- var time1 = timer1[when1].getTime()
103
- , time2 = timer2[when2].getTime();
104
-
105
- this.assert(
106
- time1 < time2
107
- , 'expected timer {' + timer1.name + '} to have been ' + when1 + ' before timer {' + timer2.name + '} was ' + when2
108
- , 'expected timer {' + timer1.name + '} to not have been ' + when1 + ' before timer {' + timer2.name + '} was ' + when2
109
- );
110
- };
111
- });
112
-
113
- Assertion.overwriteMethod('after', function (_super) {
114
- return function assertBefore (timer2, when2) {
115
- var timer1 = this._obj;
116
- new Assertion(timer1).to.be.a.timer;
117
- new Assertion(timer2).to.be.a.timer;
118
-
119
- var when1 = _.flag(this, 'timer_when') || 'started';
120
- when2 = when2 || when1;
121
- var time1 = timer1[when1].getTime()
122
- , time2 = timer2[when2].getTime();
123
-
124
- this.assert(
125
- time1 > time2
126
- , 'expected timer {' + timer1.name + '} to have been ' + when1 + ' after timer {' + timer2.name + '} was ' + when2
127
- , 'expected timer {' + timer1.name + '} to not have been ' + when1 + ' after timer {' + timer2.name + '} was' + when2
128
- );
129
- };
130
- });
53
+ module.exports = function (chai, _) {
131
54
 
132
- };
55
+ chai.Timer = function (name) {
56
+ this.name = name || 'timer';
57
+ this.created = new Date();
58
+ this.marks = [];
59
+ this.started = null;
60
+ this.stopped = null;
61
+ };
133
62
 
134
- }); // module: chai-timers.js
63
+ chai.Timer.prototype.start = function (date) {
64
+ this.started = date || new Date();
65
+ return this;
66
+ };
135
67
 
136
- require.register("timer.js", function(module, exports, require){
68
+ chai.Timer.prototype.stop = function (date) {
69
+ this.stopped = date || new Date();
70
+ };
137
71
 
138
- module.exports = Timer;
72
+ chai.Timer.prototype.mark = function (date) {
73
+ this.marks.push(date || new Date());
74
+ };
139
75
 
140
- function Timer (name) {
141
- this.name = name || 'timer';
142
- this.created = new Date();
143
- this.marks = [];
144
- this.started = null;
145
- this.stopped = null;
146
- };
76
+ Object.defineProperty(chai.Timer.prototype, 'elapsed',
77
+ { get: function () {
78
+ var start = this.started.getTime()
79
+ , stop = this.stopped.getTime();
80
+ return stop - start;
81
+ }
82
+ , configurable: true
83
+ });
147
84
 
148
- Object.defineProperty(Timer.prototype, 'elapsed',
149
- { get: function () {
150
- var start = this.started.getTime()
151
- , stop = this.stopped.getTime();
152
- return stop - start;
85
+ Object.defineProperty(chai.Timer.prototype, 'marks',
86
+ { get: function () {
87
+ var marks = _.flag(this, 'marks');
88
+ return marks;
89
+ }
90
+ , configurable: true
91
+ });
92
+
93
+ chai.Assertion.addProperty('timer', function () {
94
+ this.assert(
95
+ this._obj instanceof chai.Timer
96
+ , 'expected #{this} to be a chai timer'
97
+ , 'expected #{this} to not be a chai timer' );
98
+ });
99
+
100
+ [ 'started', 'stopped', 'created' ].forEach(function (when) {
101
+ chai.Assertion.overwriteProperty(when, function (_super) {
102
+ return function () {
103
+ if (this._obj instanceof chai.Timer) {
104
+ _.flag(this, 'timer_when', when);
105
+ } else {
106
+ _super.call(this);
153
107
  }
108
+ }
154
109
  });
155
-
156
- Timer.prototype.start = function (date) {
157
- this.started = date || new Date();
158
- return this;
110
+ });
111
+
112
+ chai.Assertion.overwriteMethod('before', function (_super) {
113
+ return function assertBefore (timer2, when2) {
114
+ var timer1 = this._obj;
115
+ new chai.Assertion(timer1).to.be.a.timer;
116
+ new chai.Assertion(timer2).to.be.a.timer;
117
+
118
+ var when1 = _.flag(this, 'timer_when') || 'started';
119
+ when2 = when2 || when1;
120
+ var time1 = timer1[when1].getTime()
121
+ , time2 = timer2[when2].getTime();
122
+
123
+ this.assert(
124
+ time1 < time2
125
+ , 'expected timer {' + timer1.name + '} to have been ' + when1 + ' before timer {' + timer2.name + '} was ' + when2
126
+ , 'expected timer {' + timer1.name + '} to not have been ' + when1 + ' before timer {' + timer2.name + '} was ' + when2
127
+ );
159
128
  };
160
-
161
- Timer.prototype.stop = function (date) {
162
- this.stopped = date || new Date();
129
+ });
130
+
131
+ chai.Assertion.overwriteMethod('after', function (_super) {
132
+ return function assertBefore (timer2, when2) {
133
+ var timer1 = this._obj;
134
+ new chai.Assertion(timer1).to.be.a.timer;
135
+ new chai.Assertion(timer2).to.be.a.timer;
136
+
137
+ var when1 = _.flag(this, 'timer_when') || 'started';
138
+ when2 = when2 || when1;
139
+ var time1 = timer1[when1].getTime()
140
+ , time2 = timer2[when2].getTime();
141
+
142
+ this.assert(
143
+ time1 > time2
144
+ , 'expected timer {' + timer1.name + '} to have been ' + when1 + ' after timer {' + timer2.name + '} was ' + when2
145
+ , 'expected timer {' + timer1.name + '} to not have been ' + when1 + ' after timer {' + timer2.name + '} was' + when2
146
+ );
163
147
  };
148
+ });
164
149
 
165
- Timer.prototype.mark = function (date) {
166
- this.marks.push(date || new Date());
167
- };
168
-
169
- }); // module: timer.js
150
+ };
170
151
 
171
- require.alias("./chai-timers.js", "chai-timers");
172
-
173
- return require('chai-timers');
152
+ }); // module timers
153
+ return require('timers');
174
154
  });
155
+
156
+ chai.use(chai_timers);
@@ -108,7 +108,7 @@ var Memoizer = function() {
108
108
  memoizer.is = this.is;
109
109
  };
110
110
 
111
- if (typeof(module) != 'undefined' && module.exports) { // Node.js
111
+ if (module && module.exports) { // Node.js
112
112
  /**
113
113
  * Return a new Memoizer object.
114
114
  *
@@ -1,18 +1,20 @@
1
1
  (function (mochaAsPromised) {
2
2
  "use strict";
3
3
 
4
- function findNodeJSMocha(moduleToTest, suffix) {
4
+ function findNodeJSMocha(moduleToTest, suffix, accumulator) {
5
+ if (accumulator === undefined) {
6
+ accumulator = [];
7
+ }
8
+
5
9
  if (moduleToTest.id.indexOf(suffix, moduleToTest.id.length - suffix.length) !== -1 && moduleToTest.exports) {
6
- return moduleToTest.exports;
10
+ accumulator.push(moduleToTest.exports);
7
11
  }
8
12
 
9
- for (var i = 0; i < moduleToTest.children.length; ++i) {
10
- var found = findNodeJSMocha(moduleToTest.children[i], suffix);
13
+ moduleToTest.children.forEach(function (child) {
14
+ findNodeJSMocha(child, suffix, accumulator);
15
+ });
11
16
 
12
- if (found) {
13
- return found;
14
- }
15
- }
17
+ return accumulator;
16
18
  }
17
19
 
18
20
  // Module systems magic dance.
@@ -22,31 +24,32 @@
22
24
  // using the Mocha test runner from either a locally-installed package, or from a globally-installed one.
23
25
  // In the latter case, naively plugging in `require("mocha")` would end up duck-punching the wrong instance,
24
26
  // so we provide this shortcut to auto-detect which Mocha package needs to be duck-punched.
25
- module.exports = function (mocha) {
26
- if (!mocha) {
27
+ module.exports = function (mochaModules) {
28
+ if (mochaModules === undefined) {
27
29
  if (typeof process === "object" && Object.prototype.toString.call(process) === "[object process]") {
28
30
  // We're in *real* Node.js, not in a browserify-like environment. Do automatic detection logic.
29
31
 
30
- // Funky syntax prevents Browserify from detecting the require, since it's needed for Node.js-only stuff.
32
+ // Funky syntax prevents Browserify from detecting the require, since it's needed for Node.js-only
33
+ // stuff.
31
34
  var path = (require)("path");
32
35
  var suffix = path.join("mocha", "lib", "mocha.js");
33
- mocha = findNodeJSMocha(require.main, suffix);
36
+ mochaModules = findNodeJSMocha(require.main, suffix);
34
37
 
35
- if (mocha === undefined) {
38
+ if (mochaModules === undefined) {
36
39
  throw new Error("Attempted to automatically plug in to Mocha, but could not detect a " +
37
40
  "running Mocha module.");
38
41
  }
39
42
 
40
43
  } else if (typeof Mocha !== "undefined") {
41
44
  // We're in a browserify-like emulation environment. Try the `Mocha` global.
42
- mocha = Mocha;
45
+ mochaModules = [Mocha];
43
46
  } else {
44
47
  throw new Error("Attempted to automatically plug in to Mocha, but could not detect the " +
45
48
  "environment. Plug in manually by passing the running Mocha module.");
46
49
  }
47
50
  }
48
51
 
49
- mochaAsPromised(mocha);
52
+ mochaModules.forEach(mochaAsPromised);
50
53
  };
51
54
  } else if (typeof define === "function" && define.amd) {
52
55
  // AMD
@@ -69,13 +72,11 @@
69
72
  }
70
73
  }
71
74
 
72
- var duckPunchedAlready = false;
73
-
74
75
  return function mochaAsPromised(mocha) {
75
- if (duckPunchedAlready) {
76
+ if (mocha._mochaAsPromisedLoadedAlready) {
76
77
  return;
77
78
  }
78
- duckPunchedAlready = true;
79
+ mocha._mochaAsPromisedLoadedAlready = true;
79
80
 
80
81
  // Soooo this is an awesome hack.
81
82