coherent 0.6.9 → 0.6.10
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.
- data/VERSION +1 -1
- data/app_generators/coherent/coherent_generator.rb +1 -1
- data/app_generators/coherent/templates/spec/index.html.erb +39 -0
- data/app_generators/coherent/templates/spec/jasmine-1.0.1/MIT.LICENSE +20 -0
- data/app_generators/coherent/templates/spec/jasmine-1.0.1/jasmine-html.js +188 -0
- data/app_generators/coherent/templates/spec/jasmine-1.0.1/jasmine.css +166 -0
- data/app_generators/coherent/templates/spec/jasmine-1.0.1/jasmine.js +2421 -0
- data/app_generators/coherent/templates/spec/jasmine-dom/jasmine-dom-fixtures.js +175 -0
- data/app_generators/coherent/templates/spec/jasmine-dom/jasmine-dom-matchers.js +205 -0
- data/app_generators/coherent/templates/spec/spec-helpers.js +72 -0
- data/coherent.gemspec +9 -1
- metadata +11 -3
@@ -0,0 +1,175 @@
|
|
1
|
+
/*jsl:declare jasmine*/
|
2
|
+
function readFixtures()
|
3
|
+
{
|
4
|
+
return jasmine.getFixtures()._proxyCallTo('read', arguments);
|
5
|
+
}
|
6
|
+
|
7
|
+
function loadFixtures()
|
8
|
+
{
|
9
|
+
jasmine.getFixtures()._proxyCallTo('load', arguments);
|
10
|
+
}
|
11
|
+
|
12
|
+
function setFixtures(html)
|
13
|
+
{
|
14
|
+
jasmine.getFixtures().set(html);
|
15
|
+
}
|
16
|
+
|
17
|
+
function sandbox(attributes)
|
18
|
+
{
|
19
|
+
return jasmine.getFixtures().sandbox(attributes);
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
jasmine.getFixtures = function()
|
24
|
+
{
|
25
|
+
return jasmine._currentFixtures = jasmine._currentFixtures || new jasmine.Fixtures();
|
26
|
+
}
|
27
|
+
|
28
|
+
jasmine.Fixtures = function()
|
29
|
+
{
|
30
|
+
this.containerId = 'jasmine-fixtures';
|
31
|
+
this._fixturesCache = {};
|
32
|
+
}
|
33
|
+
|
34
|
+
jasmine.Fixtures.XHR= window.XMLHttpRequest || (function(){
|
35
|
+
var progIdCandidates= ['Msxml2.XMLHTTP.4.0', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP'];
|
36
|
+
var len= progIdCandidates.length;
|
37
|
+
|
38
|
+
var progId;
|
39
|
+
var xhr;
|
40
|
+
|
41
|
+
function ConstructXhr()
|
42
|
+
{
|
43
|
+
return new window.ActiveXObject(ConstructXhr.progId);
|
44
|
+
}
|
45
|
+
|
46
|
+
while (len--)
|
47
|
+
{
|
48
|
+
try
|
49
|
+
{
|
50
|
+
progId= progIdCandidates[len];
|
51
|
+
xhr= new window.ActiveXObject(progId);
|
52
|
+
// ActiveXObject constructor throws an exception
|
53
|
+
// if the component isn't available.
|
54
|
+
xhr= null;
|
55
|
+
ConstructXhr.progId= progId;
|
56
|
+
return ConstructXhr;
|
57
|
+
}
|
58
|
+
catch (e)
|
59
|
+
{
|
60
|
+
// Ignore the error
|
61
|
+
}
|
62
|
+
}
|
63
|
+
throw new Error('No XMLHttpRequest implementation found');
|
64
|
+
})();
|
65
|
+
|
66
|
+
jasmine.Fixtures.prototype= {
|
67
|
+
|
68
|
+
set: function(html)
|
69
|
+
{
|
70
|
+
this.cleanUp();
|
71
|
+
this._createContainer(html);
|
72
|
+
},
|
73
|
+
|
74
|
+
load: function()
|
75
|
+
{
|
76
|
+
this.cleanUp();
|
77
|
+
this._createContainer(this.read.apply(this, arguments));
|
78
|
+
},
|
79
|
+
|
80
|
+
read: function()
|
81
|
+
{
|
82
|
+
var htmlChunks = [];
|
83
|
+
|
84
|
+
var fixtureUrls = arguments;
|
85
|
+
for (var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++)
|
86
|
+
htmlChunks.push(this._getFixtureHtml(fixtureUrls[urlIndex]));
|
87
|
+
|
88
|
+
return htmlChunks.join('');
|
89
|
+
},
|
90
|
+
|
91
|
+
clearCache: function()
|
92
|
+
{
|
93
|
+
this._fixturesCache = {};
|
94
|
+
},
|
95
|
+
|
96
|
+
cleanUp: function()
|
97
|
+
{
|
98
|
+
var container= document.getElementById(this.containerId);
|
99
|
+
if (container)
|
100
|
+
container.parentNode.removeChild(container);
|
101
|
+
},
|
102
|
+
|
103
|
+
sandbox: function(attributes)
|
104
|
+
{
|
105
|
+
var attributesToSet = attributes || {};
|
106
|
+
var sandbox= document.createElement('div');
|
107
|
+
sandbox.id= 'sandbox';
|
108
|
+
|
109
|
+
if ("string"===typeof(attributes))
|
110
|
+
{
|
111
|
+
sandbox.innerHTML= attributes;
|
112
|
+
if (1===sandbox.childNodes.length && 1===sandbox.firstChild.nodeType)
|
113
|
+
{
|
114
|
+
sandbox= sandbox.firstChild;
|
115
|
+
if (!sandbox.id)
|
116
|
+
sandbox.id= 'sandbox';
|
117
|
+
}
|
118
|
+
return sandbox;
|
119
|
+
}
|
120
|
+
|
121
|
+
for (var attr in attributesToSet)
|
122
|
+
sandbox.setAttribute(attr, attributesToSet[attr]);
|
123
|
+
|
124
|
+
return sandbox;
|
125
|
+
},
|
126
|
+
|
127
|
+
_createContainer: function(html)
|
128
|
+
{
|
129
|
+
var container = document.createElement('div');
|
130
|
+
container.id= this.containerId;
|
131
|
+
|
132
|
+
if (html && html.nodeType===1)
|
133
|
+
container.appendChild(html);
|
134
|
+
else
|
135
|
+
container.innerHTML= html;
|
136
|
+
|
137
|
+
document.body.appendChild(container);
|
138
|
+
},
|
139
|
+
|
140
|
+
_getFixtureHtml: function(url)
|
141
|
+
{
|
142
|
+
if (void(0)===this._fixturesCache[url])
|
143
|
+
this._loadFixtureIntoCache(url);
|
144
|
+
return this._fixturesCache[url];
|
145
|
+
},
|
146
|
+
|
147
|
+
_loadFixtureIntoCache: function(url)
|
148
|
+
{
|
149
|
+
var self= this;
|
150
|
+
var xhr= new jasmine.Fixtures.XHR();
|
151
|
+
xhr.open('GET', url, false);
|
152
|
+
|
153
|
+
xhr.onreadystatechange= function()
|
154
|
+
{
|
155
|
+
if (4!==xhr.readyState)
|
156
|
+
return;
|
157
|
+
var status= xhr.status;
|
158
|
+
var succeeded= 0===status || (status>=200 && status<300) || 304==status;
|
159
|
+
|
160
|
+
if (!succeeded)
|
161
|
+
throw new Error('Failed to load resource: status=' + status + ' url=' + url);
|
162
|
+
|
163
|
+
self._fixturesCache[url]= xhr.responseText;
|
164
|
+
xhr.onreadystatechange= null;
|
165
|
+
xhr= null;
|
166
|
+
}
|
167
|
+
xhr.send(null);
|
168
|
+
},
|
169
|
+
|
170
|
+
_proxyCallTo: function(methodName, passedArguments)
|
171
|
+
{
|
172
|
+
return this[methodName].apply(this, passedArguments);
|
173
|
+
}
|
174
|
+
|
175
|
+
};
|
@@ -0,0 +1,205 @@
|
|
1
|
+
/*jsl:declare jasmine*/
|
2
|
+
/*jsl:declare Sizzle*/
|
3
|
+
/*jsl:declare Prototype*/
|
4
|
+
/*jsl:declare jQuery*/
|
5
|
+
|
6
|
+
jasmine.DOM = {};
|
7
|
+
|
8
|
+
jasmine.DOM.browserTagCaseIndependentHtml = function(html)
|
9
|
+
{
|
10
|
+
var div= document.createElement('div');
|
11
|
+
div.innerHTML= html;
|
12
|
+
return div.innerHTML;
|
13
|
+
}
|
14
|
+
|
15
|
+
jasmine.DOM.elementToString = function(element)
|
16
|
+
{
|
17
|
+
var div= document.createElement('div');
|
18
|
+
div.appendChild(element.cloneNode(true));
|
19
|
+
return div.innerHTML;
|
20
|
+
}
|
21
|
+
|
22
|
+
jasmine.DOM.trim= function(string)
|
23
|
+
{
|
24
|
+
var str= string.replace(/^\s+/, '');
|
25
|
+
for (var i = str.length - 1; i > 0; --i)
|
26
|
+
if (/\S/.test(str.charAt(i)))
|
27
|
+
{
|
28
|
+
str = str.substring(0, i + 1);
|
29
|
+
break;
|
30
|
+
}
|
31
|
+
return str;
|
32
|
+
}
|
33
|
+
|
34
|
+
jasmine.DOM.slice= function(arrayLike, startIndex)
|
35
|
+
{
|
36
|
+
return [].slice.call(arrayLike, startIndex||0);
|
37
|
+
}
|
38
|
+
|
39
|
+
jasmine.DOM.uniqueId= 1;
|
40
|
+
jasmine.DOM.assignId= function(element)
|
41
|
+
{
|
42
|
+
return element.id || (element.id=('jasmine_id_' + jasmine.DOM.uniqueId++));
|
43
|
+
};
|
44
|
+
|
45
|
+
/**
|
46
|
+
jasmine.DOM.queryAll(selector[, scope]) -> array
|
47
|
+
*/
|
48
|
+
jasmine.DOM.queryAll= (function(){
|
49
|
+
if ('undefined'!==typeof(Sizzle))
|
50
|
+
return Sizzle;
|
51
|
+
if ('undefined'!==typeof(Prototype))
|
52
|
+
return function(selector, node)
|
53
|
+
{
|
54
|
+
return Element.getElementsBySelector(node||document, selector);
|
55
|
+
};
|
56
|
+
if ('undefined'!==typeof(jQuery))
|
57
|
+
return function(selector, node)
|
58
|
+
{
|
59
|
+
var result= jQuery(selector, node);
|
60
|
+
var nodes= [];
|
61
|
+
var len= result.length;
|
62
|
+
|
63
|
+
for (var i=0; i<len; ++i)
|
64
|
+
nodes.push(result[i]);
|
65
|
+
return nodes;
|
66
|
+
};
|
67
|
+
if (document.querySelectorAll)
|
68
|
+
return function(selector, node)
|
69
|
+
{
|
70
|
+
if (!node)
|
71
|
+
node= document;
|
72
|
+
else if (node!==document)
|
73
|
+
selector = ['#', jasmine.DOM.assignId(node), ' ', selector].join('');
|
74
|
+
return jasmine.DOM.slice(node.querySelectorAll(selector));
|
75
|
+
};
|
76
|
+
|
77
|
+
throw new Error("Can't determine selector engine...");
|
78
|
+
})();
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
jasmine.DOM.matchers = {};
|
83
|
+
|
84
|
+
|
85
|
+
(function(){
|
86
|
+
var matchers = {
|
87
|
+
|
88
|
+
toHaveClass: function(className)
|
89
|
+
{
|
90
|
+
var classes= jasmine.DOM.trim(this.actual.className).split(" ");
|
91
|
+
return -1!==classes.indexOf(className);
|
92
|
+
},
|
93
|
+
|
94
|
+
toBeVisible: function()
|
95
|
+
{
|
96
|
+
return (this.actual.offsetWidth!==0 || this.actual.offsetHeight!==0);
|
97
|
+
},
|
98
|
+
|
99
|
+
toBeHidden: function()
|
100
|
+
{
|
101
|
+
return (0===this.actual.offsetWidth && 0===this.actual.offsetHeight);
|
102
|
+
},
|
103
|
+
|
104
|
+
toBeSelected: function()
|
105
|
+
{
|
106
|
+
return this.actual.selected;
|
107
|
+
},
|
108
|
+
|
109
|
+
toBeChecked: function()
|
110
|
+
{
|
111
|
+
return this.actual.checked;
|
112
|
+
},
|
113
|
+
|
114
|
+
toBeEmpty: function()
|
115
|
+
{
|
116
|
+
return !this.actual.firstChild;
|
117
|
+
},
|
118
|
+
|
119
|
+
toExist: function()
|
120
|
+
{
|
121
|
+
return !!this.actual;
|
122
|
+
},
|
123
|
+
|
124
|
+
toHaveAttr: function(attributeName, expectedAttributeValue)
|
125
|
+
{
|
126
|
+
if (!this.actual.hasAttribute(attributeName))
|
127
|
+
return false;
|
128
|
+
return comparePropertyValues(this.actual.getAttribute(attributeName), expectedAttributeValue);
|
129
|
+
},
|
130
|
+
|
131
|
+
toHaveId: function(id)
|
132
|
+
{
|
133
|
+
return this.actual.id===id;
|
134
|
+
},
|
135
|
+
|
136
|
+
toHaveHtml: function(html)
|
137
|
+
{
|
138
|
+
return this.actual.innerHTML === jasmine.DOM.browserTagCaseIndependentHtml(html);
|
139
|
+
},
|
140
|
+
|
141
|
+
toHaveText: function(text)
|
142
|
+
{
|
143
|
+
return (this.actual.textContent||this.actual.innerText) === text;
|
144
|
+
},
|
145
|
+
|
146
|
+
toHaveValue: function(value)
|
147
|
+
{
|
148
|
+
return this.actual.value === value;
|
149
|
+
},
|
150
|
+
|
151
|
+
toMatchSelector: function(selector)
|
152
|
+
{
|
153
|
+
// This isn't efficient
|
154
|
+
var nodes= jasmine.DOM.queryAll(selector);
|
155
|
+
return -1!==nodes.indexOf(this.actual);
|
156
|
+
},
|
157
|
+
|
158
|
+
toContain: function(selector)
|
159
|
+
{
|
160
|
+
var nodes= jasmine.DOM.queryAll(selector, this.actual);
|
161
|
+
return nodes.length > 0;
|
162
|
+
}
|
163
|
+
};
|
164
|
+
|
165
|
+
function comparePropertyValues(actualValue, expectedValue)
|
166
|
+
{
|
167
|
+
if (void(0) === expectedValue)
|
168
|
+
return void(0) !== actualValue;
|
169
|
+
return actualValue == expectedValue;
|
170
|
+
}
|
171
|
+
|
172
|
+
function bindMatcher(methodName)
|
173
|
+
{
|
174
|
+
var originalMatcher = jasmine.Matchers.prototype[methodName];
|
175
|
+
|
176
|
+
jasmine.DOM.matchers[methodName] = function()
|
177
|
+
{
|
178
|
+
// If the actual value is a DOM node...
|
179
|
+
if (this.actual && this.actual.nodeType)
|
180
|
+
{
|
181
|
+
var result = matchers[methodName].apply(this, arguments);
|
182
|
+
this.actual = jasmine.DOM.elementToString(this.actual);
|
183
|
+
return result;
|
184
|
+
}
|
185
|
+
|
186
|
+
if (originalMatcher)
|
187
|
+
return originalMatcher.apply(this, arguments);
|
188
|
+
|
189
|
+
return false;
|
190
|
+
}
|
191
|
+
|
192
|
+
}
|
193
|
+
|
194
|
+
for (var methodName in matchers)
|
195
|
+
bindMatcher(methodName);
|
196
|
+
|
197
|
+
})();
|
198
|
+
|
199
|
+
beforeEach(function() {
|
200
|
+
this.addMatchers(jasmine.DOM.matchers);
|
201
|
+
});
|
202
|
+
|
203
|
+
afterEach(function() {
|
204
|
+
jasmine.getFixtures().cleanUp();
|
205
|
+
});
|
@@ -0,0 +1,72 @@
|
|
1
|
+
(function(){
|
2
|
+
var objectToString= Object.prototype.toString;
|
3
|
+
var PRIMITIVE_TYPES= [String, Number, RegExp, Boolean, Date];
|
4
|
+
|
5
|
+
beforeEach(function() {
|
6
|
+
|
7
|
+
this.addMatchers({
|
8
|
+
toBeEmpty: function()
|
9
|
+
{
|
10
|
+
return (this.actual instanceof Array && this.actual.length==0);
|
11
|
+
},
|
12
|
+
|
13
|
+
toHaveProperty: function(prop)
|
14
|
+
{
|
15
|
+
return prop in this.actual;
|
16
|
+
},
|
17
|
+
|
18
|
+
toHaveMethod: function(prop)
|
19
|
+
{
|
20
|
+
return prop in this.actual && 'function'==typeof(this.actual[prop]);
|
21
|
+
},
|
22
|
+
|
23
|
+
toBeInstanceOf: function(type)
|
24
|
+
{
|
25
|
+
this.message= function(args)
|
26
|
+
{
|
27
|
+
return ["Expected", jasmine.pp(this.actual), (this.isNot?"not":""), "to be of type",
|
28
|
+
objectToString.call(type.prototype).slice(8,-1)].join(" ");
|
29
|
+
}
|
30
|
+
|
31
|
+
if (null==this.actual)
|
32
|
+
return type==null;
|
33
|
+
|
34
|
+
if (-1!==PRIMITIVE_TYPES.indexOf(this.actual.constructor))
|
35
|
+
return this.actual.constructor==type;
|
36
|
+
|
37
|
+
return this.actual instanceof type;
|
38
|
+
}
|
39
|
+
});
|
40
|
+
});
|
41
|
+
|
42
|
+
})();
|
43
|
+
|
44
|
+
var TestObserver= Class.create({
|
45
|
+
|
46
|
+
constructor: function()
|
47
|
+
{
|
48
|
+
this.value= undefined;
|
49
|
+
this.called= false;
|
50
|
+
this.count= 0;
|
51
|
+
},
|
52
|
+
|
53
|
+
observeChange: function(change, keyPath, context)
|
54
|
+
{
|
55
|
+
this.value= change.newValue;
|
56
|
+
this.called= true;
|
57
|
+
this.change= change;
|
58
|
+
this.keyPath= keyPath;
|
59
|
+
this.context= context;
|
60
|
+
++this.count;
|
61
|
+
},
|
62
|
+
|
63
|
+
reset: function()
|
64
|
+
{
|
65
|
+
this.value= undefined;
|
66
|
+
this.called= false;
|
67
|
+
this.change= null;
|
68
|
+
this.keyPath= null;
|
69
|
+
this.context= null;
|
70
|
+
this.count= 0;
|
71
|
+
}
|
72
|
+
});
|
data/coherent.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{coherent}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeff Watkins"]
|
@@ -26,6 +26,14 @@ Gem::Specification.new do |s|
|
|
26
26
|
"app_generators/coherent/USAGE",
|
27
27
|
"app_generators/coherent/coherent_generator.rb",
|
28
28
|
"app_generators/coherent/templates/@name@.jsproj.erb",
|
29
|
+
"app_generators/coherent/templates/spec/index.html.erb",
|
30
|
+
"app_generators/coherent/templates/spec/jasmine-1.0.1/MIT.LICENSE",
|
31
|
+
"app_generators/coherent/templates/spec/jasmine-1.0.1/jasmine-html.js",
|
32
|
+
"app_generators/coherent/templates/spec/jasmine-1.0.1/jasmine.css",
|
33
|
+
"app_generators/coherent/templates/spec/jasmine-1.0.1/jasmine.js",
|
34
|
+
"app_generators/coherent/templates/spec/jasmine-dom/jasmine-dom-fixtures.js",
|
35
|
+
"app_generators/coherent/templates/spec/jasmine-dom/jasmine-dom-matchers.js",
|
36
|
+
"app_generators/coherent/templates/spec/spec-helpers.js",
|
29
37
|
"app_generators/coherent/templates/src/NOTICE.erb",
|
30
38
|
"app_generators/coherent/templates/src/css/@name@.css.erb",
|
31
39
|
"app_generators/coherent/templates/src/css/reset.css",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coherent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 10
|
10
|
+
version: 0.6.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeff Watkins
|
@@ -67,6 +67,14 @@ files:
|
|
67
67
|
- app_generators/coherent/USAGE
|
68
68
|
- app_generators/coherent/coherent_generator.rb
|
69
69
|
- app_generators/coherent/templates/@name@.jsproj.erb
|
70
|
+
- app_generators/coherent/templates/spec/index.html.erb
|
71
|
+
- app_generators/coherent/templates/spec/jasmine-1.0.1/MIT.LICENSE
|
72
|
+
- app_generators/coherent/templates/spec/jasmine-1.0.1/jasmine-html.js
|
73
|
+
- app_generators/coherent/templates/spec/jasmine-1.0.1/jasmine.css
|
74
|
+
- app_generators/coherent/templates/spec/jasmine-1.0.1/jasmine.js
|
75
|
+
- app_generators/coherent/templates/spec/jasmine-dom/jasmine-dom-fixtures.js
|
76
|
+
- app_generators/coherent/templates/spec/jasmine-dom/jasmine-dom-matchers.js
|
77
|
+
- app_generators/coherent/templates/spec/spec-helpers.js
|
70
78
|
- app_generators/coherent/templates/src/NOTICE.erb
|
71
79
|
- app_generators/coherent/templates/src/css/@name@.css.erb
|
72
80
|
- app_generators/coherent/templates/src/css/reset.css
|