jasmine 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e2aa3419479e90f0e0c44c799cef453b0596848
4
- data.tar.gz: 9ec54fbc88569f3e454cb6127d93b1e6ef2c32da
3
+ metadata.gz: 573d809d765f48020312d811f92cd6bdf06a886d
4
+ data.tar.gz: da52c0fb175781046c1bbf8c4ff8191f6ce0ca45
5
5
  SHA512:
6
- metadata.gz: 1d48fda1b04bbc1b5addf9e7cdd44ba92afd7d89252e6c622432343671ee85798d82798b65cdf87c5bb23106337319b673175f71e6f6233eb0cbc14393f692a5
7
- data.tar.gz: 525a1ab24058cfa8ed1e27e6fc56bc7e23ad1ec15188e9bf7bc18f52024f30bba9b9fb7aee2a1969d2d461edfb32fc48ced9cc10579fdf7614723b09cf4fc0ff
6
+ metadata.gz: e3c51f2e936b5e4d7bc5a3eca0f8be430f77867a357c0d6bc20d5d024b1135a4681124f0ebf84b1450ec681836299ecdf9ee2a6d876c7ceb77c0e81e90ab39e7
7
+ data.tar.gz: bb5a4f560ed5924e97ebb1363facf140968e8173e6224b5b314cd77cca273b223423006fab49035040696faa0fa7309835ce1239f40769decaf52e252f6c6d9b
@@ -2,10 +2,14 @@ language: ruby
2
2
  sudo: false
3
3
  cache: bundler
4
4
 
5
+ addons:
6
+ chrome: stable
7
+
5
8
  rvm:
6
9
  - "2.3"
7
10
  - "2.4"
8
11
  - "2.5"
12
+ - "2.6"
9
13
 
10
14
  env:
11
15
  - "RAILS_VERSION=rails5"
@@ -22,5 +26,7 @@ matrix:
22
26
  - "RAILS_VERSION=rails5"
23
27
 
24
28
  before_install:
25
- - gem update --system
26
- - gem install bundler
29
+ - "if [$RAILS_VERSION != rails4 ];then gem update --system; fi"
30
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
31
+ - "if [ $RAILS_VERSION = rails4 ];then gem install bundler -v '< 2.0' ; else gem install bundler; fi"
32
+ - bundle --version
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.add_development_dependency 'rspec', '>= 2.5.0'
36
36
  s.add_development_dependency 'nokogiri'
37
37
 
38
- s.add_dependency 'jasmine-core', '~> 3.3.0'
38
+ s.add_dependency 'jasmine-core', '~> 3.4.0'
39
39
  s.add_dependency 'rack', '>= 1.2.1'
40
40
  s.add_dependency 'rake'
41
41
  s.add_dependency 'phantomjs'
@@ -18,6 +18,7 @@ jasmine_files = ['base',
18
18
  File.join('formatters', 'console'),
19
19
  File.join('formatters', 'multi'),
20
20
  File.join('runners', 'phantom_js'),
21
+ File.join('runners', 'chrome_headless'),
21
22
  ]
22
23
 
23
24
 
@@ -71,13 +71,23 @@ module Jasmine
71
71
  end
72
72
 
73
73
  @config.runner = lambda do |formatter, jasmine_server_url|
74
- Jasmine::Runners::PhantomJs.new(formatter,
75
- jasmine_server_url,
76
- @config.prevent_phantom_js_auto_install,
77
- @config.show_console_log,
78
- @config.phantom_config_script,
79
- @config.show_full_stack_trace,
80
- @config.phantom_cli_options)
74
+ case @config.runner_browser
75
+ when :phantomjs
76
+ Jasmine::Runners::PhantomJs.new(formatter,
77
+ jasmine_server_url,
78
+ @config.prevent_phantom_js_auto_install,
79
+ @config.show_console_log,
80
+ @config.phantom_config_script,
81
+ @config.show_full_stack_trace,
82
+ @config.phantom_cli_options)
83
+ when :chromeheadless
84
+ Jasmine::Runners::ChromeHeadless.new(formatter,
85
+ jasmine_server_url,
86
+ @config)
87
+ else
88
+ raise "Jasmine.config.runner_browser should be either phantomjs or chromeheadless"
89
+ end
90
+
81
91
  end
