jspec 2.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/History.rdoc +522 -0
  2. data/Manifest +57 -0
  3. data/README.rdoc +825 -0
  4. data/Rakefile +75 -0
  5. data/bin/jspec +305 -0
  6. data/jspec.gemspec +44 -0
  7. data/lib/images/bg.png +0 -0
  8. data/lib/images/hr.png +0 -0
  9. data/lib/images/loading.gif +0 -0
  10. data/lib/images/sprites.bg.png +0 -0
  11. data/lib/images/sprites.png +0 -0
  12. data/lib/images/vr.png +0 -0
  13. data/lib/jspec.css +145 -0
  14. data/lib/jspec.jquery.js +71 -0
  15. data/lib/jspec.js +1771 -0
  16. data/lib/jspec.shell.js +36 -0
  17. data/lib/jspec.timers.js +90 -0
  18. data/lib/jspec.xhr.js +183 -0
  19. data/server/browsers.rb +228 -0
  20. data/server/helpers.rb +82 -0
  21. data/server/routes.rb +57 -0
  22. data/server/server.rb +88 -0
  23. data/spec/async +1 -0
  24. data/spec/env.js +695 -0
  25. data/spec/fixtures/test.html +1 -0
  26. data/spec/fixtures/test.json +1 -0
  27. data/spec/fixtures/test.xml +5 -0
  28. data/spec/helpers.js +66 -0
  29. data/spec/server.rb +2 -0
  30. data/spec/spec.dom.html +34 -0
  31. data/spec/spec.fixtures.js +18 -0
  32. data/spec/spec.grammar-less.js +34 -0
  33. data/spec/spec.grammar.js +226 -0
  34. data/spec/spec.jquery.js +176 -0
  35. data/spec/spec.jquery.xhr.js +65 -0
  36. data/spec/spec.js +166 -0
  37. data/spec/spec.matchers.js +493 -0
  38. data/spec/spec.modules.js +67 -0
  39. data/spec/spec.node.js +46 -0
  40. data/spec/spec.rhino.js +17 -0
  41. data/spec/spec.server.html +29 -0
  42. data/spec/spec.shared-behaviors.js +80 -0
  43. data/spec/spec.utils.js +279 -0
  44. data/spec/spec.xhr.js +156 -0
  45. data/templates/default/History.rdoc +4 -0
  46. data/templates/default/README.rdoc +29 -0
  47. data/templates/default/lib/yourlib.core.js +2 -0
  48. data/templates/default/spec/server.rb +4 -0
  49. data/templates/default/spec/spec.core.js +8 -0
  50. data/templates/default/spec/spec.dom.html +20 -0
  51. data/templates/default/spec/spec.rhino.js +8 -0
  52. data/templates/default/spec/spec.server.html +16 -0
  53. data/templates/rails/server.rb +4 -0
  54. data/templates/rails/spec.application.js +8 -0
  55. data/templates/rails/spec.dom.html +20 -0
  56. data/templates/rails/spec.rhino.js +8 -0
  57. data/templates/rails/spec.server.html +16 -0
  58. metadata +168 -0
