jasmine 3.2.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -1
- data/.travis.yml +13 -4
- data/Gemfile +3 -5
- data/README.markdown +58 -11
- data/jasmine.gemspec +5 -3
- data/lib/jasmine.rb +1 -0
- data/lib/jasmine/asset_expander.rb +20 -4
- data/lib/jasmine/ci_runner.rb +17 -2
- data/lib/jasmine/config.rb +17 -7
- data/lib/jasmine/configuration.rb +10 -0
- data/lib/jasmine/dependencies.rb +8 -2
- data/lib/jasmine/formatters/console.rb +26 -6
- data/lib/jasmine/runners/chrome_headless.rb +126 -0
- data/lib/jasmine/runners/chromeheadless_boot.js +15 -0
- data/lib/jasmine/tasks/jasmine.rake +5 -1
- data/lib/jasmine/version.rb +1 -1
- data/release_notes/3.3.0.md +19 -0
- data/release_notes/3.4.0.md +17 -0
- 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/spec/chrome_headless_spec.rb +50 -0
- data/spec/ci_runner_spec.rb +143 -0
- data/spec/configuration_spec.rb +13 -0
- data/spec/jasmine_rails_spec.rb +168 -113
- data/spec/lib/jasmine/formatters/console_spec.rb +54 -20
- data/spec/spec_helper.rb +21 -0
- metadata +24 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f5041dde9ff09182c2b5a3df9c1197f5271688e38f0e823155d069ae4bfdc473
|
4
|
+
data.tar.gz: a6b003232f7ef9a71ae0283b9b486ff275efdeaed368f08fa6f2576c9050382d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5709eb88e178882d97c11dc350fc7c55857f4612b8372e2b1ac1cc3504e8e386bcb578db024372d2454621cbd647713bcac68c9fccb85c31b7fa89785b0785bd
|
7
|
+
data.tar.gz: ebcfdb3e7b9b41cda30b63e29d692701d2ec88f820202cf2e4ff5dbff2bbf420edec9cb102f2881266efeb19ab6208610f37fdb0bfa712105123e0ab02524d16
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -2,25 +2,34 @@ 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
|
-
- "2.4"
|
8
10
|
- "2.5"
|
11
|
+
- "2.6"
|
9
12
|
|
10
13
|
env:
|
14
|
+
- "RAILS_VERSION=rails6"
|
11
15
|
- "RAILS_VERSION=rails5"
|
12
16
|
- "RAILS_VERSION=rails4"
|
13
17
|
- "RAILS_VERSION=pojs"
|
14
18
|
|
15
19
|
script: "if [ $PERFORMANCE_SPECS ];then bundle exec rake performance_specs --trace; else bundle exec rake --trace; fi"
|
16
20
|
|
17
|
-
|
21
|
+
jobs:
|
18
22
|
fast_finish: true
|
19
23
|
include:
|
20
24
|
- env:
|
21
25
|
- "PERFORMANCE_SPECS=true"
|
22
26
|
- "RAILS_VERSION=rails5"
|
27
|
+
exclude:
|
28
|
+
- rvm: "2.3"
|
29
|
+
env: "RAILS_VERSION=rails6"
|
23
30
|
|
24
31
|
before_install:
|
25
|
-
- gem update --system
|
26
|
-
- gem
|
32
|
+
- "if [$RAILS_VERSION != rails4 ];then gem update --system; fi"
|
33
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
34
|
+
- "if [ $RAILS_VERSION = rails4 ];then gem install bundler -v '< 2.0' ; else gem install bundler; fi"
|
35
|
+
- bundle --version
|
data/Gemfile
CHANGED
@@ -6,7 +6,7 @@ gem 'anchorman', :platform => :mri
|
|
6
6
|
|
7
7
|
# during development, do not release
|
8
8
|
if ENV['TRAVIS']
|
9
|
-
gem 'jasmine-core', :git => 'http://github.com/jasmine/jasmine.git'
|
9
|
+
gem 'jasmine-core', :git => 'http://github.com/jasmine/jasmine.git', ref: 'main'
|
10
10
|
else
|
11
11
|
gem 'jasmine-core', :path => '../jasmine'
|
12
12
|
end
|
@@ -21,8 +21,6 @@ end
|
|
21
21
|
|
22
22
|
gem 'mime-types', '< 3.0', platform: [:jruby]
|
23
23
|
|
24
|
-
|
25
|
-
gem
|
26
|
-
gem 'rubysl'
|
27
|
-
gem 'racc'
|
24
|
+
if ENV['RAILS_VERSION'] != 'rails4'
|
25
|
+
gem "bundler", "~> 2.1"
|
28
26
|
end
|
data/README.markdown
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
# The Jasmine Gem [![Build Status](https://travis-ci.org/jasmine/jasmine-gem.png?branch=
|
1
|
+
# The Jasmine Gem [![Build Status](https://travis-ci.org/jasmine/jasmine-gem.png?branch=main)](https://travis-ci.org/jasmine/jasmine-gem)
|
2
|
+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine-gem.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine-gem?ref=badge_shield)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/jasmine.svg)](https://badge.fury.io/rb/jasmine)
|
2
4
|
|
3
5
|
The [Jasmine](http://github.com/jasmine/jasmine) Ruby Gem is a package of helper code for developing Jasmine projects for Ruby-based web projects (Rails, Sinatra, etc.) or for JavaScript projects where Ruby is a welcome partner. It serves up a project's Jasmine suite in a browser so you can focus on your code instead of manually editing script tags in the Jasmine runner HTML file.
|
4
6
|
|
@@ -7,7 +9,7 @@ This gem contains:
|
|
7
9
|
|
8
10
|
* A small server that builds and executes a Jasmine suite for a project
|
9
11
|
* A script that sets up a project to use the Jasmine gem's server
|
10
|
-
* Generators for Ruby on Rails projects (Rails
|
12
|
+
* Generators for Ruby on Rails projects (Rails 4 and 5)
|
11
13
|
|
12
14
|
You can get all of this by: `gem install jasmine` or by adding Jasmine to your `Gemfile`.
|
13
15
|
|
@@ -47,9 +49,11 @@ This uses PhantomJS to load and run the Jasmine suite.
|
|
47
49
|
|
48
50
|
Please note that PhantomJS will be auto-installed by the [phantomjs-gem][phantomjs-gem] at the first `rake jasmine:ci` run. If you have a matching PhantomJS version somewhere on your path, it won't install. You can disable automatic installation altogether (and use the PhantomJS on your path) via the config helper in your jasmine_helper.rb:
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
```ruby
|
53
|
+
Jasmine.configure do |config|
|
54
|
+
config.prevent_phantom_js_auto_install = true
|
55
|
+
end
|
56
|
+
```
|
53
57
|
|
54
58
|
[phantomjs-gem]: https://github.com/colszowka/phantomjs-gem#phantomjs-as-a-rubygem
|
55
59
|
|
@@ -73,17 +77,56 @@ To change the port that `rake jasmine` uses:
|
|
73
77
|
|
74
78
|
In your jasmine_helper.rb:
|
75
79
|
|
76
|
-
|
77
|
-
|
78
|
-
|
80
|
+
```ruby
|
81
|
+
Jasmine.configure do |config|
|
82
|
+
config.server_port = 5555
|
83
|
+
end
|
84
|
+
```
|
79
85
|
|
80
86
|
By default `rake jasmine:ci` will attempt to find a random open port, to set the port that `rake jasmine:ci` uses:
|
81
87
|
|
82
88
|
In your jasmine_helper.rb:
|
83
89
|
|
84
|
-
|
85
|
-
|
86
|
-
|
90
|
+
```ruby
|
91
|
+
Jasmine.configure do |config|
|
92
|
+
config.ci_port = 1234
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
By default `rake jasmine:ci` will print results in color, to change this configuration:
|
97
|
+
|
98
|
+
In your jasmine_helper.rb:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
Jasmine.configure do |config|
|
102
|
+
config.color = false
|
103
|
+
end
|
104
|
+
```
|
105
|
+
|
106
|
+
## Using headless Chrome
|
107
|
+
|
108
|
+
* Add `chrome_remote` as a dependency
|
109
|
+
* In your jasmine_helper.rb:
|
110
|
+
```ruby
|
111
|
+
Jasmine.configure do |config|
|
112
|
+
config.runner_browser = :chromeheadless
|
113
|
+
end
|
114
|
+
```
|
115
|
+
|
116
|
+
### Additional configuration options
|
117
|
+
|
118
|
+
* `config.chrome_binary` - to customize which binary to execute
|
119
|
+
* `config.chrome_cli_options` - if you know what you're doing you can customize the CLI
|
120
|
+
* `config.chrome_startup_timeout` - change the amount of time to wait for chrome to start
|
121
|
+
|
122
|
+
### On Travis-CI
|
123
|
+
|
124
|
+
Add this to your `.travis.yml`
|
125
|
+
|
126
|
+
```yaml
|
127
|
+
addons:
|
128
|
+
chrome: stable
|
129
|
+
```
|
87
130
|
|
88
131
|
## Support
|
89
132
|
|
@@ -94,3 +137,7 @@ Twitter: [@jasminebdd](http://twitter.com/jasminebdd)
|
|
94
137
|
Please file issues here at Github
|
95
138
|
|
96
139
|
Copyright (c) 2008-2017 Pivotal Labs. This software is licensed under the MIT License.
|
140
|
+
|
141
|
+
|
142
|
+
## License
|
143
|
+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine-gem.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine-gem?ref=badge_large)
|
data/jasmine.gemspec
CHANGED
@@ -26,8 +26,10 @@ Gem::Specification.new do |s|
|
|
26
26
|
when 'pojs'
|
27
27
|
when 'rails4'
|
28
28
|
s.add_development_dependency 'rails', '>= 4.2', '< 5.0.0'
|
29
|
-
|
30
|
-
s.add_development_dependency 'rails', '>= 5'
|
29
|
+
when 'rails5'
|
30
|
+
s.add_development_dependency 'rails', '>= 5', '< 6.0.0'
|
31
|
+
else #default to rails 6 - keep in sync with `rails_version` in spec_helper
|
32
|
+
s.add_development_dependency 'rails', '>= 6', '< 7.0.0'
|
31
33
|
end
|
32
34
|
|
33
35
|
s.add_development_dependency 'rack-test'
|
@@ -35,7 +37,7 @@ Gem::Specification.new do |s|
|
|
35
37
|
s.add_development_dependency 'rspec', '>= 2.5.0'
|
36
38
|
s.add_development_dependency 'nokogiri'
|
37
39
|
|
38
|
-
s.add_dependency 'jasmine-core', '3.
|
40
|
+
s.add_dependency 'jasmine-core', '~> 3.6.0'
|
39
41
|
s.add_dependency 'rack', '>= 1.2.1'
|
40
42
|
s.add_dependency 'rake'
|
41
43
|
s.add_dependency 'phantomjs'
|
data/lib/jasmine.rb
CHANGED
@@ -13,11 +13,11 @@ module Jasmine
|
|
13
13
|
UnsupportedRailsVersion = Class.new(StandardError)
|
14
14
|
|
15
15
|
def asset_bundle
|
16
|
-
return
|
17
|
-
raise UnsupportedRailsVersion, "Jasmine only supports the asset pipeline for Rails 4. -
|
16
|
+
return Rails4Or5Or6AssetBundle.new if Jasmine::Dependencies.rails4? || Jasmine::Dependencies.rails5? || Jasmine::Dependencies.rails6?
|
17
|
+
raise UnsupportedRailsVersion, "Jasmine only supports the asset pipeline for Rails 4. - 6"
|
18
18
|
end
|
19
19
|
|
20
|
-
class
|
20
|
+
class Rails4Or5Or6AssetBundle
|
21
21
|
def assets(pathname)
|
22
22
|
if pathname =~ /\.css$/
|
23
23
|
context.get_stylesheet_assets(pathname.gsub(/\.css$/, ''))
|
@@ -29,7 +29,23 @@ module Jasmine
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def context
|
32
|
-
@context ||=
|
32
|
+
@context ||= template.extend(GetOriginalAssetsHelper)
|
33
|
+
end
|
34
|
+
|
35
|
+
def controller_class
|
36
|
+
Class.new(ActionController::Base)
|
37
|
+
end
|
38
|
+
|
39
|
+
def controller
|
40
|
+
controller_class.new
|
41
|
+
end
|
42
|
+
|
43
|
+
def lookup_context
|
44
|
+
ActionView::LookupContext.new([])
|
45
|
+
end
|
46
|
+
|
47
|
+
def template
|
48
|
+
ActionView::Base.new(lookup_context, {}, controller)
|
33
49
|
end
|
34
50
|
|
35
51
|
module GetOriginalAssetsHelper
|
data/lib/jasmine/ci_runner.rb
CHANGED
@@ -11,8 +11,7 @@ module Jasmine
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def run
|
14
|
-
formatters =
|
15
|
-
|
14
|
+
formatters = build_formatters
|
16
15
|
exit_code_formatter = Jasmine::Formatters::ExitCode.new
|
17
16
|
formatters << exit_code_formatter
|
18
17
|
|
@@ -46,5 +45,21 @@ module Jasmine
|
|
46
45
|
def app
|
47
46
|
@application_factory.app(@config)
|
48
47
|
end
|
48
|
+
|
49
|
+
def build_formatters
|
50
|
+
config.formatters.map do |formatter_class|
|
51
|
+
meta_method = if formatter_class.class == Class
|
52
|
+
formatter_class.instance_method(:initialize)
|
53
|
+
else
|
54
|
+
formatter_class.method(:new)
|
55
|
+
end
|
56
|
+
|
57
|
+
if meta_method.arity == 0 || meta_method.parameters[0][0] != :req
|
58
|
+
formatter_class.new
|
59
|
+
else
|
60
|
+
formatter_class.new(config)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
49
64
|
end
|
50
65
|
end
|
data/lib/jasmine/config.rb
CHANGED
@@ -71,13 +71,23 @@ module Jasmine
|
|
71
71
|
end
|
72
72
|
|
73
73
|
@config.runner = lambda do |formatter, jasmine_server_url|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
|
@@ -6,6 +6,7 @@ module Jasmine
|
|
6
6
|
attr_accessor :jasmine_path, :spec_path, :boot_path, :src_path, :image_path, :runner_boot_path
|
7
7
|
attr_accessor :jasmine_dir, :spec_dir, :boot_dir, :src_dir, :images_dir, :runner_boot_dir
|
8
8
|
attr_accessor :formatters
|
9
|
+
attr_accessor :color
|
9
10
|
attr_accessor :host
|
10
11
|
attr_accessor :spec_format
|
11
12
|
attr_accessor :runner
|
@@ -17,7 +18,11 @@ module Jasmine
|
|
17
18
|
attr_accessor :random
|
18
19
|
attr_accessor :phantom_config_script
|
19
20
|
attr_accessor :phantom_cli_options
|
21
|
+
attr_accessor :chrome_cli_options
|
22
|
+
attr_accessor :chrome_startup_timeout
|
23
|
+
attr_accessor :chrome_binary
|
20
24
|
attr_accessor :show_full_stack_trace
|
25
|
+
attr_accessor :runner_browser
|
21
26
|
attr_reader :rack_apps
|
22
27
|
|
23
28
|
def initialize()
|
@@ -41,8 +46,13 @@ module Jasmine
|
|
41
46
|
@random = true
|
42
47
|
@phantom_config_script = nil
|
43
48
|
@phantom_cli_options = {}
|
49
|
+
@chrome_cli_options = {"no-sandbox" => nil, "headless" => nil, "remote-debugging-port" => 9222}
|
50
|
+
@chrome_startup_timeout = 3
|
51
|
+
@chrome_binary = nil
|
52
|
+
@runner_browser = :phantomjs
|
44
53
|
|
45
54
|
@formatters = [Jasmine::Formatters::Console]
|
55
|
+
@color = true
|
46
56
|
|
47
57
|
@server_port = 8888
|
48
58
|
end
|
data/lib/jasmine/dependencies.rb
CHANGED
@@ -10,13 +10,19 @@ module Jasmine
|
|
10
10
|
rails? && Rails.version.to_i == 5
|
11
11
|
end
|
12
12
|
|
13
|
+
def rails6?
|
14
|
+
rails? && Rails.version.to_i == 6
|
15
|
+
end
|
16
|
+
|
13
17
|
def rails?
|
14
18
|
defined?(Rails) && Rails.respond_to?(:version)
|
15
19
|
end
|
16
20
|
|
17
21
|
def use_asset_pipeline?
|
18
|
-
|
19
|
-
|
22
|
+
(rails4? || rails5? || rails6?) &&
|
23
|
+
Rails.respond_to?(:application) &&
|
24
|
+
Rails.application.respond_to?(:assets) &&
|
25
|
+
!Rails.application.assets.nil?
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Jasmine
|
2
2
|
module Formatters
|
3
3
|
class Console
|
4
|
-
def initialize(outputter = Kernel)
|
4
|
+
def initialize(config, outputter = Kernel)
|
5
|
+
@config = config
|
5
6
|
@results = []
|
6
7
|
@outputter = outputter
|
7
8
|
end
|
@@ -91,13 +92,13 @@ module Jasmine
|
|
91
92
|
def chars(results)
|
92
93
|
results.map do |result|
|
93
94
|
if result.succeeded?
|
94
|
-
|
95
|
+
colored(:green, '.')
|
95
96
|
elsif result.pending?
|
96
|
-
|
97
|
+
colored(:yellow, '*')
|
97
98
|
elsif result.disabled?
|
98
99
|
""
|
99
100
|
else
|
100
|
-
|
101
|
+
colored(:red, 'F')
|
101
102
|
end
|
102
103
|
end.join('')
|
103
104
|
end
|
@@ -111,7 +112,7 @@ module Jasmine
|
|
111
112
|
reason = 'No reason given'
|
112
113
|
reason = spec.pending_reason if spec.pending_reason && spec.pending_reason != ''
|
113
114
|
|
114
|
-
"\t#{spec.full_name}\n\t
|
115
|
+
"\t#{spec.full_name}\n\t #{colored(:yellow, reason)}"
|
115
116
|
end
|
116
117
|
|
117
118
|
def failure_message(failure)
|
@@ -121,7 +122,7 @@ module Jasmine
|
|
121
122
|
def expectation_message(expectation)
|
122
123
|
<<-FE
|
123
124
|
Message:
|
124
|
-
|
125
|
+
#{colored(:red, expectation.message)}
|
125
126
|
Stack:
|
126
127
|
#{stack(expectation.stack)}
|
127
128
|
FE
|
@@ -130,6 +131,25 @@ module Jasmine
|
|
130
131
|
def stack(stack)
|
131
132
|
stack.split("\n").map(&:strip).join("\n ")
|
132
133
|
end
|
134
|
+
|
135
|
+
def colored(color, message)
|
136
|
+
s = case color
|
137
|
+
when :green
|
138
|
+
"\e[32m"
|
139
|
+
when :yellow
|
140
|
+
"\e[33m"
|
141
|
+
when :red
|
142
|
+
"\e[31m"
|
143
|
+
else
|
144
|
+
"\e[0m"
|
145
|
+
end
|
146
|
+
|
147
|
+
if @config.color
|
148
|
+
"#{s}#{message}\e[0m"
|
149
|
+
else
|
150
|
+
message
|
151
|
+
end
|
152
|
+
end
|
133
153
|
end
|
134
154
|
end
|
135
155
|
end
|
@@ -0,0 +1,126 @@
|
|
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 = wait_for { 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
|
+
"/usr/bin/google-chrome-stable",
|
67
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
68
|
+
].detect { |path|
|
69
|
+
File.file?(path)
|
70
|
+
}
|
71
|
+
raise "No Chrome binary found" if path.nil?
|
72
|
+
path
|
73
|
+
end
|
74
|
+
|
75
|
+
def cli_options_string
|
76
|
+
@cli_options.
|
77
|
+
map {|(k, v)| if v then "--#{k}=#{v}" else "--#{k}" end }.
|
78
|
+
join(' ')
|
79
|
+
end
|
80
|
+
|
81
|
+
def wait_for
|
82
|
+
|
83
|
+
|
84
|
+
puts "new logic"
|
85
|
+
|
86
|
+
|
87
|
+
time = Time.now.to_i
|
88
|
+
result = try_to { yield }
|
89
|
+
|
90
|
+
while !result && Time.now.to_i - time < config.chrome_startup_timeout
|
91
|
+
sleep(0.1)
|
92
|
+
result = try_to { yield }
|
93
|
+
end
|
94
|
+
result
|
95
|
+
end
|
96
|
+
|
97
|
+
def try_to
|
98
|
+
yield
|
99
|
+
rescue
|
100
|
+
nil
|
101
|
+
end
|
102
|
+
|
103
|
+
def wait_for_chrome_to_start_debug_socket
|
104
|
+
open_socket = -> do
|
105
|
+
begin
|
106
|
+
conn = TCPSocket.new('localhost', 9222)
|
107
|
+
conn.close
|
108
|
+
true
|
109
|
+
rescue
|
110
|
+
nil
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
message = "Chrome didn't seem to start the webSocketDebugger at port: 9222, timeout #{config.chrome_startup_timeout}sec"
|
115
|
+
raise message unless wait_for(&open_socket)
|
116
|
+
end
|
117
|
+
|
118
|
+
def boot_js
|
119
|
+
File.expand_path('chromeheadless_boot.js', File.dirname(__FILE__))
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
attr_reader :formatter, :jasmine_server_url, :show_console_log, :config
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|