jasmine-rails 0.8.1 → 0.9.0
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/README.md
CHANGED
@@ -129,8 +129,8 @@ Again, it's the opinion of the present author that this shouldn't be necessary i
|
|
129
129
|
|
130
130
|
### Custom Helpers
|
131
131
|
|
132
|
-
If you need to write a custom spec runner template (for example, using requireJS to load components from your specs), you might
|
133
|
-
custom helper functions. The controller will attempt to load JasmineRails::SpecHelper if it exists. An example:
|
132
|
+
If you need to write a custom spec runner template (for example, using requireJS to load components from your specs), you might benefit from
|
133
|
+
custom helper functions. The controller will attempt to load `JasmineRails::SpecHelper` if it exists. An example:
|
134
134
|
|
135
135
|
```ruby
|
136
136
|
# in lib/jasmine_rails/spec_helper.rb
|
@@ -143,13 +143,15 @@ Module JasmineRails
|
|
143
143
|
end
|
144
144
|
```
|
145
145
|
|
146
|
-
Create a custom layout in app/layouts/jasmine_rails/spec_runner.html.erb and reference your helper
|
146
|
+
Create a custom layout in app/layouts/jasmine_rails/spec_runner.html.erb and reference your helper:
|
147
|
+
|
147
148
|
```erb
|
148
149
|
<%= custom_function %>
|
149
150
|
```
|
150
151
|
|
151
|
-
If you wanted to do something like this using requirejs-rails
|
152
|
-
might look like this
|
152
|
+
If you wanted to do something like this using [requirejs-rails](https://github.com/jwhitley/requirejs-rails), your helper
|
153
|
+
might look like this:
|
154
|
+
|
153
155
|
```
|
154
156
|
|
155
157
|
# in lib/jasmine_rails_spec_helper.rb
|
@@ -161,7 +163,7 @@ Module JasmineRails
|
|
161
163
|
end
|
162
164
|
```
|
163
165
|
|
164
|
-
Remove any reference to src_files in `spec/javascripts/support/jasmine.yml`, to ensure files aren't loaded prematurely
|
166
|
+
Remove any reference to `src_files` in `spec/javascripts/support/jasmine.yml`, to ensure files aren't loaded prematurely.
|
165
167
|
|
166
168
|
Create your custom layout `app/layouts/jasmine_rails/spec_runner.html.erb` like so:
|
167
169
|
```erb
|
@@ -184,7 +186,7 @@ Create your custom layout `app/layouts/jasmine_rails/spec_runner.html.erb` like
|
|
184
186
|
|
185
187
|
```
|
186
188
|
|
187
|
-
Use require with a callback to load your components
|
189
|
+
Use require with a callback to load your components:
|
188
190
|
|
189
191
|
```coffeescript
|
190
192
|
|
@@ -193,3 +195,30 @@ describe 'test my module', ->
|
|
193
195
|
it 'does something', ->
|
194
196
|
expect(Module.method).toEqual 'something'
|
195
197
|
```
|
198
|
+
|
199
|
+
### Custom Reporter
|
200
|
+
|
201
|
+
You can configure custom reporter files to use when running from the
|
202
|
+
command line in `jasmine.yml`:
|
203
|
+
|
204
|
+
```yml
|
205
|
+
reporters:
|
206
|
+
cool-reporter:
|
207
|
+
- "cool-reporter.js"
|
208
|
+
awesome-reporter:
|
209
|
+
- "awesome-part-1.js"
|
210
|
+
- "awesome-part-2.js"
|
211
|
+
```
|
212
|
+
|
213
|
+
Then, specify which reporters to use when you run the rake task:
|
214
|
+
|
215
|
+
```
|
216
|
+
RAILS_ENV=test REPORTERS='cool-reporter,awesome-reporter' rake spec:javascripts
|
217
|
+
```
|
218
|
+
|
219
|
+
The console reporter shipped with jasmine-rails will be used by
|
220
|
+
default, and you can explicitly use it by the name `console`.
|
221
|
+
|
222
|
+
See [jasmine-junitreporter][j-junit] for an example with JUnit output.
|
223
|
+
|
224
|
+
[j-junit]: https://github.com/shepmaster/jasmine-junitreporter-gem
|
@@ -16,16 +16,13 @@ module JasmineRails
|
|
16
16
|
# all files are fetched through the Rails asset pipeline
|
17
17
|
# includes:
|
18
18
|
# * core jasmine libraries
|
19
|
-
# * (optional)
|
19
|
+
# * (optional) reporter libraries
|
20
20
|
# * jasmine-boot.js test runner
|
21
21
|
# * jasmine-specs.js built by asset pipeline which merges application specific libraries and specs
|
22
22
|
def jasmine_js_files
|
23
23
|
files = Jasmine::Core.js_files
|
24
24
|
files << jasmine_boot_file
|
25
|
-
|
26
|
-
files << 'jasmine-console-shims.js'
|
27
|
-
files << 'jasmine-console-reporter.js'
|
28
|
-
end
|
25
|
+
files += JasmineRails.reporter_files params[:reporters]
|
29
26
|
files << 'jasmine-specs.js'
|
30
27
|
files
|
31
28
|
end
|
data/lib/jasmine-rails.rb
CHANGED
@@ -2,6 +2,8 @@ require "jasmine_rails/engine"
|
|
2
2
|
|
3
3
|
module JasmineRails
|
4
4
|
DEFAULT_TMP_DIR = 'tmp/jasmine'
|
5
|
+
CONSOLE_REPORTERS = {'console' => ['jasmine-console-shims.js',
|
6
|
+
'jasmine-console-reporter.js']}
|
5
7
|
class << self
|
6
8
|
# return the relative path to access the spec runner
|
7
9
|
# for the host Rails application
|
@@ -29,6 +31,15 @@ module JasmineRails
|
|
29
31
|
Rails.root.join(path)
|
30
32
|
end
|
31
33
|
|
34
|
+
def reporter_files(types_string)
|
35
|
+
types = types_string.to_s.split(',')
|
36
|
+
|
37
|
+
reporters = jasmine_config['reporters'] || {}
|
38
|
+
reporters = reporters.merge(JasmineRails::CONSOLE_REPORTERS)
|
39
|
+
|
40
|
+
reporters.values_at(*types).compact.flatten
|
41
|
+
end
|
42
|
+
|
32
43
|
# returns list of all files to be included into the jasmine testsuite
|
33
44
|
# includes:
|
34
45
|
# * application src_files
|
data/lib/jasmine_rails/runner.rb
CHANGED
@@ -5,13 +5,13 @@ module JasmineRails
|
|
5
5
|
class << self
|
6
6
|
# Run the Jasmine testsuite via phantomjs CLI
|
7
7
|
# raises an exception if any errors are encountered while running the testsuite
|
8
|
-
def run(spec_filter = nil)
|
8
|
+
def run(spec_filter = nil, reporters = 'console')
|
9
9
|
override_rails_config do
|
10
10
|
require 'phantomjs'
|
11
11
|
require 'fileutils'
|
12
12
|
|
13
13
|
include_offline_asset_paths_helper
|
14
|
-
html = get_spec_runner(spec_filter)
|
14
|
+
html = get_spec_runner(spec_filter, reporters)
|
15
15
|
FileUtils.mkdir_p JasmineRails.tmp_dir
|
16
16
|
runner_path = JasmineRails.tmp_dir.join('runner.html')
|
17
17
|
asset_prefix = Rails.configuration.assets.prefix.gsub(/\A\//,'')
|
@@ -51,12 +51,12 @@ module JasmineRails
|
|
51
51
|
ActionController::Base.asset_host = original_assets_host
|
52
52
|
end
|
53
53
|
|
54
|
-
def get_spec_runner(spec_filter)
|
54
|
+
def get_spec_runner(spec_filter, reporters)
|
55
55
|
app = ActionDispatch::Integration::Session.new(Rails.application)
|
56
56
|
app.https!(JasmineRails.force_ssl)
|
57
57
|
path = JasmineRails.route_path
|
58
58
|
JasmineRails::OfflineAssetPaths.disabled = false
|
59
|
-
app.get path, :
|
59
|
+
app.get path, :reporters => reporters, :spec => spec_filter
|
60
60
|
JasmineRails::OfflineAssetPaths.disabled = true
|
61
61
|
unless app.response.success?
|
62
62
|
raise "Jasmine runner at '#{path}' returned a #{app.response.status} error: #{app.response.message} \n\n" +
|
@@ -4,7 +4,8 @@ namespace :spec do
|
|
4
4
|
task :javascript => [:environment] do
|
5
5
|
require 'jasmine_rails/runner'
|
6
6
|
spec_filter = ENV['SPEC']
|
7
|
-
|
7
|
+
reporters = ENV.fetch('REPORTERS', 'console')
|
8
|
+
JasmineRails::Runner.run spec_filter, reporters
|
8
9
|
end
|
9
10
|
|
10
11
|
# alias
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-05-
|
14
|
+
date: 2014-05-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: railties
|
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
segments:
|
151
151
|
- 0
|
152
|
-
hash:
|
152
|
+
hash: -2099432972387832543
|
153
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
154
|
none: false
|
155
155
|
requirements:
|
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
segments:
|
160
160
|
- 0
|
161
|
-
hash:
|
161
|
+
hash: -2099432972387832543
|
162
162
|
requirements: []
|
163
163
|
rubyforge_project:
|
164
164
|
rubygems_version: 1.8.23
|