jspec-steventux 3.3.2

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.
Files changed (74) hide show
  1. data/History.md +763 -0
  2. data/Manifest +73 -0
  3. data/README.md +974 -0
  4. data/Rakefile +44 -0
  5. data/bin/jspec +178 -0
  6. data/jspec-steventux.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 +149 -0
  14. data/lib/jspec.growl.js +115 -0
  15. data/lib/jspec.jquery.js +72 -0
  16. data/lib/jspec.js +1756 -0
  17. data/lib/jspec.shell.js +39 -0
  18. data/lib/jspec.timers.js +90 -0
  19. data/lib/jspec.xhr.js +195 -0
  20. data/spec/commands/example_command.rb +19 -0
  21. data/spec/dom.html +33 -0
  22. data/spec/fixtures/test.html +1 -0
  23. data/spec/fixtures/test.json +1 -0
  24. data/spec/fixtures/test.xml +5 -0
  25. data/spec/node.js +17 -0
  26. data/spec/rhino.js +23 -0
  27. data/spec/ruby/bin/init_spec.rb +101 -0
  28. data/spec/ruby/bin/install_spec.rb +142 -0
  29. data/spec/ruby/bin/run_spec.rb +0 -0
  30. data/spec/ruby/bin/shell_spec.rb +13 -0
  31. data/spec/ruby/bin/spec_helper.rb +8 -0
  32. data/spec/ruby/bin/update_spec.rb +72 -0
  33. data/spec/server.html +29 -0
  34. data/spec/server.rb +2 -0
  35. data/spec/support/env.js +10118 -0
  36. data/spec/support/jquery.js +4376 -0
  37. data/spec/unit/helpers.js +64 -0
  38. data/spec/unit/spec.fixtures.js +17 -0
  39. data/spec/unit/spec.grammar-less.js +34 -0
  40. data/spec/unit/spec.grammar.js +241 -0
  41. data/spec/unit/spec.jquery.js +178 -0
  42. data/spec/unit/spec.jquery.xhr.js +84 -0
  43. data/spec/unit/spec.js +187 -0
  44. data/spec/unit/spec.matchers.js +577 -0
  45. data/spec/unit/spec.modules.js +51 -0
  46. data/spec/unit/spec.shared-behaviors.js +80 -0
  47. data/spec/unit/spec.utils.js +346 -0
  48. data/spec/unit/spec.xhr.js +157 -0
  49. data/src/browsers.rb +294 -0
  50. data/src/helpers.rb +67 -0
  51. data/src/installables.rb +229 -0
  52. data/src/project.rb +341 -0
  53. data/src/routes.rb +57 -0
  54. data/src/server.rb +99 -0
  55. data/support/js.jar +0 -0
  56. data/templates/default/History.md +5 -0
  57. data/templates/default/Readme.md +29 -0
  58. data/templates/default/lib/yourlib.js +2 -0
  59. data/templates/default/spec/commands/example_command.rb +19 -0
  60. data/templates/default/spec/dom.html +22 -0
  61. data/templates/default/spec/node.js +10 -0
  62. data/templates/default/spec/rhino.js +10 -0
  63. data/templates/default/spec/server.html +18 -0
  64. data/templates/default/spec/server.rb +4 -0
  65. data/templates/default/spec/unit/spec.helper.js +0 -0
  66. data/templates/default/spec/unit/spec.js +8 -0
  67. data/templates/rails/commands/example_commands.rb +19 -0
  68. data/templates/rails/dom.html +22 -0
  69. data/templates/rails/rhino.js +10 -0
  70. data/templates/rails/server.html +18 -0
  71. data/templates/rails/server.rb +4 -0
  72. data/templates/rails/unit/spec.helper.js +0 -0
  73. data/templates/rails/unit/spec.js +8 -0
  74. metadata +185 -0