data/Rakefile ADDED
@@ -0,0 +1,75 @@
1
+
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'echoe'
5
+
6
+ def version
7
+ $1 if File.read('lib/jspec.js').match /version *: *'(.*?)'/
8
+ end
9
+
10
+ Echoe.new "jspec", version do |p|
11
+ p.author = "TJ Holowaychuk"
12
+ p.email = "tj@vision-media.ca"
13
+ p.summary = "JavaScript BDD Testing Framework"
14
+ p.url = "http://visionmedia.github.com/jspec"
15
+ p.runtime_dependencies << "sinatra"
16
+ p.runtime_dependencies << "json"
17
+ p.runtime_dependencies << "visionmedia-commander >=3.2.9"
18
+ p.runtime_dependencies << "visionmedia-bind >=0.2.6"
19
+ end
20
+
21
+ namespace :pkg do
22
+ desc 'Build package'
23
+ task :build => ['pkg:clear'] do
24
+ begin
25
+ sh 'mkdir pkg'
26
+ sh 'cp -fr lib/* pkg'
27
+ minify 'lib/jspec.js', 'pkg/jspec.min.js'
28
+ minify 'lib/jspec.jquery.js', 'pkg/jspec.jquery.min.js'
29
+ compress 'lib/jspec.css', 'pkg/jspec.min.css'
30
+ sh 'git add pkg/.'
31
+ rescue Exception => e
32
+ puts "Failed to package: #{e}."
33
+ else
34
+ puts "Packaging of JSpec-#{version} completed."
35
+ end
36
+ end
37
+
38
+ desc 'Clear packaging'
39
+ task :clear do
40
+ if File.directory? 'pkg'
41
+ sh 'rm -fr pkg/*'
42
+ sh 'rmdir pkg'
43
+ end
44
+ end
45
+
46
+ desc 'Display compression savings of last release'
47
+ task :savings do
48
+ totals = Hash.new { |h, k| h[k] = 0 }
49
+ format = '%-20s : %0.3f kb'
50
+ totals = %w( pkg/jspec.min.js pkg/jspec.jquery.min.js pkg/jspec.min.css ).inject totals do |total, file|
51
+ uncompressed = File.size(file.sub('.min', '')).to_f / 1024
52
+ compressed = File.size(file).to_f / 1024
53
+ saved = uncompressed - compressed
54
+ puts format % [file.sub('pkg/', ''), saved]
55
+ totals[:saved] += saved
56
+ totals[:uncompressed] += uncompressed
57
+ totals[:compressed] += compressed
58
+ totals
59
+ end
60
+ puts
61
+ puts format % ['total uncompressed', totals[:uncompressed]]
62
+ puts format % ['total compressed', totals[:compressed]]
63
+ puts format % ['total saved', totals[:saved]]
64
+ end
65
+ end
66
+
67
+ def minify from, to
68
+ sh "jsmin < #{from} > #{to}"
69
+ end
70
+
71
+ def compress from, to
72
+ File.open(to, 'w+') do |file|
73
+ file.write File.read(from).gsub(/(^[\t ]*)|\n/, '')
74
+ end
75
+ end
data/bin/jspec ADDED
@@ -0,0 +1,305 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ JSPEC_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
4
+ $:.unshift JSPEC_ROOT
5
+
6
+ require 'rubygems'
7
+ require 'commander'
8
+ require 'bind'
9
+ require 'fileutils'
10
+ require 'server/server'
11
+
12
+ RHINO = 'java org.mozilla.javascript.tools.shell.Main'
13
+
14
+ program :name, 'JSpec'
15
+ program :version, '2.11.2'
16
+ program :description, 'JavaScript BDD Testing Framework'
17
+ default_command :bind
18
+
19
+ command :init do |c|
20
+ c.syntax = 'jspec init [dest]'
21
+ c.summary = 'Initialize a JSpec project template'
22
+ c.description = 'Initialize a JSpec project template. Defaults to the current directory
23
+ when [dest] is not specified. The template includes several files for
24
+ running via Rhino, DOM, and the JSpec Rack server.
25
+
26
+ Additional switches --freeze, and --symlink are available in order
27
+ to preserve the version of JSpec at the time of initialization. Otherwise
28
+ incompatibilities from later versions may prevent your suite from
29
+ running properly.'
30
+ c.option '-R', '--rails', 'Initialize rails template from rails root directory'
31
+ c.option '-f', '--freeze', 'Copy the JSpec library'
32
+ c.option '-s', '--symlink', 'Symlink the JSpec library instead of copying it'
33
+ c.example 'Create a directory foo, initialized with a jspec template', 'jspec init foo'
34
+ c.when_called do |args, options|
35
+ dest = args.shift || '.'
36
+ if options.rails
37
+ initialize_rails_at dest, options
38
+ else
39
+ initialize_at dest, options
40
+ end
41
+ say "Template initialized at `#{dest}'"
42
+ end
43
+ end
44
+
45
+ command :shell do |c|
46
+ c.syntax = 'jspec shell [path ...]'
47
+ c.summary = 'JSpec interactive shell'
48
+ c.description = 'Launch interactive shell with jspec.js, jspec.shell.js,
49
+ and any [path]s given. Simply type "quit" or "exit" to
50
+ terminate the shell.'
51
+ c.example 'Run shell', 'jspec shell'
52
+ c.example 'Run shell with glob of files', 'jspec shell lib/*.js'
53
+ c.example 'Run shell with list of files', 'jspec shell lib/foo.js lib/bar.js'
54
+ c.when_called do |args, options|
55
+ paths = ['jspec.js', 'jspec.shell.js'] | args
56
+ paths.map! do |path|
57
+ if path.include? 'jspec'
58
+ "-f #{JSPEC_ROOT}/lib/#{path}"
59
+ else
60
+ "-f #{path}"
61
+ end
62
+ end
63
+ say "JSpec #{program(:version)}"
64
+ `#{RHINO} #{paths.join(' ')} -f -`
65
+ end
66
+ end
67
+
68
+ command :update do |c|
69
+ c.syntax = 'jspec update [path ...]'
70
+ c.summary = 'Update JSpec releases'
71
+ c.description = 'Update JSpec release in [paths], this will allow you to utilize
72
+ the latest JSpec features. Execute from JSpec project root without [paths] to
73
+ update the default template spec files.'
74
+ c.when_called do |args, options|
75
+ if args.empty?
76
+ if rails?
77
+ paths = 'jspec/spec.dom.html', 'jspec/spec.rhino.js'
78
+ else
79
+ paths = 'spec/spec.dom.html', 'spec/spec.rhino.js'
80
+ end
81
+ else
82
+ paths = args
83
+ end
84
+ update_version_in *paths
85
+ end
86
+ end
87
+
88
+ command :run do |c|
89
+ c.syntax = 'jspec run [path] [options]'
90
+ c.summary = 'Run specifications'
91
+ c.description = 'Run specifications, defaulting [path] to spec/spec.dom.html.
92
+ You will need to supply [path] if your specs do not reside
93
+ in this location. `run --bind` is the default sub-command of
94
+ jspec so you may simply execute `jspec` in order to bind execution
95
+ of your specs when a file is altered.
96
+
97
+ JSpec supports Rhino execution when installed. The [path] is assumed
98
+ to be spec/spec.rhino.js unless specified. See examples below for
99
+ using the --rhino switch.
100
+
101
+ JSpec\'s server is also available via --server, which defaults
102
+ the [path] to spec/server.html'
103
+ c.example 'Run once in Safari', 'jspec run'
104
+ c.example 'Run once in Safari and Firefox', 'jspec run --browsers Safari,Firefox'
105
+ c.example 'Run once in Opera, Firefox, and Chrome', 'jspec run --browsers opera,ff,chrome'
106
+ c.example 'Run custom spec file', 'jspec run foo.html'
107
+ c.example 'Auto-run browsers when a file is altered', 'jspec run --bind --browsers Safari,Firefox'
108
+ c.example 'Shortcut for the previous example', 'jspec --browsers Safari,Firefox'
109
+ c.example 'Auto-run rhino when a file is altered', 'jspec --rhino'
110
+ c.example 'Run Rhino specs at spec/rhino.js', 'jspec run --rhino'
111
+ c.example 'Run Rhino specs once', 'jspec run specs/something.js --rhino'
112
+ c.option '-b', '--browsers BROWSERS', Array, 'Specify browsers to test'
113
+ c.option '-p', '--paths PATHS', Array, 'Specify paths when binding, defaults to javascript within ./lib and ./spec'
114
+ c.option '-B', '--bind', 'Auto-run specs when source files or specs are altered'
115
+ c.option '-R', '--rhino', 'Run specs using Rhino'
116
+ c.option '-S', '--server', 'Run specs using the JSpec server'
117
+ c.option '-P', '--port NUMBER', Integer, 'Start JSpec server using the given port number'
118
+ c.when_called do |args, options|
119
+
120
+ # Rails
121
+ if rails?
122
+ options.default :paths => ['public/javascripts/**/*.js', 'jspec/**/*.js'], :port => 4444
123
+ else
124
+ options.default :paths => ['lib/**/*.js', 'spec/**/*.js'], :port => 4444
125
+ end
126
+
127
+ # Actions
128
+ if options.rhino
129
+ suite = args.shift || path_to('spec.rhino.js')
130
+ action = lambda { rhino suite }
131
+ elsif options.server
132
+ raise 'Cannot use --server with --bind' if options.bind
133
+ suite = args.shift || path_to('spec.server.html')
134
+ action = lambda { start_server suite, options }
135
+ else
136
+ suite = args.shift || path_to('spec.dom.html')
137
+ browsers = browsers_for options.browsers || ['safari']
138
+ action = lambda do
139
+ browsers.each do |browser|
140
+ browser.visit File.expand_path(suite)
141
+ end
142
+ end
143
+ end
144
+
145
+ # Binding
146
+ if options.bind
147
+ listener = Bind::Listener.new :paths => options.paths, :interval => 1, :actions => [action], :debug => $stdout
148
+ listener.run!
149
+ else
150
+ action.call File.new(suite)
151
+ end
152
+ end
153
+ end
154
+ alias_command :bind, :run, '--bind'
155
+
156
+ ##
157
+ # Initialize template at _dest_.
158
+
159
+ def initialize_at dest, options
160
+ unless Dir[dest + '/*'].empty?
161
+ abort unless agree "'#{dest}' is not empty; continue? "
162
+ end
163
+
164
+ copy_template_to 'default', dest
165
+ setup_lib_dir dest, options
166
+ replace_root_in dest, 'spec/spec.dom.html', 'spec/spec.rhino.js'
167
+ end
168
+
169
+ ##
170
+ # Initialize rails template at _dest_.
171
+
172
+ def initialize_rails_at dest, options
173
+ unless looks_like_rails_root?(dest)
174
+ abort unless agree "'#{dest}' does not look like root of a rails project; continue? "
175
+ end
176
+
177
+ copy_template_to 'rails', "#{dest}/jspec"
178
+ setup_lib_dir "#{dest}/jspec", options
179
+ replace_root_in "#{dest}/jspec", 'spec.dom.html', 'spec.rhino.js'
180
+ end
181
+
182
+ ##
183
+ # Copy template _name_ to _dest_.
184
+
185
+ def copy_template_to name, dest
186
+ FileUtils.mkdir_p dest
187
+ FileUtils.cp_r path_to_template(name), dest
188
+ end
189
+
190
+ ##
191
+ # Return path to template _name_.
192
+
193
+ def path_to_template name
194
+ File.join JSPEC_ROOT, 'templates', name, '.'
195
+ end
196
+
197
+ ##
198
+ # Resolve path to _file_. Supports rails and unbound projects.
199
+
200
+ def path_to file
201
+ rails? ? "jspec/#{file}" : "spec/#{file}"
202
+ end
203
+
204
+ ##
205
+ # Execute _file_ with Rhino.
206
+
207
+ def rhino file
208
+ raise "#{file} not found" unless File.exists? file
209
+ system "#{RHINO} #{file}"
210
+ end
211
+
212
+ ##
213
+ # Start server with _suite_ html and _options_.
214
+
215
+ def start_server suite, options
216
+ set :port, options.port
217
+ set :server, 'Mongrel'
218
+ enable :sessions
219
+ disable :logging
220
+ hook = File.expand_path path_to('server.rb')
221
+ load hook if File.exists? hook
222
+ JSpec::Server.new(suite, options.port).start(options.browsers ? browsers_for(options.browsers) : nil)
223
+ end
224
+
225
+ ##
226
+ # Return array of browser instances for the given _names_.
227
+
228
+ def browsers_for names
229
+ names.map do |name|
230
+ begin
231
+ Browser.subclasses.find do |browser|
232
+ browser.matches_name? name
233
+ end.new
234
+ rescue
235
+ raise "Unsupported browser `#{name}'"
236
+ end
237
+ end
238
+ end
239
+
240
+ ##
241
+ # Check if the current directory looks like a rails app.
242
+
243
+ def rails?
244
+ File.directory? 'jspec'
245
+ end
246
+
247
+ ##
248
+ # Replace JSPEC_ROOT placeholder in _paths_ relative to _dest_.
249
+
250
+ def replace_root_in dest, *paths
251
+ if rails? && File.exist?("#{dest}/jspec/lib")
252
+ root = './jspec'
253
+ elsif File.exist?("#{dest}/spec/lib")
254
+ root = "./spec"
255
+ else
256
+ root = JSPEC_ROOT
257
+ end
258
+
259
+ paths.each do |path|
260
+ path = File.join dest, path
261
+ contents = File.read(path).gsub 'JSPEC_ROOT', root
262
+ File.open(path, 'w') { |file| file.write contents }
263
+ end
264
+ end
265
+
266
+ ##
267
+ # Update JSpec version in _paths_. Matches visionmedia-jspec-TRIPLE
268
+
269
+ def update_version_in *paths
270
+ paths.each do |path|
271
+ next unless File.exists? path
272
+ contents = File.read(path).gsub /visionmedia-jspec-(\d+\.\d+\.\d+)/, "visionmedia-jspec-#{program(:version)}"
273
+ File.open(path, 'r+'){ |file| file.write contents }
274
+ say "Updated #{path}; #{$1} -> #{program(:version)}"
275
+ end
276
+ say "Finished updating JSpec"
277
+ end
278
+
279
+ ##
280
+ # Check if _path_ looks like a rails root directory.
281
+
282
+ def looks_like_rails_root? path = '.'
283
+ File.directory? "#{path}/vendor"
284
+ end
285
+
286
+ ##
287
+ # Copy or symlink library to the specified path.
288
+
289
+ def setup_lib_dir dest, options
290
+ return unless options.symlink || options.freeze
291
+
292
+ if rails?
293
+ dest = File.join dest, "lib"
294
+ else
295
+ dest = File.join dest, "spec", "lib"
296
+ end
297
+
298
+ from = File.join JSPEC_ROOT, "lib"
299
+
300
+ if options.symlink
301
+ FileUtils.symlink from, dest, :force => true
302
+ else
303
+ FileUtils.cp_r from, dest
304
+ end
305
+ end
data/jspec.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{jspec}
5
+ s.version = "2.11.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["TJ Holowaychuk"]
9
+ s.date = %q{2009-09-21}
10
+ s.default_executable = %q{jspec}
11
+ s.description = %q{JavaScript BDD Testing Framework}
12
+ s.email = %q{tj@vision-media.ca}
13
+ s.executables = ["jspec"]
14
+ s.extra_rdoc_files = ["README.rdoc", "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", "lib/jspec.shell.js", "lib/jspec.timers.js", "lib/jspec.xhr.js"]
15
+ s.files = ["History.rdoc", "Manifest", "README.rdoc", "Rakefile", "bin/jspec", "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", "lib/jspec.shell.js", "lib/jspec.timers.js", "lib/jspec.xhr.js", "server/browsers.rb", "server/helpers.rb", "server/routes.rb", "server/server.rb", "spec/async", "spec/env.js", "spec/fixtures/test.html", "spec/fixtures/test.json", "spec/fixtures/test.xml", "spec/helpers.js", "spec/server.rb", "spec/spec.dom.html", "spec/spec.fixtures.js", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.jquery.js", "spec/spec.jquery.xhr.js", "spec/spec.js", "spec/spec.matchers.js", "spec/spec.modules.js", "spec/spec.node.js", "spec/spec.rhino.js", "spec/spec.server.html", "spec/spec.shared-behaviors.js", "spec/spec.utils.js", "spec/spec.xhr.js", "templates/default/History.rdoc", "templates/default/README.rdoc", "templates/default/lib/yourlib.core.js", "templates/default/spec/server.rb", "templates/default/spec/spec.core.js", "templates/default/spec/spec.dom.html", "templates/default/spec/spec.rhino.js", "templates/default/spec/spec.server.html", "templates/rails/server.rb", "templates/rails/spec.application.js", "templates/rails/spec.dom.html", "templates/rails/spec.rhino.js", "templates/rails/spec.server.html"]
16
+ s.homepage = %q{http://visionmedia.github.com/jspec}
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Jspec", "--main", "README.rdoc"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{jspec}
20
+ s.rubygems_version = %q{1.3.5}
21
+ s.summary = %q{JavaScript BDD Testing Framework}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
29
+ s.add_runtime_dependency(%q<json>, [">= 0"])
30
+ s.add_runtime_dependency(%q<visionmedia-commander>, [">= 3.2.9"])
31
+ s.add_runtime_dependency(%q<visionmedia-bind>, [">= 0.2.6"])
32
+ else
33
+ s.add_dependency(%q<sinatra>, [">= 0"])
34
+ s.add_dependency(%q<json>, [">= 0"])
35
+ s.add_dependency(%q<visionmedia-commander>, [">= 3.2.9"])
36
+ s.add_dependency(%q<visionmedia-bind>, [">= 0.2.6"])
37
+ end
38
+ else
39
+ s.add_dependency(%q<sinatra>, [">= 0"])
40
+ s.add_dependency(%q<json>, [">= 0"])
41
+ s.add_dependency(%q<visionmedia-commander>, [">= 3.2.9"])
42
+ s.add_dependency(%q<visionmedia-bind>, [">= 0.2.6"])
43
+ end
44
+ end
data/lib/images/bg.png ADDED
Binary file
data/lib/images/hr.png ADDED
Binary file
Binary file
Binary file
Binary file
data/lib/images/vr.png ADDED
Binary file
data/lib/jspec.css ADDED
@@ -0,0 +1,145 @@
1
+ body.jspec {
2
+ margin: 45px 0;
3
+ font: 12px "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
4
+ background: #efefef url(images/bg.png) top left repeat-x;
5
+ }
6
+ #jspec {
7
+ margin: 0 auto;
8
+ padding-top: 25px;
9
+ width: 1008px;
10
+ background: url(images/vr.png) top left repeat-y;
11
+ text-align: left;
12
+ }
13
+ #jspec-top {
14
+ position: relative;
15
+ margin: 0 auto;
16
+ width: 1008px;
17
+ height: 40px;
18
+ background: url(images/sprites.bg.png) top left no-repeat;
19
+ }
20
+ #jspec-bottom {
21
+ margin: 0 auto;
22
+ width: 1008px;
23
+ height: 15px;
24
+ background: url(images/sprites.bg.png) bottom left no-repeat;
25
+ }
26
+ #jspec .loading {
27
+ margin-top: -45px;
28
+ width: 1008px;
29
+ height: 80px;
30
+ background: url(images/loading.gif) 50% 50% no-repeat;
31
+ }
32
+ #jspec-title {
33
+ position: relative;
34
+ top: 35px;
35
+ left: 20px;
36
+ width: 160px;
37
+ font-size: 22px;
38
+ font-weight: normal;
39
+ background: url(images/sprites.png) 0 -126px no-repeat;
40
+ text-align: center;
41
+ }
42
+ #jspec-title em {
43
+ font-size: 10px;
44
+ font-style: normal;
45
+ color: #BCC8D1;
46
+ }
47
+ #jspec-report * {
48
+ margin: 0;
49
+ padding: 0;
50
+ background: none;
51
+ border: none;
52
+ }
53
+ #jspec-report {
54
+ padding: 15px 40px;
55
+ font: 11px "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
56
+ color: #7B8D9B;
57
+ }
58
+ #jspec-report.has-failures {
59
+ padding-bottom: 30px;
60
+ }
61
+ #jspec-report .hidden {
62
+ display: none;
63
+ }
64
+ #jspec-report .heading {
65
+ margin-bottom: 15px;
66
+ }
67
+ #jspec-report .heading span {
68
+ padding-right: 10px;
69
+ }
70
+ #jspec-report .heading .passes em {
71
+ color: #0ea0eb;
72
+ }
73
+ #jspec-report .heading .failures em {
74
+ color: #FA1616;
75
+ }
76
+ #jspec-report table {
77
+ width: 100%;
78
+ font-size: 11px;
79
+ border-collapse: collapse;
80
+ }
81
+ #jspec-report td {
82
+ padding: 8px;
83
+ text-indent: 30px;
84
+ color: #7B8D9B;
85
+ }
86
+ #jspec-report tr.body {
87
+ display: none;
88
+ }
89
+ #jspec-report tr.body pre {
90
+ margin: 0;
91
+ padding: 0 0 5px 25px;
92
+ }
93
+ #jspec-report tr:not(.body):hover + tr.body {
94
+ display: block;
95
+ }
96
+ #jspec-report tr td:first-child em {
97
+ font-style: normal;
98
+ font-weight: normal;
99
+ color: #7B8D9B;
100
+ }
101
+ #jspec-report tr:not(.description):hover {
102
+ text-shadow: 1px 1px 1px #fff;
103
+ background: #F2F5F7;
104
+ }
105
+ #jspec-report td + td {
106
+ padding-right: 0;
107
+ width: 15px;
108
+ }
109
+ #jspec-report td.pass {
110
+ background: url(images/sprites.png) 3px -7px no-repeat;
111
+ }
112
+ #jspec-report td.fail {
113
+ background: url(images/sprites.png) 3px -47px no-repeat;
114
+ font-weight: bold;
115
+ color: #FC0D0D;
116
+ }
117
+ #jspec-report td.requires-implementation {
118
+ background: url(images/sprites.png) 3px -87px no-repeat;
119
+ }
120
+ #jspec-report tr.description td {
121
+ margin-top: 25px;
122
+ padding-top: 25px;
123
+ font-size: 12px;
124
+ font-weight: bold;
125
+ text-indent: 0;
126
+ color: #1a1a1a;
127
+ }
128
+ #jspec-report tr.description:first-child td {
129
+ border-top: none;
130
+ }
131
+ #jspec-report .assertion {
132
+ display: block;
133
+ float: left;
134
+ margin: 0 0 0 1px;
135
+ padding: 0;
136
+ width: 1px;
137
+ height: 5px;
138
+ background: #7B8D9B;
139
+ }
140
+ #jspec-report .assertion.failed {
141
+ background: red;
142
+ }
143
+ .jspec-sandbox {
144
+ display: none;
145
+ }
@@ -0,0 +1,71 @@
1
+
2
+ // JSpec - jQuery - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
+
4
+ JSpec
5
+ .requires('jQuery', 'when using jspec.jquery.js')
6
+ .include({
7
+ name: 'jQuery',
8
+
9
+ // --- Initialize
10
+
11
+ init : function() {
12
+ jQuery.ajaxSetup({ async: false })
13
+ },
14
+
15
+ // --- Utilities
16
+
17
+ utilities : {
18
+ element: jQuery,
19
+ elements: jQuery,
20
+ sandbox : function() {
21
+ return jQuery('<div class="sandbox"></div>')
22
+ }
23
+ },
24
+
25
+ // --- Matchers
26
+
27
+ matchers : {
28
+ have_tag : "jQuery(expected, actual).length == 1",
29
+ have_one : "alias have_tag",
30
+ have_tags : "jQuery(expected, actual).length > 1",
31
+ have_many : "alias have_tags",
32
+ have_child : "jQuery(actual).children(expected).length == 1",
33
+ have_children : "jQuery(actual).children(expected).length > 1",
34
+ have_text : "jQuery(actual).text() == expected",
35
+ have_value : "jQuery(actual).val() == expected",
36
+ be_enabled : "!jQuery(actual).attr('disabled')",
37
+ have_class : "jQuery(actual).hasClass(expected)",
38
+
39
+ be_visible : function(actual) {
40
+ return jQuery(actual).css('display') != 'none' &&
41
+ jQuery(actual).css('visibility') != 'hidden' &&
42
+ jQuery(actual).attr('type') != 'hidden'
43
+ },
44
+
45
+ be_hidden : function(actual) {
46
+ return !JSpec.does(actual, 'be_visible')
47
+ },
48
+
49
+ have_classes : function(actual) {
50
+ return !JSpec.any(JSpec.argumentsToArray(arguments, 1), function(arg){
51
+ return !JSpec.does(actual, 'have_class', arg)
52
+ })
53
+ },
54
+
55
+ have_attr : function(actual, attr, value) {
56
+ return value ? jQuery(actual).attr(attr) == value:
57
+ jQuery(actual).attr(attr)
58
+ },
59
+
60
+ 'be disabled selected checked' : function(attr) {
61
+ return 'jQuery(actual).attr("' + attr + '")'
62
+ },
63
+
64
+ 'have type id title alt href src sel rev name target' : function(attr) {
65
+ return function(actual, value) {
66
+ return JSpec.does(actual, 'have_attr', attr, value)
67
+ }
68
+ }
69
+ }
70
+ })
71
+