jasmine 3.4.0 → 3.8.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3675b4ae8a2d791c1fb24007ba5c1fa28cb38188289e6c2c97dcd5301af45ba8
|
4
|
+
data.tar.gz: b9899c89395e9248409eb99aa0858fbedbbdf01ed44d2766ab7f22ab8ec87ee4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1dd04e5d13478f134e16cf7b1762c180ca6f7ed927d65966f8498e54b72e5f9888911d33243e60f7239f1b43d114d27baa0b27286e0f061ba9e7f6869636429
|
7
|
+
data.tar.gz: e2de6296d752fcbbf7a4e2c7505192aa59810a01e5f470f4e95b58b0dd2458257a3b3861755c129124a5173b3dc59b2f16f07d8d74b906d4981fa0d6b8380815
|
@@ -0,0 +1,84 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@1.1.2
|
4
|
+
|
5
|
+
executors:
|
6
|
+
ruby_3_0:
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:3.0-browsers-legacy
|
9
|
+
ruby_2_7:
|
10
|
+
docker:
|
11
|
+
- image: circleci/ruby:2.7-browsers-legacy
|
12
|
+
ruby_2_6:
|
13
|
+
docker:
|
14
|
+
- image: circleci/ruby:2.6-browsers-legacy
|
15
|
+
ruby_2_5:
|
16
|
+
docker:
|
17
|
+
- image: circleci/ruby:2.5-browsers-legacy
|
18
|
+
ruby_2_3:
|
19
|
+
docker:
|
20
|
+
- image: circleci/ruby:2.3-browsers-legacy
|
21
|
+
|
22
|
+
jobs:
|
23
|
+
test:
|
24
|
+
parameters:
|
25
|
+
rails_version:
|
26
|
+
type: string
|
27
|
+
executor:
|
28
|
+
type: executor
|
29
|
+
executor: << parameters.executor >>
|
30
|
+
environment:
|
31
|
+
RAILS_VERSION=<< parameters.rails_version >>
|
32
|
+
steps:
|
33
|
+
- checkout:
|
34
|
+
path: jasmine-gem
|
35
|
+
- run:
|
36
|
+
name: Install Node
|
37
|
+
command: sudo apt-get install nodejs
|
38
|
+
- run:
|
39
|
+
name: Install bundler
|
40
|
+
command: "if [ $RAILS_VERSION = rails4 ];then gem install bundler -v '< 2.0' ; else gem install bundler; fi"
|
41
|
+
- run:
|
42
|
+
name: Report versions
|
43
|
+
command: "echo 'Ruby version:' && ruby -v && echo 'Bundler version:' && bundle -v && echo 'RAILS_VERSION:' $RAILS_VERSION"
|
44
|
+
- run:
|
45
|
+
name: Install gems
|
46
|
+
command: "cd jasmine-gem && bundle install"
|
47
|
+
- run:
|
48
|
+
name: Run tests
|
49
|
+
command: "cd jasmine-gem && bundle exec rake --trace"
|
50
|
+
|
51
|
+
workflows:
|
52
|
+
version: 2
|
53
|
+
push: &push_workflow
|
54
|
+
jobs:
|
55
|
+
- test:
|
56
|
+
matrix:
|
57
|
+
parameters:
|
58
|
+
rails_version: ["pojs", "rails6", "rails5", "rails4"]
|
59
|
+
executor: ["ruby_3_0", "ruby_2_7", "ruby_2_6", "ruby_2_5", "ruby_2_3"]
|
60
|
+
exclude:
|
61
|
+
# Don't run Rails 4 on newer Rubies that lack an old enough
|
62
|
+
# bundler.
|
63
|
+
- rails_version: "rails4"
|
64
|
+
executor: "ruby_3_0"
|
65
|
+
- rails_version: "rails4"
|
66
|
+
executor: "ruby_2_7"
|
67
|
+
# Rails 6 requires at least Ruby 2.5.
|
68
|
+
- rails_version: "rails6"
|
69
|
+
executor: "ruby_2_3"
|
70
|
+
# Rails 5 requires Ruby < 2.7
|
71
|
+
- rails_version: "rails5"
|
72
|
+
executor: "ruby_3_0"
|
73
|
+
- rails_version: "rails5"
|
74
|
+
executor: "ruby_2_7"
|
75
|
+
cron:
|
76
|
+
<<: *push_workflow
|
77
|
+
triggers:
|
78
|
+
- schedule:
|
79
|
+
# Times are UTC.
|
80
|
+
cron: "0 10 * * *"
|
81
|
+
filters:
|
82
|
+
branches:
|
83
|
+
only:
|
84
|
+
- main
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -2,11 +2,10 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'anchorman', :platform => :mri
|
6
5
|
|
7
6
|
# during development, do not release
|
8
|
-
if ENV['
|
9
|
-
gem 'jasmine-core', :git => 'http://github.com/jasmine/jasmine.git'
|
7
|
+
if ENV['CIRCLECI']
|
8
|
+
gem 'jasmine-core', :git => 'http://github.com/jasmine/jasmine.git', ref: 'main'
|
10
9
|
else
|
11
10
|
gem 'jasmine-core', :path => '../jasmine'
|
12
11
|
end
|
@@ -21,8 +20,6 @@ end
|
|
21
20
|
|
22
21
|
gem 'mime-types', '< 3.0', platform: [:jruby]
|
23
22
|
|
24
|
-
|
25
|
-
gem
|
26
|
-
gem 'rubysl'
|
27
|
-
gem 'racc'
|
23
|
+
if ENV['RAILS_VERSION'] != 'rails4'
|
24
|
+
gem "bundler", "~> 2.1"
|
28
25
|
end
|
data/README.markdown
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
# The Jasmine Gem
|
1
|
+
# The Jasmine Gem
|
2
|
+
[![Build Status](https://circleci.com/gh/jasmine/jasmine-gem.svg?style=shield)](https://circleci.com/gh/jasmine/jasmine-gem)
|
2
3
|
[![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)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/jasmine.svg)](https://badge.fury.io/rb/jasmine)
|
3
5
|
|
4
6
|
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.
|
5
7
|
|
@@ -48,9 +50,11 @@ This uses PhantomJS to load and run the Jasmine suite.
|
|
48
50
|
|
49
51
|
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:
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
53
|
+
```ruby
|
54
|
+
Jasmine.configure do |config|
|
55
|
+
config.prevent_phantom_js_auto_install = true
|
56
|
+
end
|
57
|
+
```
|
54
58
|
|
55
59
|
[phantomjs-gem]: https://github.com/colszowka/phantomjs-gem#phantomjs-as-a-rubygem
|
56
60
|
|
@@ -74,17 +78,56 @@ To change the port that `rake jasmine` uses:
|
|
74
78
|
|
75
79
|
In your jasmine_helper.rb:
|
76
80
|
|
77
|
-
|
78
|
-
|
79
|
-
|
81
|
+
```ruby
|
82
|
+
Jasmine.configure do |config|
|
83
|
+
config.server_port = 5555
|
84
|
+
end
|
85
|
+
```
|
80
86
|
|
81
87
|
By default `rake jasmine:ci` will attempt to find a random open port, to set the port that `rake jasmine:ci` uses:
|
82
88
|
|
83
89
|
In your jasmine_helper.rb:
|
84
90
|
|
85
|
-
|
86
|
-
|
87
|
-
|
91
|
+
```ruby
|
92
|
+
Jasmine.configure do |config|
|
93
|
+
config.ci_port = 1234
|
94
|
+
end
|
95
|
+
```
|
96
|
+
|
97
|
+
By default `rake jasmine:ci` will print results in color, to change this configuration:
|
98
|
+
|
99
|
+
In your jasmine_helper.rb:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
Jasmine.configure do |config|
|
103
|
+
config.color = false
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
## Using headless Chrome
|
108
|
+
|
109
|
+
* Add `chrome_remote` as a dependency
|
110
|
+
* In your jasmine_helper.rb:
|
111
|
+
```ruby
|
112
|
+
Jasmine.configure do |config|
|
113
|
+
config.runner_browser = :chromeheadless
|
114
|
+
end
|
115
|
+
```
|
116
|
+
|
117
|
+
### Additional configuration options
|
118
|
+
|
119
|
+
* `config.chrome_binary` - to customize which binary to execute
|
120
|
+
* `config.chrome_cli_options` - if you know what you're doing you can customize the CLI
|
121
|
+
* `config.chrome_startup_timeout` - change the amount of time to wait for chrome to start
|
122
|
+
|
123
|
+
### On Travis-CI
|
124
|
+
|
125
|
+
Add this to your `.travis.yml`
|
126
|
+
|
127
|
+
```yaml
|
128
|
+
addons:
|
129
|
+
chrome: stable
|
130
|
+
```
|
88
131
|
|
89
132
|
## Support
|
90
133
|
|
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,8 +37,9 @@ 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.8.0'
|
39
41
|
s.add_dependency 'rack', '>= 1.2.1'
|
42
|
+
s.add_dependency 'webrick'
|
40
43
|
s.add_dependency 'rake'
|
41
44
|
s.add_dependency 'phantomjs'
|
42
45
|
end
|
@@ -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
|
@@ -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
|
@@ -51,6 +52,7 @@ module Jasmine
|
|
51
52
|
@runner_browser = :phantomjs
|
52
53
|
|
53
54
|
@formatters = [Jasmine::Formatters::Console]
|
55
|
+
@color = true
|
54
56
|
|
55
57
|
@server_port = 8888
|
56
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
|
@@ -23,7 +23,7 @@ module Jasmine
|
|
23
23
|
raise 'Add "chrome_remote" you your Gemfile. To use chromeheadless we require this gem.'
|
24
24
|
end
|
25
25
|
|
26
|
-
chrome = ChromeRemote.client
|
26
|
+
chrome = wait_for { ChromeRemote.client }
|
27
27
|
chrome.send_cmd "Runtime.enable"
|
28
28
|
chrome.send_cmd "Page.navigate", url: jasmine_server_url
|
29
29
|
result_recived = false
|
@@ -63,6 +63,7 @@ module Jasmine
|
|
63
63
|
def find_chrome_binary
|
64
64
|
path = [
|
65
65
|
"/usr/bin/google-chrome",
|
66
|
+
"/usr/bin/google-chrome-stable",
|
66
67
|
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
67
68
|
].detect { |path|
|
68
69
|
File.file?(path)
|
@@ -77,26 +78,41 @@ module Jasmine
|
|
77
78
|
join(' ')
|
78
79
|
end
|
79
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
|
+
|
80
103
|
def wait_for_chrome_to_start_debug_socket
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
conn
|
85
|
-
|
86
|
-
|
87
|
-
|
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
|
104
|
+
open_socket = -> do
|
105
|
+
begin
|
106
|
+
conn = TCPSocket.new('localhost', 9222)
|
107
|
+
conn.close
|
108
|
+
true
|
109
|
+
rescue
|
110
|
+
nil
|
97
111
|
end
|
98
112
|
end
|
99
|
-
|
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)
|
100
116
|
end
|
101
117
|
|
102
118
|
def boot_js
|
@@ -108,4 +124,3 @@ module Jasmine
|
|
108
124
|
end
|
109
125
|
end
|
110
126
|
end
|
111
|
-
|