82
92
  end
83
93
 
@@ -17,7 +17,11 @@ module Jasmine
17
17
  attr_accessor :random
18
18
  attr_accessor :phantom_config_script
19
19
  attr_accessor :phantom_cli_options
20
+ attr_accessor :chrome_cli_options
21
+ attr_accessor :chrome_startup_timeout
22
+ attr_accessor :chrome_binary
20
23
  attr_accessor :show_full_stack_trace
24
+ attr_accessor :runner_browser
21
25
  attr_reader :rack_apps
22
26
 
23
27
  def initialize()
@@ -41,6 +45,10 @@ module Jasmine
41
45
  @random = true
42
46
  @phantom_config_script = nil
43
47
  @phantom_cli_options = {}
48
+ @chrome_cli_options = {"no-sandbox" => nil, "headless" => nil, "remote-debugging-port" => 9222}
49
+ @chrome_startup_timeout = 3
50
+ @chrome_binary = nil
51
+ @runner_browser = :phantomjs
44
52
 
45
53
  @formatters = [Jasmine::Formatters::Console]
46
54
 
@@ -0,0 +1,111 @@
1
+ # require 'phantomjs'
2
+ require "socket"
3
+
4
+ module Jasmine
5
+ module Runners
6
+ class ChromeHeadless
7
+ def initialize(formatter, jasmine_server_url, config)
8
+ @formatter = formatter
9
+ @jasmine_server_url = jasmine_server_url
10
+ @config = config
11
+ @show_console_log = @config.show_console_log
12
+ @show_full_stack_trace = @config.show_full_stack_trace
13
+ @cli_options = @config.chrome_cli_options || {}
14
+ end
15
+
16
+ def run
17
+ chrome_server = IO.popen("\"#{chrome_binary}\" #{cli_options_string}")
18
+ wait_for_chrome_to_start_debug_socket
19
+
20
+ begin
21
+ require "chrome_remote"
22
+ rescue LoadError => e
23
+ raise 'Add "chrome_remote" you your Gemfile. To use chromeheadless we require this gem.'
24
+ end
25
+
26
+ chrome = ChromeRemote.client
27
+ chrome.send_cmd "Runtime.enable"
28
+ chrome.send_cmd "Page.navigate", url: jasmine_server_url
29
+ result_recived = false
30
+ run_details = { 'random' => false }
31
+ chrome.on "Runtime.consoleAPICalled" do |params|
32
+ if params["type"] == "log"
33
+ if params["args"][0] && params["args"][0]["value"] == "jasmine_spec_result"
34
+ results = JSON.parse(params["args"][1]["value"], :max_nesting => false)
35
+ .map { |r| Result.new(r.merge!("show_full_stack_trace" => @show_full_stack_trace)) }
36
+ formatter.format(results)
37
+ elsif params["args"][0] && params["args"][0]["value"] == "jasmine_suite_result"
38
+ results = JSON.parse(params["args"][1]["value"], :max_nesting => false)
39
+ .map { |r| Result.new(r.merge!("show_full_stack_trace" => @show_full_stack_trace)) }
40
+ failures = results.select(&:failed?)
41
+ if failures.any?
42
+ formatter.format(failures)
43
+ end
44
+ elsif params["args"][0] && params["args"][0]["value"] == "jasmine_done"
45
+ result_recived = true
46
+ run_details = JSON.parse(params["args"][1]["value"], :max_nesting => false)
47
+ elsif show_console_log
48
+ puts params["args"].map { |e| e["value"] }.join(' ')
49
+ end
50
+ end
51
+ end
52
+
53
+ chrome.listen_until {|msg| result_recived }
54
+ formatter.done(run_details)
55
+ chrome.send_cmd "Browser.close"
56
+ Process.kill("INT", chrome_server.pid)
57
+ end
58
+
59
+ def chrome_binary
60
+ config.chrome_binary || find_chrome_binary
61
+ end
62
+
63
+ def find_chrome_binary
64
+ path = [
65
+ "/usr/bin/google-chrome",
66
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
67
+ ].detect { |path|
68
+ File.file?(path)
69
+ }
70
+ raise "No Chrome binary found" if path.nil?
71
+ path
72
+ end
73
+
74
+ def cli_options_string
75
+ @cli_options.
76
+ map {|(k, v)| if v then "--#{k}=#{v}" else "--#{k}" end }.
77
+ join(' ')
78
+ end
79
+
80
+ def wait_for_chrome_to_start_debug_socket
81
+ time = Time.now
82
+ while Time.now - time < config.chrome_startup_timeout
83
+ begin;
84
+ conn = TCPSocket.new('localhost', 9222);
85
+ rescue SocketError;
86
+ sleep 0.1
87
+ next
88
+ rescue Errno::ECONNREFUSED;
89
+ sleep 0.1
90
+ next
91
+ rescue Errno::EADDRNOTAVAIL;
92
+ sleep 0.1
93
+ next
94
+ else;
95
+ conn.close;
96
+ return
97
+ end
98
+ end
99
+ raise "Chrome did't seam to start the webSocketDebugger at port: 9222, timeout #{config.chrome_startup_timeout}sec"
100
+ end
101
+
102
+ def boot_js
103
+ File.expand_path('chromeheadless_boot.js', File.dirname(__FILE__))
104
+ end
105
+
106
+ private
107
+ attr_reader :formatter, :jasmine_server_url, :show_console_log, :config
108
+ end
109
+ end
110
+ end
111
+
@@ -0,0 +1,15 @@
1
+ function ChromeHeadlessReporter() {
2
+ this.jasmineDone = function(details) {
3
+ console.log('jasmine_done', JSON.stringify(details));
4
+ };
5
+
6
+ this.specDone = function(results) {
7
+ console.log('jasmine_spec_result', JSON.stringify([].concat(results)));
8
+ };
9
+
10
+ this.suiteDone = function(results) {
11
+ console.log('jasmine_suite_result',JSON.stringify([].concat(results)));
12
+ };
13
+ }
14
+
15
+ jasmine.getEnv().addReporter(new ChromeHeadlessReporter());
@@ -1,3 +1,3 @@
1
1
  module Jasmine