@@ -0,0 +1,44 @@
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 = "S Laing (original JSpec by TJ Holowaychuk)"
12
+ p.email = "info@laingsolutions.com"
13
+ p.summary = "JavaScript BDD Testing Framework"
14
+ p.url = "http://github.com/steventux/jspec"
15
+ p.runtime_dependencies << "sinatra"
16
+ p.runtime_dependencies << "json_pure"
17
+ p.runtime_dependencies << "commander >=4.0.1"
18
+ p.runtime_dependencies << "bind >=0.2.8"
19
+ end
20
+
21
+ namespace :spec do
22
+ desc 'Run jspec executable specs'
23
+ task :bin do
24
+ sh 'spec --color --require spec/ruby/bin/spec_helper.rb spec/ruby/bin/*_spec.rb'
25
+ end
26
+ end
27
+
28
+ namespace :jspec do
29
+ desc 'CI compatible jspec task'
30
+ task :ci_report do
31
+ # Run the Jspec command and read back the output.
32
+ output = IO.popen %{cd jspec && jspec run --server}
33
+ output.readlines.each { |line|
34
+ if matches = /^.*?Passes.*?\d+m(\d+).*?Failures.*?\d+m(\d+).*?$/.match(line)
35
+ puts "Jspec Test Passes: #{matches[1]}, Failures: #{matches[2]}."
36
+ end
37
+
38
+ } unless output.nil?
39
+ end
40
+ end
41
+
42
+
43
+
44
+ task :gemspec => :build_gemspec
@@ -0,0 +1,178 @@
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/import'
8
+ require 'bind'
9
+ require 'fileutils'
10
+ require 'src/project'
11
+ require 'src/installables'
12
+ require 'src/server'
13
+
14
+ program :name, 'JSpec'
15
+ program :version, '3.3.2'
16
+ program :description, 'JavaScript BDD Testing Framework'
17
+ default_command :bind
18
+
19
+ JSpec::Project.load_commands_at '~/.jspec/commands'
20
+ JSpec::Project.load_commands_at 'spec/commands'
21
+ JSpec::Project.load_commands_at 'jspec/commands'
22
+
23
+ command :stats do |c|
24
+ c.syntax = 'jspec stats [path ...]'
25
+ c.summary = 'View javascript source statistics'
26
+ c.description = 'View statistics for the given [paths], defaulting to /lib/**/*.js'
27
+ c.example 'View stats for all /lib javascript', 'jspec stats'
28
+ c.example 'View stats for all /public/javascript files', 'jspec stats public/javascript/*.js'
29
+ c.when_called do |paths, options|
30
+ paths = Dir['lib/**/*.js'] if paths.empty?
31
+ paths.each do |path|
32
+ contents = File.read path
33
+ say "%33s : \n" % $terminal.color(path, :bold)
34
+ say "%25s : %0.2f KiB\n" % ['size', File.size(path).to_f / 1024]
35
+ say "%25s : %d\n" % ['lines', contents.to_a.length]
36
+ say "%25s : %d\n" % ['comments', contents.scan(/\/\*.*?\*\/|\/\/.*?$/m).length]
37
+ say "%25s : %d\n" % ['functions', contents.scan(/function/i).length]
38
+ say "%25s : %d\n" % ['vars', contents.scan(/\bvar\b/).length]
39
+ say "\n"
40
+ end
41
+ end
42
+ end
43
+
44
+ command :install do |c|
45
+ c.syntax = 'jspec install <project> [dest]'
46
+ c.summary = 'Install a project such as jQuery, Prototype, Rhino, etc.'
47
+ c.description = 'Install the given <project> to [dest] or spec/support/<project>.
48
+ When --release is not specified, the latest stable release will be used.
49
+ Currently the following projects are supported:
50
+
51
+ - jquery
52
+ - jqueryui
53
+ - prototype
54
+ - mootools
55
+ - dojo
56
+ - envjs (--release not yet supported)
57
+ - rhino (--release not yet supported)'
58
+ c.option '-r', '--release STRING', 'Release version to install'
59
+ c.example 'Install jQuery to spec/support/jquery.js', 'jspec install jquery'
60
+ c.example 'Install jQuery 1.3.0 to spec/support/jquery.js', 'jspec install jquery --release 1.3.0'
61
+ c.example 'Install Prototype to spec/prototype.js', 'jspec install prototype spec'
62
+ c.example 'Install Prototype to spec/vendor/prototype.js', 'jspec install prototype spec/vendor'
63
+ c.when_called do |args, options|
64
+ name = args.shift or raise 'Project name required'
65
+ project = JSpec::Project.for '.'
66
+ if dest = args.shift
67
+ project.install name, :to => dest, :release => options.release
68
+ else
69
+ Dir.mkdir project.normalize('support') unless File.directory? project.normalize('support')
70
+ project.install name, :to => project.normalize('support'), :release => options.release
71
+ end
72
+ end
73
+ end
74
+
75
+ command :init do |c|
76
+ c.syntax = 'jspec init [dest]'
77
+ c.summary = 'Initialize a JSpec project template'
78
+ c.description = 'Initialize a JSpec project template. Defaults to the current directory
79
+ when [dest] is not specified. The template includes several files for
80
+ running via Rhino, DOM, and the JSpec Rack server.
81
+
82
+ Additional switches --freeze, and --symlink are available in order
83
+ to preserve the version of JSpec at the time of initialization. Otherwise
84
+ incompatibilities from later versions may prevent your suite from
85
+ running properly.
86
+
87
+ To update a project to the recent version of JSpec use
88
+ `jspec help udpate` for more information.'
89
+ c.option '-R', '--rails', 'Initialize rails template from rails root directory'
90
+ c.option '-f', '--freeze', 'Copy the JSpec library'
91
+ c.option '-s', '--symlink', 'Symlink the JSpec library instead of copying it'
92
+ c.example 'Create a project in the current directory', 'jspec init'
93
+ c.example 'Create a directory foo, initialized with a jspec template', 'jspec init foo'
94
+ c.example 'Rails application support', 'jspec init --rails'
95
+ c.example 'Rails application support, --rails is no longer required', 'jspec init'
96
+ c.example 'Freeze JSpec\'s library at spec/lib', 'jspec init --freeze'
97
+ c.when_called do |args, options|
98
+ JSpec::Project.for(dest = args.shift || '.').init! options.__hash__
99
+ say "Template initialized at `#{dest}'"
100
+ end
101
+ end
102
+
103
+ command :shell do |c|
104
+ c.syntax = 'jspec shell [path ...]'
105
+ c.summary = 'JSpec interactive shell'
106
+ c.description = 'Launch interactive Rhino shell with jspec.js, jspec.shell.js,
107
+ and any [path]s given. Simply type "quit" or "exit" to
108
+ terminate the shell.'
109
+ c.example 'Run shell', 'jspec shell'
110
+ c.example 'Run shell with glob of files', 'jspec shell lib/*.js'
111
+ c.example 'Run shell with list of files', 'jspec shell lib/foo.js lib/bar.js'
112
+ c.when_called do |args, options|
113
+ paths = ['jspec.js', 'jspec.shell.js'] | args
114
+ paths.map! do |path|
115
+ if path.include? 'jspec.'
116
+ "-f #{JSPEC_ROOT}/lib/#{path}"
117
+ else
118
+ "-f #{path}"
119
+ end
120
+ end
121
+ say "JSpec #{program(:version)}"
122
+ `#{JSpec::Project::RHINO} #{paths.join(' ')} -f -`
123
+ end
124
+ end
125
+
126
+ command :update do |c|
127
+ c.syntax = 'jspec update [dest]'
128
+ c.summary = 'Update JSpec releases'
129
+ c.description = 'Update JSpec release relative to [dest], this will allow you
130
+ to utilize the latest JSpec features. Execute from JSpec project
131
+ root without [dest] to update the default template spec files.
132
+
133
+ This command supports regular projects, as well as those initialized
134
+ with --symlink and --freeze.'
135
+ c.example 'Update project in the current directory', 'jspec update'
136
+ c.example 'Update project in the directory specified', 'jspec update path/to/project'
137
+ c.when_called do |args, options|
138
+ JSpec::Project.for(dest = args.shift || '.').update!
139
+ end
140
+ end
141
+
142
+ command :run do |c|
143
+ c.syntax = 'jspec run [path] [options]'
144
+ c.summary = 'Run specifications'
145
+ c.description = 'Run specifications, defaulting [path] to spec/dom.html.
146
+ You will need to supply [path] if your specs do not reside
147
+ in this location. `run --bind` is the default sub-command of
148
+ jspec so you may simply execute `jspec` in order to bind execution
149
+ of your specs when a file is altered.
150
+
151
+ Rhino:
152
+ The [path] is assumed to be spec/rhino.js unless specified.
153
+
154
+ Node.js:
155
+ The [path] is assumed to be spec/node.js unless specified.
156
+
157
+ JSpec\'s server is also available via --server, which defaults
158
+ the [path] to spec/server.html'
159
+ c.example 'Run once in default browser', 'jspec run'
160
+ c.example 'Run once in Safari and Firefox', 'jspec run --browsers Safari,Firefox'
161
+ c.example 'Run once in Opera, Firefox, Chrome, and WebKit', 'jspec run --browsers opera,ff,chrome,webkit'
162
+ c.example 'Run custom spec file', 'jspec run foo.html'
163
+ c.example 'Auto-run browsers when a file is altered', 'jspec run --bind --browsers Safari,Firefox'
164
+ c.example 'Shortcut for the previous example', 'jspec --browsers Safari,Firefox'
165
+ c.example 'Run Rhino specs', 'jspec run --rhino'
166
+ c.example 'Auto-run rhino when a file is altered', 'jspec --rhino'
167
+ c.option '-b', '--browsers BROWSERS', Array, 'Specify browsers to test'
168
+ c.option '-p', '--paths PATHS', Array, 'Specify paths when binding, defaults to javascript within ./lib and ./spec'
169
+ c.option '-B', '--bind', 'Auto-run specs when source files or specs are altered'
170
+ c.option '-R', '--rhino', 'Run specs using Rhino'
171
+ c.option '-N', '--node', 'Run specs using Node.js'
172
+ c.option '-S', '--server', 'Run specs using the JSpec server'
173
+ c.option '-P', '--port NUMBER', Integer, 'Start JSpec server using the given port number'
174
+ c.when_called do |args, options|
175
+ JSpec::Project.for('.').run! args.first, options.__hash__
176
+ end
177
+ end
178
+ alias_command :bind, :run, '--bind'
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{jspec-steventux}
5
+ s.version = "3.3.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["TJ Holowaychuk, S Laing"]
9
+ s.date = %q{2010-02-25}
10
+ s.default_executable = %q{jspec}
11
+ s.description = %q{JavaScript BDD Testing Framework}
12
+ s.email = %q{info@laingsolutions.com}
13
+ s.executables = ["jspec"]
14
+ s.extra_rdoc_files = ["README.md", "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.growl.js", "lib/jspec.jquery.js", "lib/jspec.js", "lib/jspec.shell.js", "lib/jspec.timers.js", "lib/jspec.xhr.js"]
15
+ s.files = ["History.md", "Manifest", "README.md", "Rakefile", "bin/jspec", "jspec-steventux.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.growl.js", "lib/jspec.jquery.js", "lib/jspec.js", "lib/jspec.shell.js", "lib/jspec.timers.js", "lib/jspec.xhr.js", "spec/commands/example_command.rb", "spec/dom.html", "spec/fixtures/test.html", "spec/fixtures/test.json", "spec/fixtures/test.xml", "spec/node.js", "spec/rhino.js", "spec/ruby/bin/init_spec.rb", "spec/ruby/bin/install_spec.rb", "spec/ruby/bin/run_spec.rb", "spec/ruby/bin/shell_spec.rb", "spec/ruby/bin/spec_helper.rb", "spec/ruby/bin/update_spec.rb", "spec/server.html", "spec/server.rb", "spec/support/env.js", "spec/support/jquery.js", "spec/unit/helpers.js", "spec/unit/spec.fixtures.js", "spec/unit/spec.grammar-less.js", "spec/unit/spec.grammar.js", "spec/unit/spec.jquery.js", "spec/unit/spec.jquery.xhr.js", "spec/unit/spec.js", "spec/unit/spec.matchers.js", "spec/unit/spec.modules.js", "spec/unit/spec.shared-behaviors.js", "spec/unit/spec.utils.js", "spec/unit/spec.xhr.js", "src/browsers.rb", "src/helpers.rb", "src/installables.rb", "src/project.rb", "src/routes.rb", "src/server.rb", "support/js.jar", "templates/default/History.md", "templates/default/Readme.md", "templates/default/lib/yourlib.js", "templates/default/spec/commands/example_command.rb", "templates/default/spec/dom.html", "templates/default/spec/node.js", "templates/default/spec/rhino.js", "templates/default/spec/server.html", "templates/default/spec/server.rb", "templates/default/spec/unit/spec.helper.js", "templates/default/spec/unit/spec.js", "templates/rails/commands/example_commands.rb", "templates/rails/dom.html", "templates/rails/rhino.js", "templates/rails/server.html", "templates/rails/server.rb", "templates/rails/unit/spec.helper.js", "templates/rails/unit/spec.js"]
16
+ s.homepage = %q{http://github.com/steventux/jspec}
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Jspec", "--main", "README.md"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{jspec}
20
+ s.rubygems_version = %q{1.3.6}
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_pure>, [">= 0"])
30
+ s.add_runtime_dependency(%q<commander>, [">= 4.0.1"])
31
+ s.add_runtime_dependency(%q<bind>, [">= 0.2.8"])
32
+ else
33
+ s.add_dependency(%q<sinatra>, [">= 0"])
34
+ s.add_dependency(%q<json_pure>, [">= 0"])
35
+ s.add_dependency(%q<commander>, [">= 4.0.1"])
36
+ s.add_dependency(%q<bind>, [">= 0.2.8"])
37
+ end
38
+ else
39
+ s.add_dependency(%q<sinatra>, [">= 0"])
40
+ s.add_dependency(%q<json_pure>, [">= 0"])
41
+ s.add_dependency(%q<commander>, [">= 4.0.1"])
42
+ s.add_dependency(%q<bind>, [">= 0.2.8"])
43
+ end
44
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,149 @@
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
+ text-align: center;
6
+ }
7
+ #jspec {
8
+ margin: 0 auto;
9
+ padding-top: 30px;
10
+ width: 1008px;
11
+ background: url(images/vr.png) top left repeat-y;
12
+ text-align: left;
13
+ }
14
+ #jspec-top {
15
+ position: relative;
16
+ margin: 0 auto;
17
+ width: 1008px;
18
+ height: 40px;
19
+ background: url(images/sprites.bg.png) top left no-repeat;
20
+ }
21
+ #jspec-bottom {
22
+ margin: 0 auto;
23
+ width: 1008px;
24
+ height: 15px;
25
+ background: url(images/sprites.bg.png) bottom left no-repeat;
26
+ }
27
+ #jspec .loading {
28
+ margin-top: -45px;
29
+ width: 1008px;
30
+ height: 80px;
31
+ background: url(images/loading.gif) 50% 50% no-repeat;
32
+ }
33
+ #jspec-title {
34
+ position: absolute;
35
+ top: 15px;
36
+ left: 20px;
37
+ width: 160px;
38
+ font-size: 22px;
39
+ font-weight: normal;
40
+ background: url(images/sprites.png) 0 -126px no-repeat;
41
+ text-align: center;
42
+ }
43
+ #jspec-title em {
44
+ font-size: 10px;
45
+ font-style: normal;
46
+ color: #BCC8D1;
47
+ }
48
+ #jspec-report * {
49
+ margin: 0;
50
+ padding: 0;
51
+ background: none;
52
+ border: none;
53
+ }
54
+ #jspec-report {
55
+ padding: 15px 40px;
56
+ font: 11px "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
57
+ color: #7B8D9B;
58
+ }
59
+ #jspec-report.has-failures {
60
+ padding-bottom: 30px;
61
+ }
62
+ #jspec-report .hidden {
63
+ display: none;
64
+ }
65
+ #jspec-report .heading {
66
+ margin-bottom: 15px;
67
+ }
68
+ #jspec-report .heading span {
69
+ padding-right: 10px;
70
+ }
71
+ #jspec-report .heading .passes em {
72
+ color: #0ea0eb;
73
+ }
74
+ #jspec-report .heading .failures em {
75
+ color: #FA1616;
76
+ }
77
+ #jspec-report table {
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.even:hover + tr.body,
94
+ #jspec-report tr.odd:hover + tr.body {
95
+ display: block;
96
+ }
97
+ #jspec-report tr td:first-child em {
98
+ display: block;
99
+ clear: both;
100
+ font-style: normal;
101
+ font-weight: normal;
102
+ color: #7B8D9B;
103
+ }
104
+ #jspec-report tr.even:hover,
105
+ #jspec-report tr.odd:hover {
106
+ text-shadow: 1px 1px 1px #fff;
107
+ background: #F2F5F7;
108
+ }
109
+ #jspec-report td + td {
110
+ padding-right: 0;
111
+ width: 15px;
112
+ }
113
+ #jspec-report td.pass {
114
+ background: url(images/sprites.png) 3px -7px no-repeat;
115
+ }
116
+ #jspec-report td.fail {
117
+ background: url(images/sprites.png) 3px -158px no-repeat;
118
+ font-weight: bold;
119
+ color: #FC0D0D;
120
+ }
121
+ #jspec-report td.requires-implementation {
122
+ background: url(images/sprites.png) 3px -333px no-repeat;
123
+ }
124
+ #jspec-report tr.description td {
125
+ margin-top: 25px;
126
+ padding-top: 25px;
127
+ font-size: 12px;
128
+ font-weight: bold;
129
+ text-indent: 0;
130
+ color: #1a1a1a;
131
+ }
132
+ #jspec-report tr.description:first-child td {
133
+ border-top: none;
134
+ }
135
+ #jspec-report .assertion {
136
+ display: block;
137
+ float: left;
138
+ margin: 0 0 0 1px;
139
+ padding: 0;
140
+ width: 1px;
141
+ height: 5px;
142
+ background: #7B8D9B;
143
+ }
144
+ #jspec-report .assertion.failed {
145
+ background: red;
146
+ }
147
+ .jspec-sandbox {
148
+ display: none;
149
+ }
@@ -0,0 +1,115 @@
1
+
2
+ // JSpec - Growl - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
+
4
+ ;(function(){
5
+
6
+ Growl = {
7
+
8
+ // --- Version
9
+
10
+ version: '1.0.0',
11
+
12
+ /**
13
+ * Execute the given _cmd_, returning an array of lines from stdout.
14
+ *
15
+ * Examples:
16
+ *
17
+ * Growl.exec('growlnotify', '-m', msg)
18
+ *
19
+ * @param {string ...} cmd
20
+ * @return {array}
21
+ * @api public
22
+ */
23
+
24
+ exec: function(cmd) {
25
+ var lines = [], line
26
+ with (JavaImporter(java.lang, java.io)) {
27
+ var proccess = Runtime.getRuntime().exec(Array.prototype.slice.call(arguments))
28
+ var stream = new DataInputStream(proccess.getInputStream())
29
+ while (line = stream.readLine())
30
+ lines.push(line + '')
31
+ stream.close()
32
+ }
33
+ return lines
34
+ },
35
+
36
+ /**
37
+ * Return the extension of the given _path_ or null.
38
+ *
39
+ * @param {string} path
40
+ * @return {string}
41
+ * @api private
42
+ */
43
+
44
+ extname: function(path) {
45
+ return path.lastIndexOf('.') != -1 ?
46
+ path.slice(path.lastIndexOf('.') + 1, path.length) :
47
+ null
48
+ },
49
+
50
+ /**
51
+ * Version of the 'growlnotify' binary.
52
+ *
53
+ * @return {string}
54
+ * @api private
55
+ */
56
+
57
+ binVersion: function() {
58
+ try { return this.exec('growlnotify', '-v')[0].split(' ')[1] } catch (e) {}
59
+ },
60
+
61
+ /**
62
+ * Send growl notification _msg_ with _options_.
63
+ *
64
+ * Options:
65
+ *
66
+ * - title Notification title
67
+ * - sticky Make the notification stick (defaults to false)
68
+ * - name Application name (defaults to growlnotify)
69
+ * - image
70
+ * - path to an icon sets --iconpath
71
+ * - path to an image sets --image
72
+ * - capitalized word sets --appIcon
73
+ * - filename uses extname as --icon
74
+ * - otherwise treated as --icon
75
+ *
76
+ * Examples:
77
+ *
78
+ * Growl.notify('New email')
79
+ * Growl.notify('5 new emails', { title: 'Thunderbird' })
80
+ *
81
+ * @param {string} msg
82
+ * @param {options} hash
83
+ * @api public
84
+ */
85
+
86
+ notify: function(msg, options) {
87
+ options = options || {}
88
+ var args = ['growlnotify', '-m', msg]
89
+ if (!this.binVersion()) throw new Error('growlnotify executable is required')
90
+ if (image = options.image) {
91
+ var flag, ext = this.extname(image)
92
+ flag = flag || ext == 'icns' && 'iconpath'
93
+ flag = flag || /^[A-Z]/.test(image) && 'appIcon'
94
+ flag = flag || /^png|gif|jpe?g$/.test(ext) && 'image'
95
+ flag = flag || ext && (image = ext) && 'icon'
96
+ flag = flag || 'icon'
97
+ args.push('--' + flag, image)
98
+ }
99
+ if (options.sticky) args.push('--sticky')
100
+ if (options.name) args.push('--name', options.name)
101
+ if (options.title) args.push(options.title)
102
+ this.exec.apply(this, args)
103
+ }
104
+ }
105
+
106
+ JSpec.include({
107
+ name: 'Growl',
108
+ reporting: function(options){
109
+ var stats = JSpec.stats
110
+ if (stats.failures) Growl.notify('failed ' + stats.failures + ' assertions', { title: 'JSpec'})
111
+ else Growl.notify('passed ' + stats.passes + ' assertions', { title: 'JSpec' })
112
+ }
113
+ })
114
+
115
+ })()