visionmedia-jspec 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +8 -0
- data/Manifest +4 -11
- data/README.rdoc +4 -4
- data/bin/jspec +16 -32
- data/jspec.gemspec +4 -4
- data/lib/jspec.js +1 -1
- data/spec/env.js +695 -0
- data/templates/default/spec/{spec.html → spec.dom.html} +0 -0
- data/templates/{rhino/spec/spec.js → default/spec/spec.rhino.js} +0 -0
- data/templates/{server/spec/spec.html → default/spec/spec.server.html} +0 -0
- metadata +6 -13
- data/templates/rhino/History.rdoc +0 -4
- data/templates/rhino/README.rdoc +0 -29
- data/templates/rhino/lib/yourlib.core.js +0 -2
- data/templates/rhino/spec/spec.core.js +0 -8
- data/templates/server/History.rdoc +0 -4
- data/templates/server/README.rdoc +0 -29
- data/templates/server/lib/yourlib.core.js +0 -2
- data/templates/server/spec/spec.core.js +0 -8
data/History.rdoc
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
|
2
|
+
=== 2.1.0 / 2009-06-12
|
3
|
+
|
4
|
+
* Changed `jspec init` to utilize a single template
|
5
|
+
which allows for all three suite running capabilities
|
6
|
+
within a single template. Now after initializing a
|
7
|
+
project you may `jspec run --server`, `jspec run --rhino`
|
8
|
+
etc at any time without modifications.
|
9
|
+
|
2
10
|
=== 2.0.3 / 2009-05-15
|
3
11
|
|
4
12
|
* Table should span full width
|
data/Manifest
CHANGED
@@ -16,6 +16,7 @@ README.rdoc
|
|
16
16
|
server/browsers.rb
|
17
17
|
server/server.rb
|
18
18
|
spec/async
|
19
|
+
spec/env.js
|
19
20
|
spec/jquery-1.3.1.js
|
20
21
|
spec/server.html
|
21
22
|
spec/spec.grammar-less.js
|
@@ -31,14 +32,6 @@ templates/default/History.rdoc
|
|
31
32
|
templates/default/lib/yourlib.core.js
|
32
33
|
templates/default/README.rdoc
|
33
34
|
templates/default/spec/spec.core.js
|
34
|
-
templates/default/spec/spec.html
|
35
|
-
templates/
|
36
|
-
templates/
|
37
|
-
templates/rhino/README.rdoc
|
38
|
-
templates/rhino/spec/spec.core.js
|
39
|
-
templates/rhino/spec/spec.js
|
40
|
-
templates/server/History.rdoc
|
41
|
-
templates/server/lib/yourlib.core.js
|
42
|
-
templates/server/README.rdoc
|
43
|
-
templates/server/spec/spec.core.js
|
44
|
-
templates/server/spec/spec.html
|
35
|
+
templates/default/spec/spec.dom.html
|
36
|
+
templates/default/spec/spec.rhino.js
|
37
|
+
templates/default/spec/spec.server.html
|
data/README.rdoc
CHANGED
@@ -37,8 +37,8 @@ Simply download JSpec and include JSpec.css and JSpec.js in your markup.
|
|
37
37
|
Head over to the downloads section on Github, clone this public repo, or
|
38
38
|
add JSpec as a git submodule with in your project. Alternatively JSpec is
|
39
39
|
also available as a Ruby Gem (though this is not required), which also
|
40
|
-
provides the `jspec` executable. To install
|
41
|
-
$ sudo gem install visionmedia-jspec
|
40
|
+
provides the `jspec` executable. To install execute:
|
41
|
+
$ sudo gem install visionmedia-jspec
|
42
42
|
|
43
43
|
At which point you may:
|
44
44
|
$ jspec init myproject
|
@@ -439,7 +439,7 @@ the command following it:
|
|
439
439
|
.report()
|
440
440
|
|
441
441
|
Initialize project with:
|
442
|
-
$ jspec init myproject
|
442
|
+
$ jspec init myproject
|
443
443
|
|
444
444
|
Run with:
|
445
445
|
$ jspec run --rhino
|
@@ -456,7 +456,7 @@ and auto-testing each browser, however results are centralized to the terminal,
|
|
456
456
|
removing the need to manually view each browser's output.
|
457
457
|
|
458
458
|
Initialize project with:
|
459
|
-
$ jspec init myproject
|
459
|
+
$ jspec init myproject
|
460
460
|
|
461
461
|
Run with:
|
462
462
|
$ jspec run --server
|
data/bin/jspec
CHANGED
@@ -10,7 +10,7 @@ require 'fileutils'
|
|
10
10
|
RHINO = 'java org.mozilla.javascript.tools.shell.Main'
|
11
11
|
|
12
12
|
program :name, 'JSpec'
|
13
|
-
program :version, '2.0
|
13
|
+
program :version, '2.1.0'
|
14
14
|
program :description, 'JavaScript BDD Testing Framework'
|
15
15
|
default_command :bind
|
16
16
|
|
@@ -18,35 +18,21 @@ command :init do |c|
|
|
18
18
|
c.syntax = 'jspec init [dest]'
|
19
19
|
c.summary = 'Initialize a JSpec project template'
|
20
20
|
c.description = 'Initialize a JSpec project template. Defaults to the current directory
|
21
|
-
when [dest] is not specified.
|
22
|
-
|
23
|
-
"default" : runs specs in browser(s) using the DOM formatter.
|
24
|
-
"rhino" : runs specs with Rhino using the Terminal formatter.
|
25
|
-
"server" : runs specs using a Ruby server/client solution which
|
26
|
-
starts each browser and reports back to the terminal.'
|
21
|
+
when [dest] is not specified. The template includes several files for
|
22
|
+
running via Rhino, DOM, and the JSpec Rack server.'
|
27
23
|
c.example 'Create a directory foo, initialized with a jspec template', 'jspec init foo'
|
28
|
-
c.example 'Initialize a rhino based project in the current directory', 'jspec init --template rhino'
|
29
|
-
c.example 'Initialize a server based project in foo', 'jspec init foo --template server'
|
30
|
-
c.option '-T', '--template name', 'Template to use. Valid choices are default, rhino, and server.'
|
31
24
|
c.when_called do |args, options|
|
32
25
|
dest = args.shift || '.'
|
33
|
-
options.default :template => 'default'
|
34
26
|
unless Dir[dest + '/*'].empty?
|
35
27
|
abort unless agree "'#{dest}' is not empty; continue? "
|
36
28
|
end
|
37
|
-
template = File.join JSPEC_ROOT, 'templates',
|
38
|
-
abort "template #{options.template} does not exist" unless File.exists? template
|
29
|
+
template = File.join JSPEC_ROOT, 'templates', 'default', '.'
|
39
30
|
FileUtils.mkdir_p dest
|
40
31
|
FileUtils.cp_r template, dest
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
if path
|
47
|
-
spec = File.join dest, 'spec', path
|
48
|
-
contents = File.read(spec).gsub 'JSPEC_ROOT', JSPEC_ROOT
|
49
|
-
File.open(spec, 'w') { |file| file.write contents }
|
32
|
+
%w( spec/spec.dom.html spec/spec.rhino.js ).each do |path|
|
33
|
+
path = File.join dest, path
|
34
|
+
contents = File.read(path).gsub 'JSPEC_ROOT', JSPEC_ROOT
|
35
|
+
File.open(path, 'w') { |file| file.write contents }
|
50
36
|
end
|
51
37
|
say "Template initialized at '#{dest}'"
|
52
38
|
end
|
@@ -55,14 +41,12 @@ end
|
|
55
41
|
command :update do |c|
|
56
42
|
c.syntax = 'jspec update [path ...]'
|
57
43
|
c.summary = 'Update JSpec releases'
|
58
|
-
c.description = 'Update JSpec release in [paths], this will allow you to utilize
|
59
|
-
JSpec features.
|
60
|
-
|
61
|
-
|
62
|
-
This is only needed when using the default, or rhino project templates.'
|
44
|
+
c.description = 'Update JSpec release in [paths], this will allow you to utilize
|
45
|
+
the latest JSpec features. Execute from JSpec project root without [paths] to
|
46
|
+
update the default template spec files.'
|
63
47
|
c.when_called do |args, options|
|
64
|
-
|
65
|
-
|
48
|
+
paths = args.empty? ? %w( spec/spec.dom.html spec/spec.rhino.js ) : args
|
49
|
+
paths.each do |path|
|
66
50
|
next unless File.exists? path
|
67
51
|
contents = File.read(path).gsub /visionmedia-jspec-(\d+\.\d+\.\d+)/, "visionmedia-jspec-#{program(:version)}"
|
68
52
|
File.open(path, 'r+'){ |file| file.write contents }
|
@@ -101,13 +85,13 @@ command :run do |c|
|
|
101
85
|
|
102
86
|
# Actions
|
103
87
|
if options.rhino
|
104
|
-
spec = args.shift || 'spec/spec.js'
|
88
|
+
spec = args.shift || 'spec/spec.rhino.js'
|
105
89
|
action = lambda { rhino spec }
|
106
90
|
elsif options.server
|
107
|
-
spec = args.shift || 'spec/spec.html'
|
91
|
+
spec = args.shift || 'spec/spec.server.html'
|
108
92
|
action = lambda { start_server options, spec }
|
109
93
|
else
|
110
|
-
spec = args.shift || 'spec/spec.html'
|
94
|
+
spec = args.shift || 'spec/spec.dom.html'
|
111
95
|
action = Bind::Actions::RefreshBrowsers.new spec, *options.browsers
|
112
96
|
end
|
113
97
|
|
data/jspec.gemspec
CHANGED
@@ -2,22 +2,22 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{jspec}
|
5
|
-
s.version = "2.0
|
5
|
+
s.version = "2.1.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["TJ Holowaychuk"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-06-12}
|
10
10
|
s.default_executable = %q{jspec}
|
11
11
|
s.description = %q{JavaScript BDD Testing Framework}
|
12
12
|
s.email = %q{tj@vision-media.ca}
|
13
13
|
s.executables = ["jspec"]
|
14
14
|
s.extra_rdoc_files = ["bin/jspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "README.rdoc"]
|
15
|
-
s.files = ["bin/jspec", "History.rdoc", "jspec.gemspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "Manifest", "Rakefile", "README.rdoc", "server/browsers.rb", "server/server.rb", "spec/async", "spec/jquery-1.3.1.js", "spec/server.html", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.html", "spec/spec.jquery.js", "spec/spec.js", "spec/spec.matchers.js", "spec/spec.rhino.js", "spec/spec.shared-behaviors.js", "spec/spec.utils.js", "templates/default/History.rdoc", "templates/default/lib/yourlib.core.js", "templates/default/README.rdoc", "templates/default/spec/spec.core.js", "templates/default/spec/spec.html", "templates/
|
15
|
+
s.files = ["bin/jspec", "History.rdoc", "jspec.gemspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "Manifest", "Rakefile", "README.rdoc", "server/browsers.rb", "server/server.rb", "spec/async", "spec/env.js", "spec/jquery-1.3.1.js", "spec/server.html", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.html", "spec/spec.jquery.js", "spec/spec.js", "spec/spec.matchers.js", "spec/spec.rhino.js", "spec/spec.shared-behaviors.js", "spec/spec.utils.js", "templates/default/History.rdoc", "templates/default/lib/yourlib.core.js", "templates/default/README.rdoc", "templates/default/spec/spec.core.js", "templates/default/spec/spec.dom.html", "templates/default/spec/spec.rhino.js", "templates/default/spec/spec.server.html"]
|
16
16
|
s.homepage = %q{http://visionmedia.github.com/jspec}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Jspec", "--main", "README.rdoc"]
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
s.rubyforge_project = %q{jspec}
|
20
|
-
s.rubygems_version = %q{1.3.
|
20
|
+
s.rubygems_version = %q{1.3.4}
|
21
21
|
s.summary = %q{JavaScript BDD Testing Framework}
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
data/lib/jspec.js
CHANGED
data/spec/env.js
ADDED
@@ -0,0 +1,695 @@
|
|
1
|
+
/*
|
2
|
+
* Simulated browser environment for Rhino
|
3
|
+
* By John Resig <http://ejohn.org/>
|
4
|
+
* Copyright 2007 John Resig, under the MIT License
|
5
|
+
*/
|
6
|
+
|
7
|
+
// The window Object
|
8
|
+
var window = this;
|
9
|
+
|
10
|
+
(function(){
|
11
|
+
|
12
|
+
// Browser Navigator
|
13
|
+
|
14
|
+
window.navigator = {
|
15
|
+
get userAgent(){
|
16
|
+
return "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3";
|
17
|
+
}
|
18
|
+
};
|
19
|
+
|
20
|
+
var curLocation = (new java.io.File("./")).toURL();
|
21
|
+
|
22
|
+
window.__defineSetter__("location", function(url){
|
23
|
+
var xhr = new XMLHttpRequest();
|
24
|
+
xhr.open("GET", url);
|
25
|
+
xhr.onreadystatechange = function(){
|
26
|
+
curLocation = new java.net.URL( curLocation, url );
|
27
|
+
window.document = xhr.responseXML;
|
28
|
+
|
29
|
+
var event = document.createEvent();
|
30
|
+
event.initEvent("load");
|
31
|
+
window.dispatchEvent( event );
|
32
|
+
};
|
33
|
+
xhr.send();
|
34
|
+
});
|
35
|
+
|
36
|
+
window.__defineGetter__("location", function(url){
|
37
|
+
return {
|
38
|
+
get protocol(){
|
39
|
+
return curLocation.getProtocol() + ":";
|
40
|
+
},
|
41
|
+
get href(){
|
42
|
+
return curLocation.toString();
|
43
|
+
},
|
44
|
+
toString: function(){
|
45
|
+
return this.href;
|
46
|
+
}
|
47
|
+
};
|
48
|
+
});
|
49
|
+
|
50
|
+
// Timers
|
51
|
+
|
52
|
+
var timers = [];
|
53
|
+
|
54
|
+
window.setTimeout = function(fn, time){
|
55
|
+
var num;
|
56
|
+
return num = setInterval(function(){
|
57
|
+
fn();
|
58
|
+
clearInterval(num);
|
59
|
+
}, time);
|
60
|
+
};
|
61
|
+
|
62
|
+
window.setInterval = function(fn, time){
|
63
|
+
var num = timers.length;
|
64
|
+
|
65
|
+
timers[num] = new java.lang.Thread(new java.lang.Runnable({
|
66
|
+
run: function(){
|
67
|
+
while (true){
|
68
|
+
java.lang.Thread.currentThread().sleep(time);
|
69
|
+
fn();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}));
|
73
|
+
|
74
|
+
timers[num].start();
|
75
|
+
|
76
|
+
return num;
|
77
|
+
};
|
78
|
+
|
79
|
+
window.clearInterval = function(num){
|
80
|
+
if ( timers[num] ) {
|
81
|
+
timers[num].stop();
|
82
|
+
delete timers[num];
|
83
|
+
}
|
84
|
+
};
|
85
|
+
|
86
|
+
// Window Events
|
87
|
+
|
88
|
+
var events = [{}];
|
89
|
+
|
90
|
+
window.addEventListener = function(type, fn){
|
91
|
+
if ( !this.uuid || this == window ) {
|
92
|
+
this.uuid = events.length;
|
93
|
+
events[this.uuid] = {};
|
94
|
+
}
|
95
|
+
|
96
|
+
if ( !events[this.uuid][type] )
|
97
|
+
events[this.uuid][type] = [];
|
98
|
+
|
99
|
+
if ( events[this.uuid][type].indexOf( fn ) < 0 )
|
100
|
+
events[this.uuid][type].push( fn );
|
101
|
+
};
|
102
|
+
|
103
|
+
window.removeEventListener = function(type, fn){
|
104
|
+
if ( !this.uuid || this == window ) {
|
105
|
+
this.uuid = events.length;
|
106
|
+
events[this.uuid] = {};
|
107
|
+
}
|
108
|
+
|
109
|
+
if ( !events[this.uuid][type] )
|
110
|
+
events[this.uuid][type] = [];
|
111
|
+
|
112
|
+
events[this.uuid][type] =
|
113
|
+
events[this.uuid][type].filter(function(f){
|
114
|
+
return f != fn;
|
115
|
+
});
|
116
|
+
};
|
117
|
+
|
118
|
+
window.dispatchEvent = function(event){
|
119
|
+
if ( event.type ) {
|
120
|
+
if ( this.uuid && events[this.uuid][event.type] ) {
|
121
|
+
var self = this;
|
122
|
+
|
123
|
+
events[this.uuid][event.type].forEach(function(fn){
|
124
|
+
fn.call( self, event );
|
125
|
+
});
|
126
|
+
}
|
127
|
+
|
128
|
+
if ( this["on" + event.type] )
|
129
|
+
this["on" + event.type].call( self, event );
|
130
|
+
}
|
131
|
+
};
|
132
|
+
|
133
|
+
// DOM Document
|
134
|
+
|
135
|
+
window.DOMDocument = function(file){
|
136
|
+
this._file = file;
|
137
|
+
this._dom = Packages.javax.xml.parsers.
|
138
|
+
DocumentBuilderFactory.newInstance()
|
139
|
+
.newDocumentBuilder().parse(file);
|
140
|
+
|
141
|
+
if ( !obj_nodes.containsKey( this._dom ) )
|
142
|
+
obj_nodes.put( this._dom, this );
|
143
|
+
};
|
144
|
+
|
145
|
+
DOMDocument.prototype = {
|
146
|
+
createTextNode: function(text){
|
147
|
+
return makeNode( this._dom.createTextNode(
|
148
|
+
text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) );
|
149
|
+
},
|
150
|
+
createElement: function(name){
|
151
|
+
return makeNode( this._dom.createElement(name.toLowerCase()) );
|
152
|
+
},
|
153
|
+
getElementsByTagName: function(name){
|
154
|
+
return new DOMNodeList( this._dom.getElementsByTagName(
|
155
|
+
name.toLowerCase()) );
|
156
|
+
},
|
157
|
+
getElementById: function(id){
|
158
|
+
var elems = this._dom.getElementsByTagName("*");
|
159
|
+
|
160
|
+
for ( var i = 0; i < elems.length; i++ ) {
|
161
|
+
var elem = elems.item(i);
|
162
|
+
if ( elem.getAttribute("id") == id )
|
163
|
+
return makeNode(elem);
|
164
|
+
}
|
165
|
+
|
166
|
+
return null;
|
167
|
+
},
|
168
|
+
get body(){
|
169
|
+
return this.getElementsByTagName("body")[0];
|
170
|
+
},
|
171
|
+
get documentElement(){
|
172
|
+
return makeNode( this._dom.getDocumentElement() );
|
173
|
+
},
|
174
|
+
get ownerDocument(){
|
175
|
+
return null;
|
176
|
+
},
|
177
|
+
addEventListener: window.addEventListener,
|
178
|
+
removeEventListener: window.removeEventListener,
|
179
|
+
dispatchEvent: window.dispatchEvent,
|
180
|
+
get nodeName() {
|
181
|
+
return "#document";
|
182
|
+
},
|
183
|
+
importNode: function(node, deep){
|
184
|
+
return makeNode( this._dom.importNode(node._dom, deep) );
|
185
|
+
},
|
186
|
+
toString: function(){
|
187
|
+
return "Document" + (typeof this._file == "string" ?
|
188
|
+
": " + this._file : "");
|
189
|
+
},
|
190
|
+
get innerHTML(){
|
191
|
+
return this.documentElement.outerHTML;
|
192
|
+
},
|
193
|
+
|
194
|
+
get defaultView(){
|
195
|
+
return {
|
196
|
+
getComputedStyle: function(elem){
|
197
|
+
return {
|
198
|
+
getPropertyValue: function(prop){
|
199
|
+
prop = prop.replace(/\-(\w)/g,function(m,c){
|
200
|
+
return c.toUpperCase();
|
201
|
+
});
|
202
|
+
var val = elem.style[prop];
|
203
|
+
|
204
|
+
if ( prop == "opacity" && val == "" )
|
205
|
+
val = "1";
|
206
|
+
|
207
|
+
return val;
|
208
|
+
}
|
209
|
+
};
|
210
|
+
}
|
211
|
+
};
|
212
|
+
},
|
213
|
+
|
214
|
+
createEvent: function(){
|
215
|
+
return {
|
216
|
+
type: "",
|
217
|
+
initEvent: function(type){
|
218
|
+
this.type = type;
|
219
|
+
}
|
220
|
+
};
|
221
|
+
}
|
222
|
+
};
|
223
|
+
|
224
|
+
function getDocument(node){
|
225
|
+
return obj_nodes.get(node);
|
226
|
+
}
|
227
|
+
|
228
|
+
// DOM NodeList
|
229
|
+
|
230
|
+
window.DOMNodeList = function(list){
|
231
|
+
this._dom = list;
|
232
|
+
this.length = list.getLength();
|
233
|
+
|
234
|
+
for ( var i = 0; i < this.length; i++ ) {
|
235
|
+
var node = list.item(i);
|
236
|
+
this[i] = makeNode( node );
|
237
|
+
}
|
238
|
+
};
|
239
|
+
|
240
|
+
DOMNodeList.prototype = {
|
241
|
+
toString: function(){
|
242
|
+
return "[ " +
|
243
|
+
Array.prototype.join.call( this, ", " ) + " ]";
|
244
|
+
},
|
245
|
+
get outerHTML(){
|
246
|
+
return Array.prototype.map.call(
|
247
|
+
this, function(node){return node.outerHTML;}).join('');
|
248
|
+
}
|
249
|
+
};
|
250
|
+
|
251
|
+
// DOM Node
|
252
|
+
|
253
|
+
window.DOMNode = function(node){
|
254
|
+
this._dom = node;
|
255
|
+
};
|
256
|
+
|
257
|
+
DOMNode.prototype = {
|
258
|
+
get nodeType(){
|
259
|
+
return this._dom.getNodeType();
|
260
|
+
},
|
261
|
+
get nodeValue(){
|
262
|
+
return this._dom.getNodeValue();
|
263
|
+
},
|
264
|
+
get nodeName() {
|
265
|
+
return this._dom.getNodeName();
|
266
|
+
},
|
267
|
+
cloneNode: function(deep){
|
268
|
+
return makeNode( this._dom.cloneNode(deep) );
|
269
|
+
},
|
270
|
+
get ownerDocument(){
|
271
|
+
return getDocument( this._dom.ownerDocument );
|
272
|
+
},
|
273
|
+
get documentElement(){
|
274
|
+
return makeNode( this._dom.documentElement );
|
275
|
+
},
|
276
|
+
get parentNode() {
|
277
|
+
return makeNode( this._dom.getParentNode() );
|
278
|
+
},
|
279
|
+
get nextSibling() {
|
280
|
+
return makeNode( this._dom.getNextSibling() );
|
281
|
+
},
|
282
|
+
get previousSibling() {
|
283
|
+
return makeNode( this._dom.getPreviousSibling() );
|
284
|
+
},
|
285
|
+
toString: function(){
|
286
|
+
return '"' + this.nodeValue + '"';
|
287
|
+
},
|
288
|
+
get outerHTML(){
|
289
|
+
return this.nodeValue;
|
290
|
+
}
|
291
|
+
};
|
292
|
+
|
293
|
+
// DOM Element
|
294
|
+
|
295
|
+
window.DOMElement = function(elem){
|
296
|
+
this._dom = elem;
|
297
|
+
this.style = {
|
298
|
+
get opacity(){ return this._opacity; },
|
299
|
+
set opacity(val){ this._opacity = val + ""; }
|
300
|
+
};
|
301
|
+
|
302
|
+
// Load CSS info
|
303
|
+
var styles = (this.getAttribute("style") || "").split(/\s*;\s*/);
|
304
|
+
|
305
|
+
for ( var i = 0; i < styles.length; i++ ) {
|
306
|
+
var style = styles[i].split(/\s*:\s*/);
|
307
|
+
if ( style.length == 2 )
|
308
|
+
this.style[ style[0] ] = style[1];
|
309
|
+
}
|
310
|
+
};
|
311
|
+
|
312
|
+
DOMElement.prototype = extend( new DOMNode(), {
|
313
|
+
get nodeName(){
|
314
|
+
return this.tagName.toUpperCase();
|
315
|
+
},
|
316
|
+
get tagName(){
|
317
|
+
return this._dom.getTagName();
|
318
|
+
},
|
319
|
+
toString: function(){
|
320
|
+
return "<" + this.tagName + (this.id ? "#" + this.id : "" ) + ">";
|
321
|
+
},
|
322
|
+
get outerHTML(){
|
323
|
+
var ret = "<" + this.tagName, attr = this.attributes;
|
324
|
+
|
325
|
+
for ( var i in attr )
|
326
|
+
ret += " " + i + "='" + attr[i] + "'";
|
327
|
+
|
328
|
+
if ( this.childNodes.length || this.nodeName == "SCRIPT" )
|
329
|
+
ret += ">" + this.childNodes.outerHTML +
|
330
|
+
"</" + this.tagName + ">";
|
331
|
+
else
|
332
|
+
ret += "/>";
|
333
|
+
|
334
|
+
return ret;
|
335
|
+
},
|
336
|
+
|
337
|
+
get attributes(){
|
338
|
+
var attr = {}, attrs = this._dom.getAttributes();
|
339
|
+
|
340
|
+
for ( var i = 0; i < attrs.getLength(); i++ )
|
341
|
+
attr[ attrs.item(i).nodeName ] = attrs.item(i).nodeValue;
|
342
|
+
|
343
|
+
return attr;
|
344
|
+
},
|
345
|
+
|
346
|
+
get innerHTML(){
|
347
|
+
return this.childNodes.outerHTML;
|
348
|
+
},
|
349
|
+
set innerHTML(html){
|
350
|
+
html = html.replace(/<\/?([A-Z]+)/g, function(m){
|
351
|
+
return m.toLowerCase();
|
352
|
+
});
|
353
|
+
|
354
|
+
var nodes = this.ownerDocument.importNode(
|
355
|
+
new DOMDocument( new java.io.ByteArrayInputStream(
|
356
|
+
(new java.lang.String("<wrap>" + html + "</wrap>"))
|
357
|
+
.getBytes("UTF8"))).documentElement, true).childNodes;
|
358
|
+
|
359
|
+
while (this.firstChild)
|
360
|
+
this.removeChild( this.firstChild );
|
361
|
+
|
362
|
+
for ( var i = 0; i < nodes.length; i++ )
|
363
|
+
this.appendChild( nodes[i] );
|
364
|
+
},
|
365
|
+
|
366
|
+
get textContent(){
|
367
|
+
return nav(this.childNodes);
|
368
|
+
|
369
|
+
function nav(nodes){
|
370
|
+
var str = "";
|
371
|
+
for ( var i = 0; i < nodes.length; i++ )
|
372
|
+
if ( nodes[i].nodeType == 3 )
|
373
|
+
str += nodes[i].nodeValue;
|
374
|
+
else if ( nodes[i].nodeType == 1 )
|
375
|
+
str += nav(nodes[i].childNodes);
|
376
|
+
return str;
|
377
|
+
}
|
378
|
+
},
|
379
|
+
set textContent(text){
|
380
|
+
while (this.firstChild)
|
381
|
+
this.removeChild( this.firstChild );
|
382
|
+
this.appendChild( this.ownerDocument.createTextNode(text));
|
383
|
+
},
|
384
|
+
|
385
|
+
style: {},
|
386
|
+
clientHeight: 0,
|
387
|
+
clientWidth: 0,
|
388
|
+
offsetHeight: 0,
|
389
|
+
offsetWidth: 0,
|
390
|
+
|
391
|
+
get disabled() {
|
392
|
+
var val = this.getAttribute("disabled");
|
393
|
+
return val != "false" && !!val;
|
394
|
+
},
|
395
|
+
set disabled(val) { return this.setAttribute("disabled",val); },
|
396
|
+
|
397
|
+
get checked() {
|
398
|
+
var val = this.getAttribute("checked");
|
399
|
+
return val != "false" && !!val;
|
400
|
+
},
|
401
|
+
set checked(val) { return this.setAttribute("checked",val); },
|
402
|
+
|
403
|
+
get selected() {
|
404
|
+
if ( !this._selectDone ) {
|
405
|
+
this._selectDone = true;
|
406
|
+
|
407
|
+
if ( this.nodeName == "OPTION" && !this.parentNode.getAttribute("multiple") ) {
|
408
|
+
var opt = this.parentNode.getElementsByTagName("option");
|
409
|
+
|
410
|
+
if ( this == opt[0] ) {
|
411
|
+
var select = true;
|
412
|
+
|
413
|
+
for ( var i = 1; i < opt.length; i++ )
|
414
|
+
if ( opt[i].selected ) {
|
415
|
+
select = false;
|
416
|
+
break;
|
417
|
+
}
|
418
|
+
|
419
|
+
if ( select )
|
420
|
+
this.selected = true;
|
421
|
+
}
|
422
|
+
}
|
423
|
+
}
|
424
|
+
|
425
|
+
var val = this.getAttribute("selected");
|
426
|
+
return val != "false" && !!val;
|
427
|
+
},
|
428
|
+
set selected(val) { return this.setAttribute("selected",val); },
|
429
|
+
|
430
|
+
get className() { return this.getAttribute("class") || ""; },
|
431
|
+
set className(val) {
|
432
|
+
return this.setAttribute("class",
|
433
|
+
val.replace(/(^\s*|\s*$)/g,""));
|
434
|
+
},
|
435
|
+
|
436
|
+
get type() { return this.getAttribute("type") || ""; },
|
437
|
+
set type(val) { return this.setAttribute("type",val); },
|
438
|
+
|
439
|
+
get value() { return this.getAttribute("value") || ""; },
|
440
|
+
set value(val) { return this.setAttribute("value",val); },
|
441
|
+
|
442
|
+
get src() { return this.getAttribute("src") || ""; },
|
443
|
+
set src(val) { return this.setAttribute("src",val); },
|
444
|
+
|
445
|
+
get id() { return this.getAttribute("id") || ""; },
|
446
|
+
set id(val) { return this.setAttribute("id",val); },
|
447
|
+
|
448
|
+
getAttribute: function(name){
|
449
|
+
return this._dom.hasAttribute(name) ?
|
450
|
+
new String( this._dom.getAttribute(name) ) :
|
451
|
+
null;
|
452
|
+
},
|
453
|
+
setAttribute: function(name,value){
|
454
|
+
this._dom.setAttribute(name,value);
|
455
|
+
},
|
456
|
+
removeAttribute: function(name){
|
457
|
+
this._dom.removeAttribute(name);
|
458
|
+
},
|
459
|
+
|
460
|
+
get childNodes(){
|
461
|
+
return new DOMNodeList( this._dom.getChildNodes() );
|
462
|
+
},
|
463
|
+
get firstChild(){
|
464
|
+
return makeNode( this._dom.getFirstChild() );
|
465
|
+
},
|
466
|
+
get lastChild(){
|
467
|
+
return makeNode( this._dom.getLastChild() );
|
468
|
+
},
|
469
|
+
appendChild: function(node){
|
470
|
+
this._dom.appendChild( node._dom );
|
471
|
+
},
|
472
|
+
insertBefore: function(node,before){
|
473
|
+
this._dom.insertBefore( node._dom, before ? before._dom : before );
|
474
|
+
},
|
475
|
+
removeChild: function(node){
|
476
|
+
this._dom.removeChild( node._dom );
|
477
|
+
},
|
478
|
+
|
479
|
+
getElementsByTagName: DOMDocument.prototype.getElementsByTagName,
|
480
|
+
|
481
|
+
addEventListener: window.addEventListener,
|
482
|
+
removeEventListener: window.removeEventListener,
|
483
|
+
dispatchEvent: window.dispatchEvent,
|
484
|
+
|
485
|
+
click: function(){
|
486
|
+
var event = document.createEvent();
|
487
|
+
event.initEvent("click");
|
488
|
+
this.dispatchEvent(event);
|
489
|
+
},
|
490
|
+
submit: function(){
|
491
|
+
var event = document.createEvent();
|
492
|
+
event.initEvent("submit");
|
493
|
+
this.dispatchEvent(event);
|
494
|
+
},
|
495
|
+
focus: function(){
|
496
|
+
var event = document.createEvent();
|
497
|
+
event.initEvent("focus");
|
498
|
+
this.dispatchEvent(event);
|
499
|
+
},
|
500
|
+
blur: function(){
|
501
|
+
var event = document.createEvent();
|
502
|
+
event.initEvent("blur");
|
503
|
+
this.dispatchEvent(event);
|
504
|
+
},
|
505
|
+
get elements(){
|
506
|
+
return this.getElementsByTagName("*");
|
507
|
+
},
|
508
|
+
get contentWindow(){
|
509
|
+
return this.nodeName == "IFRAME" ? {
|
510
|
+
document: this.contentDocument
|
511
|
+
} : null;
|
512
|
+
},
|
513
|
+
get contentDocument(){
|
514
|
+
if ( this.nodeName == "IFRAME" ) {
|
515
|
+
if ( !this._doc )
|
516
|
+
this._doc = new DOMDocument(
|
517
|
+
new java.io.ByteArrayInputStream((new java.lang.String(
|
518
|
+
"<html><head><title></title></head><body></body></html>"))
|
519
|
+
.getBytes("UTF8")));
|
520
|
+
return this._doc;
|
521
|
+
} else
|
522
|
+
return null;
|
523
|
+
}
|
524
|
+
});
|
525
|
+
|
526
|
+
// Helper method for extending one object with another
|
527
|
+
|
528
|
+
function extend(a,b) {
|
529
|
+
for ( var i in b ) {
|
530
|
+
var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
|
531
|
+
|
532
|
+
if ( g || s ) {
|
533
|
+
if ( g )
|
534
|
+
a.__defineGetter__(i, g);
|
535
|
+
if ( s )
|
536
|
+
a.__defineSetter__(i, s);
|
537
|
+
} else
|
538
|
+
a[i] = b[i];
|
539
|
+
}
|
540
|
+
return a;
|
541
|
+
}
|
542
|
+
|
543
|
+
// Helper method for generating the right
|
544
|
+
// DOM objects based upon the type
|
545
|
+
|
546
|
+
var obj_nodes = new java.util.HashMap();
|
547
|
+
|
548
|
+
function makeNode(node){
|
549
|
+
if ( node ) {
|
550
|
+
if ( !obj_nodes.containsKey( node ) )
|
551
|
+
obj_nodes.put( node, node.getNodeType() ==
|
552
|
+
Packages.org.w3c.dom.Node.ELEMENT_NODE ?
|
553
|
+
new DOMElement( node ) : new DOMNode( node ) );
|
554
|
+
|
555
|
+
return obj_nodes.get(node);
|
556
|
+
} else
|
557
|
+
return null;
|
558
|
+
}
|
559
|
+
|
560
|
+
// XMLHttpRequest
|
561
|
+
// Originally implemented by Yehuda Katz
|
562
|
+
|
563
|
+
window.XMLHttpRequest = function(){
|
564
|
+
this.headers = {};
|
565
|
+
this.responseHeaders = {};
|
566
|
+
};
|
567
|
+
|
568
|
+
XMLHttpRequest.prototype = {
|
569
|
+
open: function(method, url, async, user, password){
|
570
|
+
this.readyState = 1;
|
571
|
+
if (async)
|
572
|
+
this.async = true;
|
573
|
+
this.method = method || "GET";
|
574
|
+
this.url = url;
|
575
|
+
this.onreadystatechange();
|
576
|
+
},
|
577
|
+
setRequestHeader: function(header, value){
|
578
|
+
this.headers[header] = value;
|
579
|
+
},
|
580
|
+
getResponseHeader: function(header){ },
|
581
|
+
send: function(data){
|
582
|
+
var self = this;
|
583
|
+
|
584
|
+
function makeRequest(){
|
585
|
+
var url = new java.net.URL(curLocation, self.url);
|
586
|
+
|
587
|
+
if ( url.getProtocol() == "file" ) {
|
588
|
+
if ( self.method == "PUT" ) {
|
589
|
+
var out = new java.io.FileWriter(
|
590
|
+
new java.io.File( new java.net.URI( url.toString() ) ) ),
|
591
|
+
text = new java.lang.String( data || "" );
|
592
|
+
|
593
|
+
out.write( text, 0, text.length() );
|
594
|
+
out.flush();
|
595
|
+
out.close();
|
596
|
+
} else if ( self.method == "DELETE" ) {
|
597
|
+
var file = new java.io.File( new java.net.URI( url.toString() ) );
|
598
|
+
file["delete"]();
|
599
|
+
} else {
|
600
|
+
var connection = url.openConnection();
|
601
|
+
connection.connect();
|
602
|
+
handleResponse();
|
603
|
+
}
|
604
|
+
} else {
|
605
|
+
var connection = url.openConnection();
|
606
|
+
|
607
|
+
connection.setRequestMethod( self.method );
|
608
|
+
|
609
|
+
// Add headers to Java connection
|
610
|
+
for (var header in self.headers)
|
611
|
+
connection.addRequestProperty(header, self.headers[header]);
|
612
|
+
|
613
|
+
connection.connect();
|
614
|
+
|
615
|
+
// Stick the response headers into responseHeaders
|
616
|
+
for (var i = 0; ; i++) {
|
617
|
+
var headerName = connection.getHeaderFieldKey(i);
|
618
|
+
var headerValue = connection.getHeaderField(i);
|
619
|
+
if (!headerName && !headerValue) break;
|
620
|
+
if (headerName)
|
621
|
+
self.responseHeaders[headerName] = headerValue;
|
622
|
+
}
|
623
|
+
|
624
|
+
handleResponse();
|
625
|
+
}
|
626
|
+
|
627
|
+
function handleResponse(){
|
628
|
+
self.readyState = 4;
|
629
|
+
self.status = parseInt(connection.responseCode) || undefined;
|
630
|
+
self.statusText = connection.responseMessage || "";
|
631
|
+
|
632
|
+
var stream = new java.io.InputStreamReader(connection.getInputStream()),
|
633
|
+
buffer = new java.io.BufferedReader(stream), line;
|
634
|
+
|
635
|
+
while ((line = buffer.readLine()) != null)
|
636
|
+
self.responseText += line;
|
637
|
+
|
638
|
+
self.responseXML = null;
|
639
|
+
|
640
|
+
if ( self.responseText.match(/^\s*</) ) {
|
641
|
+
try {
|
642
|
+
self.responseXML = new DOMDocument(
|
643
|
+
new java.io.ByteArrayInputStream(
|
644
|
+
(new java.lang.String(
|
645
|
+
self.responseText)).getBytes("UTF8")));
|
646
|
+
} catch(e) {}
|
647
|
+
}
|
648
|
+
}
|
649
|
+
|
650
|
+
self.onreadystatechange();
|
651
|
+
}
|
652
|
+
|
653
|
+
if (this.async)
|
654
|
+
(new java.lang.Thread(new java.lang.Runnable({
|
655
|
+
run: makeRequest
|
656
|
+
}))).start();
|
657
|
+
else
|
658
|
+
makeRequest();
|
659
|
+
},
|
660
|
+
abort: function(){},
|
661
|
+
onreadystatechange: function(){},
|
662
|
+
getResponseHeader: function(header){
|
663
|
+
if (this.readyState < 3)
|
664
|
+
throw new Error("INVALID_STATE_ERR");
|
665
|
+
else {
|
666
|
+
var returnedHeaders = [];
|
667
|
+
for (var rHeader in this.responseHeaders) {
|
668
|
+
if (rHeader.match(new Regexp(header, "i")))
|
669
|
+
returnedHeaders.push(this.responseHeaders[rHeader]);
|
670
|
+
}
|
671
|
+
|
672
|
+
if (returnedHeaders.length)
|
673
|
+
return returnedHeaders.join(", ");
|
674
|
+
}
|
675
|
+
|
676
|
+
return null;
|
677
|
+
},
|
678
|
+
getAllResponseHeaders: function(header){
|
679
|
+
if (this.readyState < 3)
|
680
|
+
throw new Error("INVALID_STATE_ERR");
|
681
|
+
else {
|
682
|
+
var returnedHeaders = [];
|
683
|
+
|
684
|
+
for (var header in this.responseHeaders)
|
685
|
+
returnedHeaders.push( header + ": " + this.responseHeaders[header] );
|
686
|
+
|
687
|
+
return returnedHeaders.join("\r\n");
|
688
|
+
}
|
689
|
+
},
|
690
|
+
async: true,
|
691
|
+
readyState: 0,
|
692
|
+
responseText: "",
|
693
|
+
status: 0
|
694
|
+
};
|
695
|
+
})();
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visionmedia-jspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-12 00:00:00 -07:00
|
13
13
|
default_executable: jspec
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- server/browsers.rb
|
60
60
|
- server/server.rb
|
61
61
|
- spec/async
|
62
|
+
- spec/env.js
|
62
63
|
- spec/jquery-1.3.1.js
|
63
64
|
- spec/server.html
|
64
65
|
- spec/spec.grammar-less.js
|
@@ -74,17 +75,9 @@ files:
|
|
74
75
|
- templates/default/lib/yourlib.core.js
|
75
76
|
- templates/default/README.rdoc
|
76
77
|
- templates/default/spec/spec.core.js
|
77
|
-
- templates/default/spec/spec.html
|
78
|
-
- templates/
|
79
|
-
- templates/
|
80
|
-
- templates/rhino/README.rdoc
|
81
|
-
- templates/rhino/spec/spec.core.js
|
82
|
-
- templates/rhino/spec/spec.js
|
83
|
-
- templates/server/History.rdoc
|
84
|
-
- templates/server/lib/yourlib.core.js
|
85
|
-
- templates/server/README.rdoc
|
86
|
-
- templates/server/spec/spec.core.js
|
87
|
-
- templates/server/spec/spec.html
|
78
|
+
- templates/default/spec/spec.dom.html
|
79
|
+
- templates/default/spec/spec.rhino.js
|
80
|
+
- templates/default/spec/spec.server.html
|
88
81
|
has_rdoc: false
|
89
82
|
homepage: http://visionmedia.github.com/jspec
|
90
83
|
post_install_message:
|
data/templates/rhino/README.rdoc
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
= YourLib
|
3
|
-
|
4
|
-
Description
|
5
|
-
|
6
|
-
== License
|
7
|
-
|
8
|
-
(The MIT License)
|
9
|
-
|
10
|
-
Copyright (c) 2009 Your Name <Your Email>
|
11
|
-
|
12
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
13
|
-
a copy of this software and associated documentation files (the
|
14
|
-
'Software'), to deal in the Software without restriction, including
|
15
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
16
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
17
|
-
permit persons to whom the Software is furnished to do so, subject to
|
18
|
-
the following conditions:
|
19
|
-
|
20
|
-
The above copyright notice and this permission notice shall be
|
21
|
-
included in all copies or substantial portions of the Software.
|
22
|
-
|
23
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
24
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
26
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
27
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
28
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
29
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
= YourLib
|
3
|
-
|
4
|
-
Description
|
5
|
-
|
6
|
-
== License
|
7
|
-
|
8
|
-
(The MIT License)
|
9
|
-
|
10
|
-
Copyright (c) 2009 Your Name <Your Email>
|
11
|
-
|
12
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
13
|
-
a copy of this software and associated documentation files (the
|
14
|
-
'Software'), to deal in the Software without restriction, including
|
15
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
16
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
17
|
-
permit persons to whom the Software is furnished to do so, subject to
|
18
|
-
the following conditions:
|
19
|
-
|
20
|
-
The above copyright notice and this permission notice shall be
|
21
|
-
included in all copies or substantial portions of the Software.
|
22
|
-
|
23
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
24
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
26
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
27
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
28
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
29
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|