jasmine 2.0.0 → 2.99.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 +4 -4
- data/.travis.yml +27 -13
- data/Gemfile +9 -9
- data/HOW_TO_TEST.markdown +1 -0
- data/README.markdown +18 -11
- data/jasmine.gemspec +14 -6
- data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/jasmine_examples/SpecHelper.js +1 -1
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +38 -5
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb +14 -9
- data/lib/jasmine/application.rb +2 -2
- data/lib/jasmine/asset_expander.rb +56 -8
- data/lib/jasmine/base.rb +5 -5
- data/lib/jasmine/ci_runner.rb +50 -0
- data/lib/jasmine/command_line_tool.rb +4 -4
- data/lib/jasmine/config.rb +34 -5
- data/lib/jasmine/configuration.rb +31 -11
- data/lib/jasmine/dependencies.rb +8 -37
- data/lib/jasmine/formatters/console.rb +69 -4
- data/lib/jasmine/formatters/exit_code.rb +4 -6
- data/lib/jasmine/formatters/multi.rb +3 -11
- data/lib/jasmine/path_expander.rb +5 -1
- data/lib/jasmine/path_mapper.rb +11 -2
- data/lib/jasmine/railtie.rb +1 -1
- data/lib/jasmine/result.rb +21 -9
- data/lib/jasmine/ruby_versions.rb +11 -0
- data/lib/jasmine/run.html.erb +1 -1
- data/lib/jasmine/runners/phantom_boot.js +15 -0
- data/lib/jasmine/runners/phantom_jasmine_run.js +39 -43
- data/lib/jasmine/runners/phantom_js.rb +53 -8
- data/lib/jasmine/server.rb +7 -10
- data/lib/jasmine/tasks/jasmine.rake +29 -25
- data/lib/jasmine/version.rb +1 -1
- data/lib/jasmine/yaml_config_parser.rb +28 -0
- data/lib/jasmine.rb +1 -1
- data/release_notes/v2.0.1.md +31 -0
- data/release_notes/v2.0.2.md +17 -0
- data/release_notes/v2.0.3.md +31 -0
- data/release_notes/v2.1.0.md +11 -0
- data/release_notes/v2.2.0.md +31 -0
- data/release_notes/v2.3.0.md +27 -0
- data/release_notes/v2.3.1.md +14 -0
- data/release_notes/v2.4.0.md +20 -0
- data/release_notes/v2.5.0.md +35 -0
- data/release_notes/v2.5.1.md +12 -0
- data/release_notes/v2.5.2.md +22 -0
- data/release_notes/v2.6.0.md +17 -0
- data/release_notes/v2.6.1.md +11 -0
- data/release_notes/v2.7.0.md +28 -0
- data/release_notes/v2.8.0.md +21 -0
- data/release_notes/v2.9.0.md +22 -0
- data/release_notes/v2.99.md +13 -0
- data/spec/application_integration_spec.rb +3 -3
- data/spec/application_spec.rb +27 -11
- data/spec/base_spec.rb +27 -6
- data/spec/ci_runner_spec.rb +137 -0
- data/spec/configuration_spec.rb +57 -23
- data/spec/fixture/afterall_spec.js +8 -0
- data/spec/fixture/console_log_spec.js +5 -0
- data/spec/fixture/exception_test.js +1 -0
- data/spec/fixture/phantomConfig.js +6 -0
- data/spec/fixture/viewport_spec.js +6 -0
- data/spec/jasmine_command_line_tool_spec.rb +46 -27
- data/spec/jasmine_pojs_spec.rb +73 -12
- data/spec/jasmine_rails_spec.rb +107 -41
- data/spec/lib/jasmine/formatters/console_spec.rb +124 -26
- data/spec/lib/jasmine/formatters/exit_code_spec.rb +34 -0
- data/spec/lib/jasmine/formatters/multi_spec.rb +16 -6
- data/spec/page_spec.rb +2 -2
- data/spec/path_expander_spec.rb +22 -5
- data/spec/path_mapper_spec.rb +14 -9
- data/spec/performance/phantom_js_runner_performance_spec.rb +1 -1
- data/spec/phantom_js_spec.rb +14 -0
- data/spec/rack/jasmine/runner_spec.rb +2 -2
- data/spec/result_spec.rb +17 -7
- data/spec/server_spec.rb +13 -39
- data/spec/spec_helper.rb +54 -6
- data/spec/yaml_config_parser_spec.rb +21 -21
- metadata +75 -36
- data/lib/jasmine/asset_bundle.rb +0 -68
data/spec/jasmine_rails_spec.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
require 'net/http'
|
|
3
3
|
require 'yaml'
|
|
4
|
+
require 'jasmine/ruby_versions'
|
|
4
5
|
|
|
5
|
-
if
|
|
6
|
+
if rails_available?
|
|
6
7
|
describe 'A Rails app' do
|
|
7
8
|
def bundle_install
|
|
8
9
|
tries_remaining = 3
|
|
@@ -21,29 +22,38 @@ if Jasmine::Dependencies.rails_available?
|
|
|
21
22
|
temp_dir_before
|
|
22
23
|
Dir::chdir @tmp
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
`rails new rails-example --skip-bundle --skip-active-record`
|
|
25
26
|
Dir::chdir File.join(@tmp, 'rails-example')
|
|
26
27
|
|
|
27
28
|
base = File.absolute_path(File.join(__FILE__, '../..'))
|
|
28
29
|
|
|
30
|
+
# execjs v2.2.0 is broken in rbx, locking the version to 2.0.2 for now
|
|
31
|
+
# see https://github.com/sstephenson/execjs/issues/148
|
|
32
|
+
|
|
29
33
|
open('Gemfile', 'a') { |f|
|
|
30
34
|
f.puts "gem 'jasmine', :path => '#{base}'"
|
|
31
35
|
f.puts "gem 'jasmine-core', :github => 'pivotal/jasmine'"
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
if RUBY_PLATFORM != 'java' && ENV['RAILS_VERSION'] != 'rails5'
|
|
37
|
+
f.puts "gem 'thin'"
|
|
38
|
+
end
|
|
39
|
+
f.puts "gem 'angularjs-rails'"
|
|
40
|
+
f.puts "gem 'execjs', '2.0.2'"
|
|
41
|
+
if ruby_version_less_than([2,0,0]) && ENV['RAILS_VERSION'] == 'rails3'
|
|
42
|
+
f.puts "gem 'sass', '3.4.25'"
|
|
43
|
+
end
|
|
34
44
|
f.flush
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
Bundler.with_clean_env do
|
|
38
48
|
bundle_install
|
|
39
49
|
`bundle exec rails g jasmine:install`
|
|
40
|
-
File.exists?('spec/javascripts/helpers/.gitkeep').
|
|
41
|
-
File.exists?('spec/javascripts/support/jasmine.yml').
|
|
50
|
+
expect(File.exists?('spec/javascripts/helpers/.gitkeep')).to eq true
|
|
51
|
+
expect(File.exists?('spec/javascripts/support/jasmine.yml')).to eq true
|
|
42
52
|
`bundle exec rails g jasmine:examples`
|
|
43
|
-
File.exists?('app/assets/javascripts/jasmine_examples/Player.js').
|
|
44
|
-
File.exists?('app/assets/javascripts/jasmine_examples/Song.js').
|
|
45
|
-
File.exists?('spec/javascripts/jasmine_examples/PlayerSpec.js').
|
|
46
|
-
File.exists?('spec/javascripts/helpers/jasmine_examples/SpecHelper.js').
|
|
53
|
+
expect(File.exists?('app/assets/javascripts/jasmine_examples/Player.js')).to eq true
|
|
54
|
+
expect(File.exists?('app/assets/javascripts/jasmine_examples/Song.js')).to eq true
|
|
55
|
+
expect(File.exists?('spec/javascripts/jasmine_examples/PlayerSpec.js')).to eq true
|
|
56
|
+
expect(File.exists?('spec/javascripts/helpers/jasmine_examples/SpecHelper.js')).to eq true
|
|
47
57
|
end
|
|
48
58
|
end
|
|
49
59
|
|
|
@@ -54,18 +64,17 @@ if Jasmine::Dependencies.rails_available?
|
|
|
54
64
|
it 'should have the jasmine & jasmine:ci rake task' do
|
|
55
65
|
#See https://github.com/jimweirich/rake/issues/220 and https://github.com/jruby/activerecord-jdbc-adapter/pull/467
|
|
56
66
|
#There's a workaround, but requires setting env vars & jruby opts (non-trivial when inside of a jruby process), so skip for now.
|
|
57
|
-
pending "activerecord-jdbc + rake -T doesn't work correctly under Jruby" if ENV['RAILS_VERSION'] == 'rails3' && RUBY_PLATFORM == 'java'
|
|
58
67
|
Bundler.with_clean_env do
|
|
59
68
|
output = `bundle exec rake -T`
|
|
60
|
-
output.
|
|
61
|
-
output.
|
|
69
|
+
expect(output).to include('jasmine ')
|
|
70
|
+
expect(output).to include('jasmine:ci')
|
|
62
71
|
end
|
|
63
72
|
end
|
|
64
73
|
|
|
65
74
|
it "rake jasmine:ci runs and returns expected results" do
|
|
66
75
|
Bundler.with_clean_env do
|
|
67
76
|
output = `bundle exec rake jasmine:ci`
|
|
68
|
-
output.
|
|
77
|
+
expect(output).to include('5 specs, 0 failures')
|
|
69
78
|
end
|
|
70
79
|
end
|
|
71
80
|
|
|
@@ -76,8 +85,20 @@ if Jasmine::Dependencies.rails_available?
|
|
|
76
85
|
jasmine_config['spec_files'] << 'failing_test.js'
|
|
77
86
|
end
|
|
78
87
|
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{failing_yaml}`
|
|
79
|
-
|
|
80
|
-
output.
|
|
88
|
+
expect($?).to_not be_success
|
|
89
|
+
expect(output).to include('6 specs, 1 failure')
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "rake jasmine:ci runs specs when an error occurs in the javascript" do
|
|
94
|
+
Bundler.with_clean_env do
|
|
95
|
+
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'exception_test.js'), File.join('spec', 'javascripts'))
|
|
96
|
+
exception_yaml = custom_jasmine_config('exception') do |jasmine_config|
|
|
97
|
+
jasmine_config['spec_files'] << 'exception_test.js'
|
|
98
|
+
end
|
|
99
|
+
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{exception_yaml}`
|
|
100
|
+
expect($?).to be_success
|
|
101
|
+
expect(output).to include('5 specs, 0 failures')
|
|
81
102
|
end
|
|
82
103
|
end
|
|
83
104
|
|
|
@@ -89,7 +110,7 @@ if Jasmine::Dependencies.rails_available?
|
|
|
89
110
|
|
|
90
111
|
Bundler.with_clean_env do
|
|
91
112
|
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{coffee_yaml}`
|
|
92
|
-
output.
|
|
113
|
+
expect(output).to include('6 specs, 0 failures')
|
|
93
114
|
end
|
|
94
115
|
end
|
|
95
116
|
|
|
@@ -99,15 +120,80 @@ if Jasmine::Dependencies.rails_available?
|
|
|
99
120
|
f.flush
|
|
100
121
|
}
|
|
101
122
|
|
|
123
|
+
open('spec/javascripts/helpers/angular_helper.js', 'w') { |f|
|
|
124
|
+
f.puts "//= require angular-mocks"
|
|
125
|
+
f.flush
|
|
126
|
+
}
|
|
127
|
+
|
|
102
128
|
css_yaml = custom_jasmine_config('css') do |jasmine_config|
|
|
103
|
-
jasmine_config['src_files'] = [
|
|
129
|
+
jasmine_config['src_files'] = %w[assets/application.js http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js]
|
|
104
130
|
jasmine_config['stylesheets'] = ['assets/application.css']
|
|
105
131
|
end
|
|
106
132
|
|
|
133
|
+
run_jasmine_server("JASMINE_CONFIG_PATH=#{css_yaml}") do
|
|
134
|
+
output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
|
|
135
|
+
expect(output).to match(%r{script src.*/assets/jasmine_examples/Player\.js})
|
|
136
|
+
expect(output).to match(%r{script src=['"]http://ajax\.googleapis\.com/ajax/libs/jquery/1\.11\.0/jquery\.min\.js})
|
|
137
|
+
expect(output).to match(%r{script src.*/assets/jasmine_examples/Song\.js})
|
|
138
|
+
expect(output).to match(%r{script src.*angular_helper\.js})
|
|
139
|
+
expect(output).to match(%r{<link rel=.stylesheet.*?href=./assets/foo\.css\?.*?>})
|
|
140
|
+
|
|
141
|
+
output = Net::HTTP.get(URI.parse('http://localhost:8888/__spec__/helpers/angular_helper.js'))
|
|
142
|
+
expect(output).to match(/angular\.mock/)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it "sets assets_prefix when using sprockets" do
|
|
147
|
+
open('app/assets/stylesheets/assets_prefix.js.erb', 'w') { |f|
|
|
148
|
+
f.puts "<%= assets_prefix %>"
|
|
149
|
+
f.flush
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
run_jasmine_server do
|
|
153
|
+
output = Net::HTTP.get(URI.parse('http://localhost:8888/assets/assets_prefix.js'))
|
|
154
|
+
expect(output).to match("/assets")
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "should load js files outside of the assets path too" do
|
|
159
|
+
yaml = custom_jasmine_config('public-assets') do |jasmine_config|
|
|
160
|
+
jasmine_config['src_files'] << 'public/javascripts/**/*.js'
|
|
161
|
+
jasmine_config['spec_files'] = ['non_asset_pipeline_test.js']
|
|
162
|
+
end
|
|
163
|
+
FileUtils.mkdir_p(File.join('public', 'javascripts'))
|
|
164
|
+
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline.js'), File.join('public', 'javascripts'))
|
|
165
|
+
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline_test.js'), File.join('spec', 'javascripts'))
|
|
166
|
+
|
|
167
|
+
Bundler.with_clean_env do
|
|
168
|
+
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{yaml}`
|
|
169
|
+
expect(output).to include('1 spec, 0 failures')
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "should pass custom rack options from jasmine.yml" do
|
|
174
|
+
pending "we're testing this with thin, which doesn't work in jruby" if RUBY_PLATFORM == 'java'
|
|
175
|
+
rack_yaml = custom_jasmine_config('custom_rack') do |jasmine_config|
|
|
176
|
+
jasmine_config['rack_options'] = { 'server' => 'webrick' }
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
Bundler.with_clean_env do
|
|
180
|
+
default_output = `bundle exec rake jasmine:ci`
|
|
181
|
+
if ENV['RAILS_VERSION'] == 'rails5' || ENV['RAILS_VERSION'].nil?
|
|
182
|
+
expect(default_output).to include('Puma starting')
|
|
183
|
+
else
|
|
184
|
+
expect(default_output).to include('Thin web server')
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
custom_output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{rack_yaml} 2>&1`
|
|
188
|
+
expect(custom_output).to include("WEBrick")
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def run_jasmine_server(options = "")
|
|
107
193
|
Bundler.with_clean_env do
|
|
108
194
|
begin
|
|
109
|
-
pid = IO.popen("bundle exec rake jasmine
|
|
110
|
-
Jasmine::wait_for_listener(8888, '
|
|
195
|
+
pid = IO.popen("bundle exec rake jasmine #{options}").pid
|
|
196
|
+
Jasmine::wait_for_listener(8888, 'localhost', 60)
|
|
111
197
|
|
|
112
198
|
# if the process we started is not still running, it's very likely this test
|
|
113
199
|
# will fail because another server is already running on port 8888
|
|
@@ -116,13 +202,8 @@ if Jasmine::Dependencies.rails_available?
|
|
|
116
202
|
`kill -0 #{pid}`
|
|
117
203
|
unless $?.success?
|
|
118
204
|
puts "someone else is running a server on port 8888"
|
|
119
|
-
|
|
205
|
+
expect($?).to be_success
|
|
120
206
|
end
|
|
121
|
-
|
|
122
|
-
output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
|
|
123
|
-
output.should match(%r{script src.*/assets/jasmine_examples/Player.js})
|
|
124
|
-
output.should match(%r{script src.*/assets/jasmine_examples/Song.js})
|
|
125
|
-
output.should match(%r{<link rel=.stylesheet.*?href=./assets/foo.css\?.*?>})
|
|
126
207
|
ensure
|
|
127
208
|
Process.kill(:SIGINT, pid)
|
|
128
209
|
begin
|
|
@@ -132,20 +213,5 @@ if Jasmine::Dependencies.rails_available?
|
|
|
132
213
|
end
|
|
133
214
|
end
|
|
134
215
|
end
|
|
135
|
-
|
|
136
|
-
it "should load js files outside of the assets path too" do
|
|
137
|
-
yaml = custom_jasmine_config('public-assets') do |jasmine_config|
|
|
138
|
-
jasmine_config['src_files'] << 'public/javascripts/**/*.js'
|
|
139
|
-
jasmine_config['spec_files'] = ['non_asset_pipeline_test.js']
|
|
140
|
-
end
|
|
141
|
-
FileUtils.mkdir_p(File.join('public', 'javascripts'))
|
|
142
|
-
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline.js'), File.join('public', 'javascripts'))
|
|
143
|
-
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline_test.js'), File.join('spec', 'javascripts'))
|
|
144
|
-
|
|
145
|
-
Bundler.with_clean_env do
|
|
146
|
-
output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{yaml}`
|
|
147
|
-
output.should include('1 spec, 0 failures')
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
216
|
end
|
|
151
217
|
end
|
|
@@ -3,38 +3,74 @@ require 'spec_helper'
|
|
|
3
3
|
describe Jasmine::Formatters::Console do
|
|
4
4
|
|
|
5
5
|
let(:outputter_output) { '' }
|
|
6
|
-
let(:outputter)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
let(:outputter) do
|
|
7
|
+
double(:outputter).tap do |o|
|
|
8
|
+
allow(o).to receive(:print) { |str| outputter_output << str }
|
|
9
|
+
allow(o).to receive(:puts) { |str| outputter_output << "#{str}\n" }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
let(:run_details) { { 'order' => { 'random' => false } } }
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
describe '#format' do
|
|
15
|
+
it 'prints a dot for a successful spec' do
|
|
16
|
+
formatter = Jasmine::Formatters::Console.new(outputter)
|
|
17
|
+
formatter.format([passing_result])
|
|
18
|
+
|
|
19
|
+
expect(outputter_output).to include('.')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'prints a star for a pending spec' do
|
|
23
|
+
formatter = Jasmine::Formatters::Console.new(outputter)
|
|
24
|
+
formatter.format([pending_result])
|
|
25
|
+
|
|
26
|
+
expect(outputter_output).to include('*')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'prints an F for a failing spec' do
|
|
30
|
+
formatter = Jasmine::Formatters::Console.new(outputter)
|
|
31
|
+
formatter.format([failing_result])
|
|
32
|
+
|
|
33
|
+
expect(outputter_output).to include('F')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'prints a dot for a disabled spec' do
|
|
37
|
+
formatter = Jasmine::Formatters::Console.new(outputter)
|
|
38
|
+
formatter.format([disabled_result])
|
|
39
|
+
|
|
40
|
+
expect(outputter_output).to eq('')
|
|
15
41
|
end
|
|
16
42
|
end
|
|
17
43
|
|
|
18
44
|
describe '#summary' do
|
|
45
|
+
it 'shows the failure messages' do
|
|
46
|
+
results = [failing_result, failing_result]
|
|
47
|
+
formatter = Jasmine::Formatters::Console.new(outputter)
|
|
48
|
+
formatter.format(results)
|
|
49
|
+
formatter.done(run_details)
|
|
50
|
+
expect(outputter_output).to match(/a suite with a failing spec/)
|
|
51
|
+
expect(outputter_output).to match(/a failure message/)
|
|
52
|
+
expect(outputter_output).to match(/a stack trace/)
|
|
53
|
+
end
|
|
54
|
+
|
|
19
55
|
describe 'when the full suite passes' do
|
|
20
56
|
it 'shows the spec counts' do
|
|
21
57
|
results = [passing_result]
|
|
22
58
|
console = Jasmine::Formatters::Console.new(outputter)
|
|
23
59
|
console.format(results)
|
|
24
|
-
console.done
|
|
60
|
+
console.done(run_details)
|
|
25
61
|
|
|
26
|
-
outputter_output.
|
|
27
|
-
outputter_output.
|
|
62
|
+
expect(outputter_output).to match(/1 spec/)
|
|
63
|
+
expect(outputter_output).to match(/0 failures/)
|
|
28
64
|
end
|
|
29
65
|
|
|
30
66
|
it 'shows the spec counts (pluralized)' do
|
|
31
67
|
results = [passing_result, passing_result]
|
|
32
68
|
console = Jasmine::Formatters::Console.new(outputter)
|
|
33
69
|
console.format(results)
|
|
34
|
-
console.done
|
|
70
|
+
console.done(run_details)
|
|
35
71
|
|
|
36
|
-
outputter_output.
|
|
37
|
-
outputter_output.
|
|
72
|
+
expect(outputter_output).to match(/2 specs/)
|
|
73
|
+
expect(outputter_output).to match(/0 failures/)
|
|
38
74
|
end
|
|
39
75
|
end
|
|
40
76
|
|
|
@@ -43,20 +79,29 @@ describe Jasmine::Formatters::Console do
|
|
|
43
79
|
results = [passing_result, failing_result]
|
|
44
80
|
console = Jasmine::Formatters::Console.new(outputter)
|
|
45
81
|
console.format(results)
|
|
46
|
-
console.done
|
|
82
|
+
console.done(run_details)
|
|
47
83
|
|
|
48
|
-
outputter_output.
|
|
49
|
-
outputter_output.
|
|
84
|
+
expect(outputter_output).to match(/2 specs/)
|
|
85
|
+
expect(outputter_output).to match(/1 failure/)
|
|
50
86
|
end
|
|
51
87
|
|
|
52
88
|
it 'shows the spec counts (pluralized)' do
|
|
53
89
|
results = [failing_result, failing_result]
|
|
54
90
|
console = Jasmine::Formatters::Console.new(outputter)
|
|
55
91
|
console.format(results)
|
|
56
|
-
console.done
|
|
92
|
+
console.done(run_details)
|
|
93
|
+
|
|
94
|
+
expect(outputter_output).to match(/2 specs/)
|
|
95
|
+
expect(outputter_output).to match(/2 failures/)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'shows the failure message' do
|
|
99
|
+
results = [failing_result]
|
|
100
|
+
console = Jasmine::Formatters::Console.new(outputter)
|
|
101
|
+
console.format(results)
|
|
102
|
+
console.done(run_details)
|
|
57
103
|
|
|
58
|
-
outputter_output.
|
|
59
|
-
outputter_output.should match(/2 failures/)
|
|
104
|
+
expect(outputter_output).to match(/a failure message/)
|
|
60
105
|
end
|
|
61
106
|
end
|
|
62
107
|
|
|
@@ -65,18 +110,36 @@ describe Jasmine::Formatters::Console do
|
|
|
65
110
|
results = [passing_result, pending_result]
|
|
66
111
|
console = Jasmine::Formatters::Console.new(outputter)
|
|
67
112
|
console.format(results)
|
|
68
|
-
console.done
|
|
113
|
+
console.done(run_details)
|
|
69
114
|
|
|
70
|
-
outputter_output.
|
|
115
|
+
expect(outputter_output).to match(/1 pending spec/)
|
|
71
116
|
end
|
|
72
117
|
|
|
73
118
|
it 'shows the spec counts (pluralized)' do
|
|
74
119
|
results = [pending_result, pending_result]
|
|
75
120
|
console = Jasmine::Formatters::Console.new(outputter)
|
|
76
121
|
console.format(results)
|
|
77
|
-
console.done
|
|
122
|
+
console.done(run_details)
|
|
123
|
+
|
|
124
|
+
expect(outputter_output).to match(/2 pending specs/)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'shows the pending reason' do
|
|
128
|
+
results = [pending_result]
|
|
129
|
+
console = Jasmine::Formatters::Console.new(outputter)
|
|
130
|
+
console.format(results)
|
|
131
|
+
console.done(run_details)
|
|
78
132
|
|
|
79
|
-
outputter_output.
|
|
133
|
+
expect(outputter_output).to match(/I pend because/)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 'shows the default pending reason' do
|
|
137
|
+
results = [Jasmine::Result.new(pending_raw_result.merge('pendingReason' => ''))]
|
|
138
|
+
console = Jasmine::Formatters::Console.new(outputter)
|
|
139
|
+
console.format(results)
|
|
140
|
+
console.done(run_details)
|
|
141
|
+
|
|
142
|
+
expect(outputter_output).to match(/No reason given/)
|
|
80
143
|
end
|
|
81
144
|
end
|
|
82
145
|
|
|
@@ -86,11 +149,42 @@ describe Jasmine::Formatters::Console do
|
|
|
86
149
|
results = [passing_result]
|
|
87
150
|
console = Jasmine::Formatters::Console.new(outputter)
|
|
88
151
|
console.format(results)
|
|
89
|
-
console.done
|
|
152
|
+
console.done(run_details)
|
|
90
153
|
|
|
91
|
-
outputter_output.
|
|
154
|
+
expect(outputter_output).to_not match(/pending spec[s]/)
|
|
92
155
|
end
|
|
93
156
|
end
|
|
157
|
+
|
|
158
|
+
describe 'when the tests were randomized' do
|
|
159
|
+
it 'should print a message with the seed' do
|
|
160
|
+
results = [passing_result]
|
|
161
|
+
console = Jasmine::Formatters::Console.new(outputter)
|
|
162
|
+
console.format(results)
|
|
163
|
+
console.done({ 'order' => { 'random' => true, 'seed' => '4325' } })
|
|
164
|
+
|
|
165
|
+
expect(outputter_output).to match(/Randomized with seed 4325/)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
describe 'with errors in a global afterAll' do
|
|
170
|
+
it 'should show the errors' do
|
|
171
|
+
console = Jasmine::Formatters::Console.new(outputter)
|
|
172
|
+
console.done({ 'failedExpectations' => [{ 'message' => 'Global Failure', 'stack' => 'more info' }] })
|
|
173
|
+
|
|
174
|
+
expect(outputter_output).to match(/Error occurred in afterAll/)
|
|
175
|
+
expect(outputter_output).to match(/Global Failure/)
|
|
176
|
+
expect(outputter_output).to match(/more info/)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it 'shows deprecation warnings' do
|
|
181
|
+
console = Jasmine::Formatters::Console.new(outputter)
|
|
182
|
+
console.format([Jasmine::Result.new(deprecation_raw_result)])
|
|
183
|
+
console.done({ 'deprecationWarnings' => [{ 'message' => 'globally deprecated', 'stack' => nil }] })
|
|
184
|
+
|
|
185
|
+
expect(outputter_output).to match(/deprecated call/)
|
|
186
|
+
expect(outputter_output).to match(/globally deprecated/)
|
|
187
|
+
end
|
|
94
188
|
end
|
|
95
189
|
|
|
96
190
|
def failing_result
|
|
@@ -104,4 +198,8 @@ describe Jasmine::Formatters::Console do
|
|
|
104
198
|
def pending_result
|
|
105
199
|
Jasmine::Result.new(pending_raw_result)
|
|
106
200
|
end
|
|
201
|
+
|
|
202
|
+
def disabled_result
|
|
203
|
+
Jasmine::Result.new(disabled_raw_result)
|
|
204
|
+
end
|
|
107
205
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Jasmine::Formatters::ExitCode do
|
|
4
|
+
subject(:formatter) { Jasmine::Formatters::ExitCode.new }
|
|
5
|
+
|
|
6
|
+
it 'is successful with no results' do
|
|
7
|
+
formatter.done({})
|
|
8
|
+
expect(formatter).to be_succeeded
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'is unsuccessful with a failure' do
|
|
12
|
+
formatter.format([double(:result, failed?: true)])
|
|
13
|
+
formatter.done({})
|
|
14
|
+
expect(formatter).not_to be_succeeded
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'finds a single failure to cause the error' do
|
|
18
|
+
formatter.format([double(failed?: false), double(failed?: false), double(failed?: true), double(failed?: false)])
|
|
19
|
+
formatter.done({})
|
|
20
|
+
expect(formatter).not_to be_succeeded
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'is unsuccessful with a failedExpectation in done' do
|
|
24
|
+
formatter.done({
|
|
25
|
+
'failedExpectations' => [{}]
|
|
26
|
+
})
|
|
27
|
+
expect(formatter).not_to be_succeeded
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'is still successful with empty failedExpectations in done' do
|
|
31
|
+
formatter.done({ 'failedExpectations' => [] })
|
|
32
|
+
expect(formatter).to be_succeeded
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -6,12 +6,22 @@ describe Jasmine::Formatters::Multi do
|
|
|
6
6
|
formatter2 = double(:formatter2)
|
|
7
7
|
multi = Jasmine::Formatters::Multi.new([formatter1, formatter2])
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
formatter2.should_receive(:format)
|
|
11
|
-
multi.format(nil)
|
|
9
|
+
results1 = double(:results1)
|
|
12
10
|
|
|
13
|
-
formatter1.
|
|
14
|
-
formatter2.
|
|
15
|
-
multi.
|
|
11
|
+
expect(formatter1).to receive(:format).with(results1)
|
|
12
|
+
expect(formatter2).to receive(:format).with(results1)
|
|
13
|
+
multi.format(results1)
|
|
14
|
+
|
|
15
|
+
results2 = double(:results1)
|
|
16
|
+
|
|
17
|
+
expect(formatter1).to receive(:format).with(results2)
|
|
18
|
+
expect(formatter2).to receive(:format).with(results2)
|
|
19
|
+
multi.format(results2)
|
|
20
|
+
|
|
21
|
+
run_details = double(:run_details)
|
|
22
|
+
|
|
23
|
+
expect(formatter1).to receive(:done).with(run_details)
|
|
24
|
+
expect(formatter2).to receive(:done).with(run_details)
|
|
25
|
+
multi.done(run_details)
|
|
16
26
|
end
|
|
17
27
|
end
|
data/spec/page_spec.rb
CHANGED
|
@@ -12,12 +12,12 @@ describe Jasmine::Page do
|
|
|
12
12
|
let(:page) { Jasmine::Page.new(context) }
|
|
13
13
|
it "should render javascript files in the correct order" do
|
|
14
14
|
js_files = subject.css("script")
|
|
15
|
-
js_files.map { |file| file["src"] }.compact.
|
|
15
|
+
expect(js_files.map { |file| file["src"] }.compact).to eq ["file1.js", "file2.js"]
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "should render css files in the correct order" do
|
|
19
19
|
css_files = subject.css("link[type='text/css']")
|
|
20
|
-
css_files.map { |file| file["href"] }.compact.
|
|
20
|
+
expect(css_files.map { |file| file["href"] }.compact).to eq ["file1.css", "file2.css"]
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
end
|
data/spec/path_expander_spec.rb
CHANGED
|
@@ -19,7 +19,7 @@ describe Jasmine::PathExpander do
|
|
|
19
19
|
dir_glob
|
|
20
20
|
)
|
|
21
21
|
|
|
22
|
-
expanded_files.
|
|
22
|
+
expect(expanded_files).to eq [
|
|
23
23
|
File.join('some_base', 'src1.js'),
|
|
24
24
|
File.join('some_base', 'src15.js'),
|
|
25
25
|
File.join('some_base', 'src2.js')
|
|
@@ -44,7 +44,7 @@ describe Jasmine::PathExpander do
|
|
|
44
44
|
dir_glob
|
|
45
45
|
)
|
|
46
46
|
|
|
47
|
-
expanded_files.
|
|
47
|
+
expect(expanded_files).to eq [
|
|
48
48
|
File.join('some_base', 'src1.js'),
|
|
49
49
|
File.join('some_base', 'src15.js'),
|
|
50
50
|
File.join('some_base', 'src2.js')
|
|
@@ -69,7 +69,7 @@ describe Jasmine::PathExpander do
|
|
|
69
69
|
dir_glob
|
|
70
70
|
)
|
|
71
71
|
|
|
72
|
-
expanded_files.
|
|
72
|
+
expect(expanded_files).to eq [
|
|
73
73
|
File.join('some_base', 'src1.js'),
|
|
74
74
|
File.join('some_base', 'src1zzz.js'),
|
|
75
75
|
File.join('some_base', 'src0.js')
|
|
@@ -96,7 +96,7 @@ describe Jasmine::PathExpander do
|
|
|
96
96
|
dir_glob
|
|
97
97
|
)
|
|
98
98
|
|
|
99
|
-
expanded_files.
|
|
99
|
+
expect(expanded_files).to eq [
|
|
100
100
|
File.join('some_base', 'src15.js'),
|
|
101
101
|
File.join('some_base', 'src2.js')
|
|
102
102
|
]
|
|
@@ -114,8 +114,25 @@ describe Jasmine::PathExpander do
|
|
|
114
114
|
dir_glob
|
|
115
115
|
)
|
|
116
116
|
|
|
117
|
-
expanded_files.
|
|
117
|
+
expect(expanded_files).to eq [
|
|
118
118
|
File.join('some_base', 'src2.js')
|
|
119
119
|
]
|
|
120
120
|
end
|
|
121
|
+
|
|
122
|
+
it "passes through files that are not found by the globber and look like urls" do
|
|
123
|
+
#this is designed to support cdn files
|
|
124
|
+
dir_glob = lambda do |pattern|
|
|
125
|
+
[]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
expanded_files = Jasmine::PathExpander.expand(
|
|
129
|
+
'some_base',
|
|
130
|
+
['http://www.google.com'],
|
|
131
|
+
dir_glob
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
expect(expanded_files).to eq [
|
|
135
|
+
'http://www.google.com'
|
|
136
|
+
]
|
|
137
|
+
end
|
|
121
138
|
end
|
data/spec/path_mapper_spec.rb
CHANGED
|
@@ -4,30 +4,35 @@ describe Jasmine::PathMapper do
|
|
|
4
4
|
it "correctly remaps src files" do
|
|
5
5
|
config = double(:config, :src_dir => '/src_dir', :src_path => '/__src__')
|
|
6
6
|
mapper = Jasmine::PathMapper.new(config)
|
|
7
|
-
mapper.map_src_paths(['/src_dir/foo']).
|
|
8
|
-
mapper.map_src_paths(['foo/bar']).
|
|
7
|
+
expect(mapper.map_src_paths(['/src_dir/foo'])).to eq ['/__src__/foo']
|
|
8
|
+
expect(mapper.map_src_paths(['foo/bar'])).to eq ['/__src__/foo/bar']
|
|
9
9
|
end
|
|
10
10
|
it "correctly remaps spec files" do
|
|
11
11
|
config = double(:config, :spec_dir => '/spec_dir', :spec_path => '/__spec__')
|
|
12
12
|
mapper = Jasmine::PathMapper.new(config)
|
|
13
|
-
mapper.map_spec_paths(['/spec_dir/foo']).
|
|
14
|
-
mapper.map_spec_paths(['foo/bar']).
|
|
13
|
+
expect(mapper.map_spec_paths(['/spec_dir/foo'])).to eq ['/__spec__/foo']
|
|
14
|
+
expect(mapper.map_spec_paths(['foo/bar'])).to eq ['/__spec__/foo/bar']
|
|
15
15
|
end
|
|
16
16
|
it "correctly remaps jasmine files" do
|
|
17
17
|
config = double(:config, :jasmine_dir => '/jasmine_dir', :jasmine_path => '/__jasmine__')
|
|
18
18
|
mapper = Jasmine::PathMapper.new(config)
|
|
19
|
-
mapper.map_jasmine_paths(['/jasmine_dir/foo']).
|
|
20
|
-
mapper.map_jasmine_paths(['foo/bar']).
|
|
19
|
+
expect(mapper.map_jasmine_paths(['/jasmine_dir/foo'])).to eq ['/__jasmine__/foo']
|
|
20
|
+
expect(mapper.map_jasmine_paths(['foo/bar'])).to eq ['/__jasmine__/foo/bar']
|
|
21
21
|
end
|
|
22
22
|
it "correctly remaps boot files" do
|
|
23
23
|
config = double(:config, :boot_dir => '/boot_dir', :boot_path => '/__boot__')
|
|
24
24
|
mapper = Jasmine::PathMapper.new(config)
|
|
25
|
-
mapper.map_boot_paths(['/boot_dir/foo']).
|
|
26
|
-
mapper.map_boot_paths(['foo/bar']).
|
|
25
|
+
expect(mapper.map_boot_paths(['/boot_dir/foo'])).to eq ['/__boot__/foo']
|
|
26
|
+
expect(mapper.map_boot_paths(['foo/bar'])).to eq ['/__boot__/foo/bar']
|
|
27
27
|
end
|
|
28
28
|
it "handles edge case where dir == path" do
|
|
29
29
|
config = double(:config, :src_dir => '/src_dir', :src_path => '/src_dir')
|
|
30
30
|
mapper = Jasmine::PathMapper.new(config)
|
|
31
|
-
mapper.map_src_paths(['/src_dir/foo']).
|
|
31
|
+
expect(mapper.map_src_paths(['/src_dir/foo'])).to eq ['/src_dir/foo']
|
|
32
|
+
end
|
|
33
|
+
it 'handles edge case with multiple instances of src dir' do
|
|
34
|
+
config = double(:config, :src_dir => '/app', :src_path => '/')
|
|
35
|
+
mapper = Jasmine::PathMapper.new(config)
|
|
36
|
+
expect(mapper.map_src_paths(['/app/assets/application.js'])).to eq ['/assets/application.js']
|
|
32
37
|
end
|
|
33
38
|
end
|
|
@@ -18,6 +18,6 @@ describe "Phantom JS Runner performance/integration suite", :performance => true
|
|
|
18
18
|
FileUtils.cp(File.join(@root, 'spec', 'fixture', 'large_test_suite_spec.js'), File.join(@tmp, 'spec', 'javascripts'))
|
|
19
19
|
|
|
20
20
|
ci_output = `rake --trace jasmine:ci`
|
|
21
|
-
ci_output.
|
|
21
|
+
expect(ci_output).to match (/40000 specs, 20000 failures/)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Jasmine::Runners::PhantomJs do
|
|
4
|
+
it 'converts a given cli options hash to a cli arguments string' do
|
|
5
|
+
options = {
|
|
6
|
+
'local-storage-quota' => 5000,
|
|
7
|
+
'local-storage-path' => 'tmp/xyz'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
phantom_js = Jasmine::Runners::PhantomJs.new(nil, nil,nil,nil, nil,nil, options)
|
|
11
|
+
|
|
12
|
+
expect(phantom_js.cli_options_string).to eq('--local-storage-quota=5000 --local-storage-path=tmp/xyz')
|
|
13
|
+
end
|
|
14
|
+
end
|