2
- VERSION = "3.3.0"
2
+ VERSION = "3.4.0"
3
3
  end
@@ -0,0 +1,17 @@
1
+ # Jasmine Gem 3.4 Release Notes
2
+
3
+ ## Summary
4
+
5
+ This release updates the jasmine-core dependency to 3.4.0. See the
6
+ [jasmine-core release notes](https://github.com/jasmine/jasmine/blob/master/release_notes/3.4.0.md)
7
+ for more information
8
+
9
+ ## Changes
10
+
11
+ * Chrome headless as an option to phantomJS
12
+ - Merges [#301](https://github.com/jasmine/jasmine-gem/issues/301) from @stoivo
13
+ - Fixes [#293](https://github.com/jasmine/jasmine-gem/issues/293)
14
+
15
+ ------
16
+
17
+ _Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Runners::ChromeHeadless do
4
+
5
+ let(:config) {
6
+ {
7
+ show_console_log: nil,
8
+ show_full_stack_trace: nil,
9
+ chrome_cli_options: nil,
10
+ chrome_binary: nil,
11
+ }
12
+ }
13
+
14
+ it 'uses chrome_binary from config is set' do
15
+ config[:chrome_binary] = "some_path"
16
+ runner = Jasmine::Runners::ChromeHeadless.new(nil, nil, double(config))
17
+
18
+ expect(runner.chrome_binary).to eq("some_path")
19
+ end
20
+
21
+ it 'uses chrome_binary from default chrome path if it exist' do
22
+ allow(File).to receive(:file?).and_return(true)
23
+ runner = Jasmine::Runners::ChromeHeadless.new(nil, nil, double(config))
24
+
25
+ expect(runner.chrome_binary).to eq("/usr/bin/google-chrome")
26
+ end
27
+
28
+ it 'chrome_binary raise an exeption if nowhere to be found' do
29
+ allow(File).to receive(:file?).and_return(false)
30
+ runner = Jasmine::Runners::ChromeHeadless.new(nil, nil, double(config))
31
+
32
+ expect {
33
+ runner.chrome_binary
34
+ }.to raise_error(RuntimeError)
35
+ end
36
+
37
+ describe "cli_options_string" do
38
+ it "empty hash is empty result" do
39
+ runner = Jasmine::Runners::ChromeHeadless.new(nil, nil, double(config))
40
+ expect(runner.cli_options_string).to eq("")
41
+ end
42
+
43
+ it "formats hash properly" do
44
+ config[:chrome_cli_options] = {"no-sandbox" => nil, "headless" => nil, "remote-debugging-port" => 9222}
45
+ runner = Jasmine::Runners::ChromeHeadless.new(nil, nil, double(config))
46
+ expect(runner.cli_options_string).to eq("--no-sandbox --headless --remote-debugging-port=9222")
47
+ end
48
+ end
49
+
50
+ end
@@ -63,167 +63,231 @@ if rails_available?
63
63
  end
64
64
  end
65
65
 
66
- it "rake jasmine:ci runs and returns expected results" do
67
- Bundler.with_clean_env do
68
- output = `bundle exec rake jasmine:ci`
69
- expect(output).to include('5 specs, 0 failures')
66
+ describe "with phantomJS" do
67
+ it "rake jasmine:ci runs and returns expected results" do
68
+ Bundler.with_clean_env do
69
+ output = `bundle exec rake jasmine:ci`
70
+ expect(output).to include('5 specs, 0 failures')
71
+ end
70
72
  end
71
- end
72
73
 
73
- it "rake jasmine:ci returns proper exit code when specs fail" do
74
- Bundler.with_clean_env do
75
- FileUtils.cp(File.join(@root, 'spec', 'fixture', 'failing_test.js'), File.join('spec', 'javascripts'))
76
- failing_yaml = custom_jasmine_config('failing') do |jasmine_config|
77
- jasmine_config['spec_files'] << 'failing_test.js'
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')
78
83
  end
79
- output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{failing_yaml}`
80
- expect($?).to_not be_success
81
- expect(output).to include('6 specs, 1 failure')
82
84
  end
83
- end
84
85
 
85
- it "rake jasmine:ci runs specs when an error occurs in the javascript" do
86
- Bundler.with_clean_env do
87
- FileUtils.cp(File.join(@root, 'spec', 'fixture', 'exception_test.js'), File.join('spec', 'javascripts'))
88
- exception_yaml = custom_jasmine_config('exception') do |jasmine_config|
89
- jasmine_config['spec_files'] << 'exception_test.js'
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')
90
95
  end
91
- output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{exception_yaml}`
92
- expect($?).to_not be_success
93
- expect(output).to include('5 specs, 0 failures')
94
96
  end
95
- end
96
97
 
97
- it "runs specs written in coffeescript" do
98
- coffee_yaml = custom_jasmine_config('coffee') do |jasmine_config|
99
- jasmine_config['spec_files'] << 'coffee_spec.coffee'
100
- end
101
- FileUtils.cp(File.join(@root, 'spec', 'fixture', 'coffee_spec.coffee'), File.join('spec', 'javascripts'))
98
+ it "runs specs written in coffeescript" do
99
+ coffee_yaml = custom_jasmine_config('coffee') do |jasmine_config|
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'))
102
103
 
103
- Bundler.with_clean_env do
104
- output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{coffee_yaml}`
105
- expect(output).to include('6 specs, 0 failures')
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
106
108
  end
107
- end
108
109
 
109
- it "rake jasmine runs and serves the expected webpage when using asset pipeline" do
110
- open('app/assets/stylesheets/foo.css', 'w') { |f|
111
- f.puts "/* hi dere */"
112
- f.flush
113
- }
110
+ it "rake jasmine runs and serves the expected webpage when using asset pipeline" do
111
+ open('app/assets/stylesheets/foo.css', 'w') { |f|
112
+ f.puts "/* hi dere */"
113
+ f.flush
114
+ }
114
115
 
115
- open('spec/javascripts/helpers/angular_helper.js', 'w') { |f|
116
- f.puts "//= require angular-mocks"
117
- f.flush
118
- }
116
+ open('spec/javascripts/helpers/angular_helper.js', 'w') { |f|
117
+ f.puts "//= require angular-mocks"
118
+ f.flush
119
+ }
120
+
121
+ css_yaml = custom_jasmine_config('css') do |jasmine_config|
122
+ jasmine_config['src_files'] = %w[assets/application.js http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js]
123
+ jasmine_config['stylesheets'] = ['assets/application.css']
124
+ end
119
125
 
120
- css_yaml = custom_jasmine_config('css') do |jasmine_config|
121
- jasmine_config['src_files'] = %w[assets/application.js http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js]
122
- jasmine_config['stylesheets'] = ['assets/application.css']
126
+ run_jasmine_server("JASMINE_CONFIG_PATH=#{css_yaml}") do
127
+ output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
128
+ expect(output).to match(%r{script src.*/assets/jasmine_examples/Player(\.self-[^\.]+)?\.js})
129
+ 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
+
134
+ output = Net::HTTP.get(URI.parse('http://localhost:8888/__spec__/helpers/angular_helper.js'))
135
+ expect(output).to match(/angular\.mock/)
136
+ end
123
137
  end
124
138
 
125
- run_jasmine_server("JASMINE_CONFIG_PATH=#{css_yaml}") do
126
- output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
127
- expect(output).to match(%r{script src.*/assets/jasmine_examples/Player(\.self-[^\.]+)?\.js})
128
- expect(output).to match(%r{script src=['"]http://ajax\.googleapis\.com/ajax/libs/jquery/1\.11\.0/jquery\.min\.js})
129
- expect(output).to match(%r{script src.*/assets/jasmine_examples/Song(\.self-[^\.]+)?\.js})
130
- expect(output).to match(%r{script src.*angular_helper\.js})
131
- expect(output).to match(%r{<link rel=.stylesheet.*?href=./assets/foo(\.self-[^\.]+)?\.css\?.*?>})
139
+ it "sets assets_prefix when using sprockets" do
140
+ open('app/assets/stylesheets/assets_prefix.js.erb', 'w') { |f|
141
+ f.puts "<%= assets_prefix %>"
142
+ f.flush
143
+ }
132
144
 
133
- output = Net::HTTP.get(URI.parse('http://localhost:8888/__spec__/helpers/angular_helper.js'))
134
- expect(output).to match(/angular\.mock/)
145
+ run_jasmine_server do
146
+ output = Net::HTTP.get(URI.parse('http://localhost:8888/assets/assets_prefix.js'))
147
+ expect(output).to match("/assets")
148
+ end
135
149
  end
136
- end
137
150
 
138
- it "sets assets_prefix when using sprockets" do
139
- open('app/assets/stylesheets/assets_prefix.js.erb', 'w') { |f|
140
- f.puts "<%= assets_prefix %>"
141
- f.flush
142
- }
151
+ it "should load js files outside of the assets path too" do
152
+ yaml = custom_jasmine_config('public-assets') do |jasmine_config|
153
+ jasmine_config['src_files'] << 'public/javascripts/**/*.js'
154
+ jasmine_config['spec_files'] = ['non_asset_pipeline_test.js']
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'))
143
159
 
144
- run_jasmine_server do
145
- output = Net::HTTP.get(URI.parse('http://localhost:8888/assets/assets_prefix.js'))
146
- expect(output).to match("/assets")
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
147
164
  end
148
- end
149
165
 
150
- it "should load js files outside of the assets path too" do
151
- yaml = custom_jasmine_config('public-assets') do |jasmine_config|
152
- jasmine_config['src_files'] << 'public/javascripts/**/*.js'
153
- jasmine_config['spec_files'] = ['non_asset_pipeline_test.js']
154
- end
155
- FileUtils.mkdir_p(File.join('public', 'javascripts'))
156
- FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline.js'), File.join('public', 'javascripts'))
157
- FileUtils.cp(File.join(@root, 'spec', 'fixture', 'non_asset_pipeline_test.js'), File.join('spec', 'javascripts'))
166
+ it "should pass custom rack options from jasmine.yml" do
167
+ pending "we're testing this with thin, which doesn't work in jruby" if RUBY_PLATFORM == 'java'
168
+ rack_yaml = custom_jasmine_config('custom_rack') do |jasmine_config|
169
+ jasmine_config['rack_options'] = { 'server' => 'webrick' }
170
+ end
158
171
 
159
- Bundler.with_clean_env do
160
- output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{yaml}`
161
- expect(output).to include('1 spec, 0 failures')
162
- end
163
- end
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
164
179
 
165
- it "should pass custom rack options from jasmine.yml" do
166
- pending "we're testing this with thin, which doesn't work in jruby" if RUBY_PLATFORM == 'java'
167
- rack_yaml = custom_jasmine_config('custom_rack') do |jasmine_config|
168
- jasmine_config['rack_options'] = { 'server' => 'webrick' }
180
+ custom_output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{rack_yaml} 2>&1`
181
+ expect(custom_output).to include("WEBrick")
182
+ end
169
183
  end
170
184
 
171
- Bundler.with_clean_env do
172
- default_output = `bundle exec rake jasmine:ci`
173
- if ENV['RAILS_VERSION'] == 'rails5' || ENV['RAILS_VERSION'].nil?
174
- expect(default_output).to include('Puma starting')
175
- else
176
- expect(default_output).to include('Thin web server')
185
+ describe 'using sprockets 4' do
186
+ before :all do
187
+ FileUtils.cp('Gemfile', 'Gemfile-old')
188
+ FileUtils.rm 'Gemfile.lock'
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')
199
+
200
+ open('app/assets/config/manifest.js', 'w') { |f|
201
+ f.puts "//= link application.js"
202
+ f.puts "//= link application.css"
203
+ f.flush
204
+ }
205
+ end
206
+
207
+ after :all do
208
+ FileUtils.mv 'Gemfile-old', 'Gemfile'
209
+ FileUtils.rm 'Gemfile.lock'
210
+ FileUtils.rm 'app/assets/config/manifest.js'
211
+ Bundler.with_clean_env do
212
+ bundle_install
213
+ end
177
214
  end
178
215
 
179
- custom_output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{rack_yaml} 2>&1`
180
- expect(custom_output).to include("WEBrick")
216
+ it "serves source mapped assets" do
217
+ run_jasmine_server do
218
+ output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
219
+
220
+ js_match = output.match %r{script src.*/(assets/application.debug-[^\.]+\.js)}
221
+
222
+ expect(js_match).to_not be_nil
223
+ expect(output).to match(%r{<link rel=.stylesheet.*?href=.*/assets/application.debug-[^\.]+\.css})
224
+
225
+ js_path = js_match[1]
226
+ output = Net::HTTP.get(URI.parse("http://localhost:8888/#{js_path}"))
227
+ expect(output).to match(%r{//# sourceMappingURL=.*\.map})
228
+ end
229
+ end
181
230
  end
182
231
  end
183
232
 
184
- describe 'using sprockets 4' do
233
+ describe "with Chrome headless" do
185
234
  before :all do
186
- FileUtils.cp('Gemfile', 'Gemfile-old')
187
- FileUtils.rm 'Gemfile.lock'
188
-
189
- open('Gemfile', 'a') { |f|
190
- f.puts "gem 'sprockets', '~> 4.0.0.beta6'"
235
+ open('spec/javascripts/support/jasmine_helper.rb', 'w') { |f|
236
+ f.puts "Jasmine.configure do |config|\n config.runner_browser = :chromeheadless\nend\n"
191
237
  f.flush
192
238
  }
239
+ end
240
+
241
+
242
+ it "rake jasmine:ci runs and returns expected results", :focus do
193
243
  Bundler.with_clean_env do
194
- bundle_install
244
+ `bundle add chrome_remote`
245
+ output = `bundle exec rake jasmine:ci`
246
+ expect(output).to include('5 specs, 0 failures')
247
+ `bundle remove chrome_remote`
195
248
  end
249
+ end
196
250
 
197
- FileUtils.mkdir_p('app/assets/config')
251
+ it "rake jasmine:ci returns proper exit code when specs fail" do
252
+ Bundler.with_clean_env do
253
+ `bundle add chrome_remote`
198
254
 
199
- open('app/assets/config/manifest.js', 'w') { |f|
200
- f.puts "//= link application.js"
201
- f.puts "//= link application.css"
202
- f.flush
203
- }
255
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'failing_test.js'), File.join('spec', 'javascripts'))
256
+ failing_yaml = custom_jasmine_config('failing') do |jasmine_config|
257
+ jasmine_config['spec_files'] << 'failing_test.js'
258
+ end
259
+ output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{failing_yaml}`
260
+ expect($?).to_not be_success
261
+ expect(output).to include('6 specs, 1 failure')
262
+ `bundle remove chrome_remote`
263
+ end
204
264
  end
205
265
 
206
- after :all do
207
- FileUtils.mv 'Gemfile-old', 'Gemfile'
208
- FileUtils.rm 'Gemfile.lock'
209
- FileUtils.rm 'app/assets/config/manifest.js'
266
+ it "rake jasmine:ci runs specs when an error occurs in the javascript" do
210
267
  Bundler.with_clean_env do
211
- bundle_install
268
+ `bundle add chrome_remote`
269
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'exception_test.js'), File.join('spec', 'javascripts'))
270
+ exception_yaml = custom_jasmine_config('exception') do |jasmine_config|
271
+ jasmine_config['spec_files'] << 'exception_test.js'
272
+ end
273
+ output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{exception_yaml}`
274
+ expect($?).to_not be_success
275
+ expect(output).to include('5 specs, 0 failures')
276
+ `bundle remove chrome_remote`
212
277
  end
213
278
  end
214
279
 
215
- it "serves source mapped assets" do
216
- run_jasmine_server do
217
- output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
218
-
219
- js_match = output.match %r{script src.*/(assets/application.debug-[^\.]+\.js)}
220
-
221
- expect(js_match).to_not be_nil
222
- expect(output).to match(%r{<link rel=.stylesheet.*?href=.*/assets/application.debug-[^\.]+\.css})
280
+ it "runs specs written in coffeescript" do
281
+ coffee_yaml = custom_jasmine_config('coffee') do |jasmine_config|
282
+ jasmine_config['spec_files'] << 'coffee_spec.coffee'
283
+ end
284
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'coffee_spec.coffee'), File.join('spec', 'javascripts'))
223
285
 
224
- js_path = js_match[1]
225
- output = Net::HTTP.get(URI.parse("http://localhost:8888/#{js_path}"))
226
- expect(output).to match(%r{//# sourceMappingURL=.*\.map})
286
+ Bundler.with_clean_env do
287
+ `bundle add chrome_remote`
288
+ output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{coffee_yaml}`
289
+ expect(output).to include('6 specs, 0 failures')
290
+ `bundle remove chrome_remote`
227
291
  end
228
292
  end
229
293
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Van Hove
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-25 00:00:00.000000000 Z
11
+ date: 2019-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 3.3.0
89
+ version: 3.4.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 3.3.0
96
+ version: 3.4.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rack
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +189,8 @@ files:
189
189
  - lib/jasmine/result.rb
190
190
  - lib/jasmine/ruby_versions.rb
191
191
  - lib/jasmine/run.html.erb
192
+ - lib/jasmine/runners/chrome_headless.rb
193
+ - lib/jasmine/runners/chromeheadless_boot.js
192
194
  - lib/jasmine/runners/phantom_boot.js
193
195
  - lib/jasmine/runners/phantom_jasmine_run.js
194
196
  - lib/jasmine/runners/phantom_js.rb
@@ -204,6 +206,7 @@ files:
204
206
  - release_notes/3.1.0.md
205
207
  - release_notes/3.2.0.md
206
208
  - release_notes/3.3.0.md
209
+ - release_notes/3.4.0.md
207
210
  - release_notes/v1.2.1.md
208
211
  - release_notes/v1.3.2.md
209
212
  - release_notes/v2.0.0.md
@@ -227,6 +230,7 @@ files:
227
230
  - spec/application_integration_spec.rb
228
231
  - spec/application_spec.rb
229
232
  - spec/base_spec.rb
233
+ - spec/chrome_headless_spec.rb
230
234
  - spec/ci_runner_spec.rb
231
235
  - spec/configuration_spec.rb
232
236
  - spec/fixture/Rakefile
@@ -286,6 +290,7 @@ test_files:
286
290
  - spec/application_integration_spec.rb
287
291
  - spec/application_spec.rb
288
292
  - spec/base_spec.rb
293
+ - spec/chrome_headless_spec.rb
289
294
  - spec/ci_runner_spec.rb
290
295
  - spec/configuration_spec.rb
291
296
  - spec/fixture/Rakefile