jasmine 3.4.0 → 3.8.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.
- checksums.yaml +5 -5
- data/.circleci/config.yml +84 -0
- data/.gitignore +1 -1
- data/Gemfile +4 -7
- data/README.markdown +53 -10
- data/jasmine.gemspec +6 -3
- data/lib/jasmine/asset_expander.rb +20 -4
- data/lib/jasmine/ci_runner.rb +17 -2
- data/lib/jasmine/configuration.rb +2 -0
- data/lib/jasmine/dependencies.rb +8 -2
- data/lib/jasmine/formatters/console.rb +26 -6
- data/lib/jasmine/runners/chrome_headless.rb +34 -19
- data/lib/jasmine/runners/phantom_js.rb +1 -0
- data/lib/jasmine/tasks/jasmine.rake +5 -1
- data/lib/jasmine/version.rb +1 -1
- data/release_notes/3.5.0.md +16 -0
- data/release_notes/3.5.1.md +18 -0
- data/release_notes/3.6.0.md +31 -0
- data/release_notes/3.7.0.md +7 -0
- data/release_notes/3.8.0.md +38 -0
- data/spec/ci_runner_spec.rb +143 -0
- data/spec/configuration_spec.rb +13 -0
- data/spec/jasmine_rails_spec.rb +139 -148
- data/spec/lib/jasmine/formatters/console_spec.rb +54 -20
- data/spec/spec_helper.rb +21 -0
- metadata +33 -8
- data/.travis.yml +0 -32
@@ -59,7 +59,11 @@ namespace :jasmine do
|
|
59
59
|
config = Jasmine.config
|
60
60
|
port = config.port(:server)
|
61
61
|
server = Jasmine::Server.new(port, Jasmine::Application.app(Jasmine.config), config.rack_options)
|
62
|
-
|
62
|
+
if config.random
|
63
|
+
puts "your server is running here: http://localhost:#{port}/"
|
64
|
+
else
|
65
|
+
puts "your server is running here: http://localhost:#{port}/?random=false"
|
66
|
+
end
|
63
67
|
puts "your tests are here: #{config.spec_dir}"
|
64
68
|
puts "your source files are here: #{config.src_dir}"
|
65
69
|
puts ''
|
data/lib/jasmine/version.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Jasmine Gem 3.5 Release Notes
|
2
|
+
|
3
|
+
## Summary
|
4
|
+
|
5
|
+
This release updates the jasmine-core dependency to 3.5.0. See the
|
6
|
+
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/master/release_notes/3.5.0.md)
|
7
|
+
for more information
|
8
|
+
|
9
|
+
## Changes
|
10
|
+
|
11
|
+
* Add docs for how to use the new Chrome Headless runner
|
12
|
+
- Fixes [#308](https://github.com/jasmine/jasmine-gem/issues/308)
|
13
|
+
|
14
|
+
------
|
15
|
+
|
16
|
+
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Jasmine Gem 3.5.1 Release Notes
|
2
|
+
|
3
|
+
## Summary
|
4
|
+
|
5
|
+
This update allows the gem to continue working with Sprockets in Rails 6
|
6
|
+
|
7
|
+
## Changes
|
8
|
+
|
9
|
+
* Various readme improvements
|
10
|
+
- Merges [#312](https://github.com/jasmine/jasmine-gem/issues/312) from @cprodhomme
|
11
|
+
|
12
|
+
* Allow Jasmine to continue to work with Rails 6
|
13
|
+
- Merges [#310](https://github.com/jasmine/jasmine-gem/issues/310) from @cbaines
|
14
|
+
- Fixes [#311](https://github.com/jasmine/jasmine-gem/issues/311)
|
15
|
+
|
16
|
+
------
|
17
|
+
|
18
|
+
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Jasmine Gem 3.6 Release Notes
|
2
|
+
|
3
|
+
## Summary
|
4
|
+
|
5
|
+
This release updates the jasmine-core dependency to 3.6.0. See the
|
6
|
+
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/3.6.0.md)
|
7
|
+
for more information
|
8
|
+
|
9
|
+
|
10
|
+
## Changes
|
11
|
+
|
12
|
+
* Change jasmine:server url depending on random flag
|
13
|
+
* Merges #317 from @vimalloc
|
14
|
+
* Fixes #307
|
15
|
+
|
16
|
+
* Fix Action View deprecation warnings in Rails 6
|
17
|
+
* Merges #318 from @pixeltrix
|
18
|
+
|
19
|
+
* Prevent race condition with Chrome Remote startup
|
20
|
+
* Merges #316 from @stoivo
|
21
|
+
|
22
|
+
* Add API to enable/disable coloring text
|
23
|
+
* Merges #313 from @soutaro
|
24
|
+
|
25
|
+
* Add support for chrome from yaourt
|
26
|
+
* Merges #315 from @TheBlackArroVV
|
27
|
+
* Fixes #314
|
28
|
+
|
29
|
+
------
|
30
|
+
|
31
|
+
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Jasmine Gem 3.8 Release Notes
|
2
|
+
|
3
|
+
## Summary
|
4
|
+
|
5
|
+
This release updates the jasmine-core dependency to 3.8.0. See the
|
6
|
+
[jasmine-core release notes](https://github.com/pivotal/jasmine/blob/main/release_notes/3.8.0.md)
|
7
|
+
for more information.
|
8
|
+
|
9
|
+
## Changes
|
10
|
+
|
11
|
+
* Ruby 3.0 compatibility
|
12
|
+
|
13
|
+
# Internal notes
|
14
|
+
|
15
|
+
* Added Ruby 2.7 and Ruby 3.0 to CI matrix
|
16
|
+
|
17
|
+
* Migrated from Travis to Circle CI
|
18
|
+
|
19
|
+
## Supported Environments
|
20
|
+
|
21
|
+
The Jasmine gem has been tested in the following environments:
|
22
|
+
|
23
|
+
| Rails version | Ruby versions |
|
24
|
+
|-----------------|---------------|
|
25
|
+
| 6 | 2.5-3.0 |
|
26
|
+
| 5 | 2.3-2.7 |
|
27
|
+
| 4 | 2.3-2.6 |
|
28
|
+
| Non-Rails usage | 2.3-3.0 |
|
29
|
+
|
30
|
+
See the
|
31
|
+
[jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/3.8.0.md)
|
32
|
+
for supported browsers.
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
------
|
37
|
+
|
38
|
+
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
data/spec/ci_runner_spec.rb
CHANGED
@@ -61,6 +61,149 @@ describe Jasmine::CiRunner do
|
|
61
61
|
expect(runner).to have_received(:run)
|
62
62
|
end
|
63
63
|
|
64
|
+
it 'instantiates all formatters' do
|
65
|
+
class SimpleFormatter1
|
66
|
+
end
|
67
|
+
|
68
|
+
class SimpleFormatter2
|
69
|
+
end
|
70
|
+
|
71
|
+
expect(config).to receive(:formatters) { [SimpleFormatter1, SimpleFormatter2] }
|
72
|
+
|
73
|
+
ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
|
74
|
+
|
75
|
+
ci_runner.run
|
76
|
+
|
77
|
+
expect(runner_factory).to have_received(:call).with(anything, anything) do |multi_formatter, url|
|
78
|
+
expect_any_instance_of(SimpleFormatter1).to receive(:format)
|
79
|
+
expect_any_instance_of(SimpleFormatter2).to receive(:format)
|
80
|
+
|
81
|
+
multi_formatter.format([])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'instantiates formatters with arguments' do
|
86
|
+
class SimpleFormatter
|
87
|
+
attr_reader :obj
|
88
|
+
def initialize(obj)
|
89
|
+
@obj = obj
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
expect(config).to receive(:formatters) { [SimpleFormatter] }
|
94
|
+
|
95
|
+
ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
|
96
|
+
|
97
|
+
ci_runner.run
|
98
|
+
|
99
|
+
expect(runner_factory).to have_received(:call).with(anything, anything) do |multi_formatter, url|
|
100
|
+
expect_any_instance_of(SimpleFormatter).to receive(:format) do |formatter, results|
|
101
|
+
expect(formatter.obj).to eq(config)
|
102
|
+
end
|
103
|
+
|
104
|
+
multi_formatter.format([])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'works with formatters that are not classes' do
|
109
|
+
class Factory1
|
110
|
+
attr_reader :called
|
111
|
+
def new
|
112
|
+
@called = true
|
113
|
+
nil
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
class Factory2
|
118
|
+
attr_reader :called
|
119
|
+
attr_reader :obj
|
120
|
+
def new(obj)
|
121
|
+
@obj = obj
|
122
|
+
@called = true
|
123
|
+
nil
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
factory1 = Factory1.new
|
128
|
+
factory2 = Factory2.new
|
129
|
+
|
130
|
+
expect(config).to receive(:formatters) { [factory1, factory2] }
|
131
|
+
|
132
|
+
ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
|
133
|
+
|
134
|
+
ci_runner.run
|
135
|
+
|
136
|
+
expect(factory1.called).to eq(true)
|
137
|
+
expect(factory2.called).to eq(true)
|
138
|
+
expect(factory2.obj).to eq(config)
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'handles optional arguments by only passing config when it is required' do
|
142
|
+
class NoConfigFormatter
|
143
|
+
attr_reader :optional
|
144
|
+
def initialize(optional = {config: 'no'})
|
145
|
+
@optional = optional
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
class HasConfigFormatter
|
150
|
+
attr_reader :obj, :optional
|
151
|
+
def initialize(obj, optional = {config: 'no'})
|
152
|
+
@obj = obj
|
153
|
+
@optional = optional
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
class NoConfigFactory
|
158
|
+
def initialize(dummy_formatter)
|
159
|
+
@dummy_formatter = dummy_formatter
|
160
|
+
end
|
161
|
+
attr_reader :optional
|
162
|
+
def new(optional = {config: 'no'})
|
163
|
+
@optional = optional
|
164
|
+
@dummy_formatter
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
class HasConfigFactory
|
169
|
+
def initialize(dummy_formatter)
|
170
|
+
@dummy_formatter = dummy_formatter
|
171
|
+
end
|
172
|
+
attr_reader :obj, :optional
|
173
|
+
def new(obj, optional = {config: 'no'})
|
174
|
+
@obj = obj
|
175
|
+
@optional = optional
|
176
|
+
@dummy_formatter
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
no_config_factory = NoConfigFactory.new(double(:formatter, format: nil))
|
181
|
+
has_config_factory = HasConfigFactory.new(double(:formatter, format: nil))
|
182
|
+
|
183
|
+
expect(config).to receive(:formatters) { [NoConfigFormatter, HasConfigFormatter, no_config_factory, has_config_factory] }
|
184
|
+
|
185
|
+
ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
|
186
|
+
|
187
|
+
ci_runner.run
|
188
|
+
|
189
|
+
expect(no_config_factory.optional).to eq({config: 'no'})
|
190
|
+
expect(has_config_factory.optional).to eq({config: 'no'})
|
191
|
+
expect(has_config_factory.obj).to eq(config)
|
192
|
+
|
193
|
+
expect(runner_factory).to have_received(:call).with(anything, anything) do |multi_formatter, url|
|
194
|
+
expect_any_instance_of(NoConfigFormatter).to receive(:format) do |formatter, results|
|
195
|
+
expect(formatter.optional).to eq({config: 'no'})
|
196
|
+
end
|
197
|
+
|
198
|
+
expect_any_instance_of(HasConfigFormatter).to receive(:format) do |formatter, results|
|
199
|
+
expect(formatter.optional).to eq({config: 'no'})
|
200
|
+
expect(formatter.obj).to eq(config)
|
201
|
+
end
|
202
|
+
|
203
|
+
multi_formatter.format([])
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
64
207
|
it 'adds runner boot files when necessary' do
|
65
208
|
expect(runner).to receive(:boot_js).at_least(:once) { 'foo/bar/baz.js' }
|
66
209
|
expect(config).to receive(:runner_boot_dir=).with('foo/bar')
|
data/spec/configuration_spec.rb
CHANGED
@@ -215,5 +215,18 @@ describe Jasmine::Configuration do
|
|
215
215
|
config.runner.call('hi')
|
216
216
|
end
|
217
217
|
end
|
218
|
+
|
219
|
+
describe 'colorization settings' do
|
220
|
+
it 'defaults to color' do
|
221
|
+
config = Jasmine::Configuration.new
|
222
|
+
expect(config.color).to eq(true)
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'can be set to false' do
|
226
|
+
config = Jasmine::Configuration.new
|
227
|
+
config.color = false
|
228
|
+
expect(config.color).to eq(false)
|
229
|
+
end
|
230
|
+
end
|
218
231
|
end
|
219
232
|
|
data/spec/jasmine_rails_spec.rb
CHANGED
@@ -4,10 +4,19 @@ require 'yaml'
|
|
4
4
|
require 'jasmine/ruby_versions'
|
5
5
|
|
6
6
|
if rails_available?
|
7
|
+
if !Bundler.respond_to?(:with_unbundled_env)
|
8
|
+
module Bundler
|
9
|
+
class << self
|
10
|
+
alias_method :with_unbundled_env, :with_clean_env
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
describe 'A Rails app' do
|
8
16
|
def bundle_install
|
9
|
-
|
17
|
+
bundle_output = `NOKOGIRI_USE_SYSTEM_LIBRARIES=true bundle install`
|
10
18
|
unless $?.success?
|
19
|
+
puts bundle_output
|
11
20
|
raise "Bundle failed to install."
|
12
21
|
end
|
13
22
|
end
|
@@ -16,26 +25,35 @@ if rails_available?
|
|
16
25
|
temp_dir_before
|
17
26
|
Dir::chdir @tmp
|
18
27
|
|
19
|
-
|
28
|
+
if rails_version == 'rails6'
|
29
|
+
`rails new rails-example --skip-bundle --skip-active-record --skip-bootsnap --skip-webpack-install --skip-javascript`
|
30
|
+
else
|
31
|
+
`rails new rails-example --skip-bundle --skip-active-record`
|
32
|
+
end
|
20
33
|
Dir::chdir File.join(@tmp, 'rails-example')
|
21
34
|
|
22
35
|
base = File.absolute_path(File.join(__FILE__, '../..'))
|
23
36
|
|
24
|
-
# execjs v2.2.0 is broken in rbx, locking the version to 2.0.2 for now
|
25
|
-
# see https://github.com/sstephenson/execjs/issues/148
|
26
|
-
|
27
37
|
open('Gemfile', 'a') { |f|
|
28
38
|
f.puts "gem 'jasmine', :path => '#{base}'"
|
29
|
-
f.puts "gem 'jasmine-core', :git => 'http://github.com/jasmine/jasmine.git'"
|
30
|
-
if RUBY_PLATFORM != 'java' &&
|
39
|
+
f.puts "gem 'jasmine-core', :git => 'http://github.com/jasmine/jasmine.git', ref: 'main'"
|
40
|
+
if RUBY_PLATFORM != 'java' && rails_version == 'rails4'
|
31
41
|
f.puts "gem 'thin'"
|
32
42
|
end
|
33
|
-
f.puts "gem 'angularjs-rails'"
|
34
|
-
f.puts "gem 'execjs', '2.0.2'"
|
35
43
|
f.flush
|
36
44
|
}
|
37
45
|
|
38
|
-
|
46
|
+
FileUtils.mkdir_p('.bundle')
|
47
|
+
open('.bundle/config', 'a') do |f|
|
48
|
+
f.puts(<<~YAML)
|
49
|
+
---
|
50
|
+
BUNDLE_PATH: "vendor"
|
51
|
+
BUNDLE_RETRY: "3"
|
52
|
+
YAML
|
53
|
+
f.flush
|
54
|
+
end
|
55
|
+
|
56
|
+
Bundler.with_unbundled_env do
|
39
57
|
bundle_install
|
40
58
|
`bundle exec rails g jasmine:install`
|
41
59
|
expect($?).to eq 0
|
@@ -47,6 +65,19 @@ if rails_available?
|
|
47
65
|
expect(File.exists?('spec/javascripts/jasmine_examples/PlayerSpec.js')).to eq true
|
48
66
|
expect(File.exists?('spec/javascripts/helpers/jasmine_examples/SpecHelper.js')).to eq true
|
49
67
|
end
|
68
|
+
|
69
|
+
if rails_version == 'rails6'
|
70
|
+
FileUtils.mkdir_p('app/assets/javascripts')
|
71
|
+
open('app/assets/javascripts/application.js', 'a') { |f|
|
72
|
+
f.puts '//= require_tree .'
|
73
|
+
f.flush
|
74
|
+
}
|
75
|
+
FileUtils.mkdir_p('app/assets/config')
|
76
|
+
open('app/assets/config/manifest.js', 'a') { |f|
|
77
|
+
f.puts '//= link_directory ../javascripts .js'
|
78
|
+
f.flush
|
79
|
+
}
|
80
|
+
end
|
50
81
|
end
|
51
82
|
|
52
83
|
after :all do
|
@@ -56,55 +87,23 @@ if rails_available?
|
|
56
87
|
it 'should have the jasmine & jasmine:ci rake task' do
|
57
88
|
#See https://github.com/jimweirich/rake/issues/220 and https://github.com/jruby/activerecord-jdbc-adapter/pull/467
|
58
89
|
#There's a workaround, but requires setting env vars & jruby opts (non-trivial when inside of a jruby process), so skip for now.
|
59
|
-
Bundler.
|
90
|
+
Bundler.with_unbundled_env do
|
60
91
|
output = `bundle exec rake -T`
|
61
92
|
expect(output).to include('jasmine ')
|
62
93
|
expect(output).to include('jasmine:ci')
|
63
94
|
end
|
64
95
|
end
|
65
96
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
it "rake jasmine:ci returns proper exit code when specs fail" do
|
75
|
-
Bundler.with_clean_env do
|
76
|
-
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'failing_test.js'), File.join('spec', 'javascripts'))
|
77
|
-
failing_yaml = custom_jasmine_config('failing') do |jasmine_config|
|
78
|
-
jasmine_config['spec_files'] << 'failing_test.js'
|
79
|
-
end
|
80
|
-
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{failing_yaml}`
|
81
|
-
expect($?).to_not be_success
|
82
|
-
expect(output).to include('6 specs, 1 failure')
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
it "rake jasmine:ci runs specs when an error occurs in the javascript" do
|
87
|
-
Bundler.with_clean_env do
|
88
|
-
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'exception_test.js'), File.join('spec', 'javascripts'))
|
89
|
-
exception_yaml = custom_jasmine_config('exception') do |jasmine_config|
|
90
|
-
jasmine_config['spec_files'] << 'exception_test.js'
|
91
|
-
end
|
92
|
-
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{exception_yaml}`
|
93
|
-
expect($?).to_not be_success
|
94
|
-
expect(output).to include('5 specs, 0 failures')
|
95
|
-
end
|
97
|
+
context 'with angular mocks' do
|
98
|
+
before(:all) do
|
99
|
+
open('spec/javascripts/helpers/angular_helper.js', 'w') { |f|
|
100
|
+
f.puts "//= require angular-mocks"
|
101
|
+
f.flush
|
102
|
+
}
|
96
103
|
end
|
97
104
|
|
98
|
-
|
99
|
-
|
100
|
-
jasmine_config['spec_files'] << 'coffee_spec.coffee'
|
101
|
-
end
|
102
|
-
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'coffee_spec.coffee'), File.join('spec', 'javascripts'))
|
103
|
-
|
104
|
-
Bundler.with_clean_env do
|
105
|
-
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{coffee_yaml}`
|
106
|
-
expect(output).to include('6 specs, 0 failures')
|
107
|
-
end
|
105
|
+
after(:all) do
|
106
|
+
FileUtils.rm('spec/javascripts/helpers/angular_helper.js')
|
108
107
|
end
|
109
108
|
|
110
109
|
it "rake jasmine runs and serves the expected webpage when using asset pipeline" do
|
@@ -113,114 +112,95 @@ if rails_available?
|
|
113
112
|
f.flush
|
114
113
|
}
|
115
114
|
|
116
|
-
open('spec/javascripts/helpers/angular_helper.js', 'w') { |f|
|
117
|
-
f.puts "//= require angular-mocks"
|
118
|
-
f.flush
|
119
|
-
}
|
120
|
-
|
121
115
|
css_yaml = custom_jasmine_config('css') do |jasmine_config|
|
122
116
|
jasmine_config['src_files'] = %w[assets/application.js http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js]
|
123
117
|
jasmine_config['stylesheets'] = ['assets/application.css']
|
124
118
|
end
|
125
119
|
|
120
|
+
Bundler.with_unbundled_env do
|
121
|
+
`bundle add angularjs-rails`
|
122
|
+
end
|
126
123
|
run_jasmine_server("JASMINE_CONFIG_PATH=#{css_yaml}") do
|
127
124
|
output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
|
128
|
-
|
125
|
+
if rails_version == 'rails6'
|
126
|
+
expect(output).to match(%r{script src.*/(assets/application.debug-[^\.]+\.js)})
|
127
|
+
expect(output).to match(%r{<link rel=.stylesheet.*?href=.*/assets/application.debug-[^\.]+\.css})
|
128
|
+
else
|
129
|
+
expect(output).to match(%r{script src.*/assets/jasmine_examples/Player(\.self-[^\.]+)?\.js})
|
130
|
+
expect(output).to match(%r{script src.*/assets/jasmine_examples/Song(\.self-[^\.]+)?\.js})
|
131
|
+
expect(output).to match(%r{script src.*angular_helper\.js})
|
132
|
+
expect(output).to match(%r{<link rel=.stylesheet.*?href=./assets/foo(\.self-[^\.]+)?\.css\?.*?>})
|
133
|
+
end
|
129
134
|
expect(output).to match(%r{script src=['"]http://ajax\.googleapis\.com/ajax/libs/jquery/1\.11\.0/jquery\.min\.js})
|
130
|
-
expect(output).to match(%r{script src.*/assets/jasmine_examples/Song(\.self-[^\.]+)?\.js})
|
131
|
-
expect(output).to match(%r{script src.*angular_helper\.js})
|
132
|
-
expect(output).to match(%r{<link rel=.stylesheet.*?href=./assets/foo(\.self-[^\.]+)?\.css\?.*?>})
|
133
135
|
|
134
136
|
output = Net::HTTP.get(URI.parse('http://localhost:8888/__spec__/helpers/angular_helper.js'))
|
135
137
|
expect(output).to match(/angular\.mock/)
|
136
138
|
end
|
137
139
|
end
|
140
|
+
end
|
138
141
|
|
139
|
-
|
142
|
+
context 'with an assets_prefix set' do
|
143
|
+
before(:all) do
|
140
144
|
open('app/assets/stylesheets/assets_prefix.js.erb', 'w') { |f|
|
141
145
|
f.puts "<%= assets_prefix %>"
|
142
146
|
f.flush
|
143
147
|
}
|
148
|
+
end
|
144
149
|
|
150
|
+
after(:all) do
|
151
|
+
FileUtils.rm('app/assets/stylesheets/assets_prefix.js.erb')
|
152
|
+
end
|
153
|
+
|
154
|
+
it "sets assets_prefix when using sprockets" do
|
145
155
|
run_jasmine_server do
|
146
156
|
output = Net::HTTP.get(URI.parse('http://localhost:8888/assets/assets_prefix.js'))
|
147
157
|
expect(output).to match("/assets")
|
148
158
|
end
|
149
159
|
end
|
160
|
+
end
|
150
161
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
end
|
156
|
-
FileUtils.mkdir_p(File.join('public', 'javascripts'))
|
157
|
-
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline.js'), File.join('public', 'javascripts'))
|
158
|
-
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline_test.js'), File.join('spec', 'javascripts'))
|
159
|
-
|
160
|
-
Bundler.with_clean_env do
|
161
|
-
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{yaml}`
|
162
|
-
expect(output).to include('1 spec, 0 failures')
|
163
|
-
end
|
162
|
+
it "should load js files outside of the assets path too" do
|
163
|
+
yaml = custom_jasmine_config('public-assets') do |jasmine_config|
|
164
|
+
jasmine_config['src_files'] << 'public/javascripts/**/*.js'
|
165
|
+
jasmine_config['spec_files'] = ['non_asset_pipeline_test.js']
|
164
166
|
end
|
167
|
+
FileUtils.mkdir_p(File.join('public', 'javascripts'))
|
168
|
+
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline.js'), File.join('public', 'javascripts'))
|
169
|
+
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline_test.js'), File.join('spec', 'javascripts'))
|
165
170
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
jasmine_config['rack_options'] = { 'server' => 'webrick' }
|
170
|
-
end
|
171
|
-
|
172
|
-
Bundler.with_clean_env do
|
173
|
-
default_output = `bundle exec rake jasmine:ci`
|
174
|
-
if ENV['RAILS_VERSION'] == 'rails5' || ENV['RAILS_VERSION'].nil?
|
175
|
-
expect(default_output).to include('Puma starting')
|
176
|
-
else
|
177
|
-
expect(default_output).to include('Thin web server')
|
178
|
-
end
|
179
|
-
|
180
|
-
custom_output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{rack_yaml} 2>&1`
|
181
|
-
expect(custom_output).to include("WEBrick")
|
182
|
-
end
|
171
|
+
Bundler.with_unbundled_env do
|
172
|
+
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{yaml}`
|
173
|
+
expect(output).to include('1 spec, 0 failures')
|
183
174
|
end
|
175
|
+
end
|
184
176
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
open('Gemfile', 'a') { |f|
|
191
|
-
f.puts "gem 'sprockets', '~> 4.0.0.beta6'"
|
192
|
-
f.flush
|
193
|
-
}
|
194
|
-
Bundler.with_clean_env do
|
195
|
-
bundle_install
|
196
|
-
end
|
197
|
-
|
198
|
-
FileUtils.mkdir_p('app/assets/config')
|
177
|
+
it "should pass custom rack options from jasmine.yml" do
|
178
|
+
pending "we're testing this with thin, which doesn't work in jruby" if RUBY_PLATFORM == 'java'
|
179
|
+
rack_yaml = custom_jasmine_config('custom_rack') do |jasmine_config|
|
180
|
+
jasmine_config['rack_options'] = { 'server' => 'webrick' }
|
181
|
+
end
|
199
182
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
183
|
+
Bundler.with_unbundled_env do
|
184
|
+
default_output = `bundle exec rake jasmine:ci`
|
185
|
+
if rails_version == 'rails6' || rails_version == 'rails5' || rails_version.nil?
|
186
|
+
expect(default_output).to include('Puma starting')
|
187
|
+
else
|
188
|
+
expect(default_output).to include('Thin web server')
|
205
189
|
end
|
206
190
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
Bundler.with_clean_env do
|
212
|
-
bundle_install
|
213
|
-
end
|
214
|
-
end
|
191
|
+
custom_output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{rack_yaml} 2>&1`
|
192
|
+
expect(custom_output).to include("WEBrick")
|
193
|
+
end
|
194
|
+
end
|
215
195
|
|
196
|
+
if rails_version == 'rails6'
|
197
|
+
describe 'using sprockets 4' do
|
216
198
|
it "serves source mapped assets" do
|
217
199
|
run_jasmine_server do
|
218
200
|
output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
|
219
201
|
|
220
202
|
js_match = output.match %r{script src.*/(assets/application.debug-[^\.]+\.js)}
|
221
|
-
|
222
203
|
expect(js_match).to_not be_nil
|
223
|
-
expect(output).to match(%r{<link rel=.stylesheet.*?href=.*/assets/application.debug-[^\.]+\.css})
|
224
204
|
|
225
205
|
js_path = js_match[1]
|
226
206
|
output = Net::HTTP.get(URI.parse("http://localhost:8888/#{js_path}"))
|
@@ -230,28 +210,17 @@ if rails_available?
|
|
230
210
|
end
|
231
211
|
end
|
232
212
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
f.puts "Jasmine.configure do |config|\n config.runner_browser = :chromeheadless\nend\n"
|
237
|
-
f.flush
|
238
|
-
}
|
239
|
-
end
|
240
|
-
|
241
|
-
|
242
|
-
it "rake jasmine:ci runs and returns expected results", :focus do
|
243
|
-
Bundler.with_clean_env do
|
244
|
-
`bundle add chrome_remote`
|
213
|
+
shared_examples_for 'a working jasmine:ci' do
|
214
|
+
it "rake jasmine:ci runs and returns expected results" do
|
215
|
+
Bundler.with_unbundled_env do
|
245
216
|
output = `bundle exec rake jasmine:ci`
|
246
217
|
expect(output).to include('5 specs, 0 failures')
|
247
|
-
|
218
|
+
expect($?).to be_success
|
248
219
|
end
|
249
220
|
end
|
250
221
|
|
251
222
|
it "rake jasmine:ci returns proper exit code when specs fail" do
|
252
|
-
Bundler.
|
253
|
-
`bundle add chrome_remote`
|
254
|
-
|
223
|
+
Bundler.with_unbundled_env do
|
255
224
|
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'failing_test.js'), File.join('spec', 'javascripts'))
|
256
225
|
failing_yaml = custom_jasmine_config('failing') do |jasmine_config|
|
257
226
|
jasmine_config['spec_files'] << 'failing_test.js'
|
@@ -259,13 +228,11 @@ if rails_available?
|
|
259
228
|
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{failing_yaml}`
|
260
229
|
expect($?).to_not be_success
|
261
230
|
expect(output).to include('6 specs, 1 failure')
|
262
|
-
`bundle remove chrome_remote`
|
263
231
|
end
|
264
232
|
end
|
265
233
|
|
266
234
|
it "rake jasmine:ci runs specs when an error occurs in the javascript" do
|
267
|
-
Bundler.
|
268
|
-
`bundle add chrome_remote`
|
235
|
+
Bundler.with_unbundled_env do
|
269
236
|
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'exception_test.js'), File.join('spec', 'javascripts'))
|
270
237
|
exception_yaml = custom_jasmine_config('exception') do |jasmine_config|
|
271
238
|
jasmine_config['spec_files'] << 'exception_test.js'
|
@@ -273,27 +240,51 @@ if rails_available?
|
|
273
240
|
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{exception_yaml}`
|
274
241
|
expect($?).to_not be_success
|
275
242
|
expect(output).to include('5 specs, 0 failures')
|
276
|
-
`bundle remove chrome_remote`
|
277
243
|
end
|
278
244
|
end
|
279
245
|
|
280
|
-
|
281
|
-
|
282
|
-
|
246
|
+
unless rails_version == 'rails6'
|
247
|
+
it "runs specs written in coffeescript" do
|
248
|
+
coffee_yaml = custom_jasmine_config('coffee') do |jasmine_config|
|
249
|
+
jasmine_config['spec_files'] << 'coffee_spec.coffee'
|
250
|
+
end
|
251
|
+
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'coffee_spec.coffee'), File.join('spec', 'javascripts'))
|
252
|
+
|
253
|
+
Bundler.with_unbundled_env do
|
254
|
+
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{coffee_yaml}`
|
255
|
+
expect(output).to include('6 specs, 0 failures')
|
256
|
+
expect($?).to be_success
|
257
|
+
end
|
283
258
|
end
|
284
|
-
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "with phantomJS" do
|
263
|
+
it_behaves_like 'a working jasmine:ci'
|
264
|
+
end
|
285
265
|
|
286
|
-
|
266
|
+
describe "with Chrome headless" do
|
267
|
+
before :all do
|
268
|
+
open('spec/javascripts/support/jasmine_helper.rb', 'w') { |f|
|
269
|
+
f.puts "Jasmine.configure do |config|\n config.runner_browser = :chromeheadless\nend\n"
|
270
|
+
f.flush
|
271
|
+
}
|
272
|
+
Bundler.with_unbundled_env do
|
287
273
|
`bundle add chrome_remote`
|
288
|
-
|
289
|
-
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
after :all do
|
278
|
+
Bundler.with_unbundled_env do
|
290
279
|
`bundle remove chrome_remote`
|
291
280
|
end
|
292
281
|
end
|
282
|
+
|
283
|
+
it_behaves_like 'a working jasmine:ci'
|
293
284
|
end
|
294
285
|
|
295
286
|
def run_jasmine_server(options = "")
|
296
|
-
Bundler.
|
287
|
+
Bundler.with_unbundled_env do
|
297
288
|
begin
|
298
289
|
pid = IO.popen("bundle exec rake jasmine #{options}").pid
|
299
290
|
Jasmine::wait_for_listener(8888, 'localhost', 60)
|