jasmine 3.4.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 573d809d765f48020312d811f92cd6bdf06a886d
4
- data.tar.gz: da52c0fb175781046c1bbf8c4ff8191f6ce0ca45
2
+ SHA256:
3
+ metadata.gz: 3675b4ae8a2d791c1fb24007ba5c1fa28cb38188289e6c2c97dcd5301af45ba8
4
+ data.tar.gz: b9899c89395e9248409eb99aa0858fbedbbdf01ed44d2766ab7f22ab8ec87ee4
5
5
  SHA512:
6
- metadata.gz: e3c51f2e936b5e4d7bc5a3eca0f8be430f77867a357c0d6bc20d5d024b1135a4681124f0ebf84b1450ec681836299ecdf9ee2a6d876c7ceb77c0e81e90ab39e7
7
- data.tar.gz: bb5a4f560ed5924e97ebb1363facf140968e8173e6224b5b314cd77cca273b223423006fab49035040696faa0fa7309835ce1239f40769decaf52e252f6c6d9b
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
@@ -5,9 +5,9 @@ bin
5
5
  .bundle
6
6
  .DS_Store
7
7
  .rvmrc
8
+ .ruby-version
8
9
  .pairs
9
10
  *.swp
10
11
  tags
11
12
  Gemfile.lock
12
13
  spec/reports
13
- .rvmrc
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['TRAVIS']
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
- platform :rbx do
25
- gem 'json'
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 [![Build Status](https://travis-ci.org/jasmine/jasmine-gem.png?branch=master)](https://travis-ci.org/jasmine/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
- Jasmine.configure do |config|
52
- config.prevent_phantom_js_auto_install = true
53
- end
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
- Jasmine.configure do |config|
78
- config.server_port = 5555
79
- end
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
- Jasmine.configure do |config|
86
- config.ci_port = 1234
87
- end
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
- else #default to rails 5
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.4.0'
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 Rails4Or5AssetBundle.new if Jasmine::Dependencies.rails4? || Jasmine::Dependencies.rails5?
17
- raise UnsupportedRailsVersion, "Jasmine only supports the asset pipeline for Rails 4. - 5"
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 Rails4Or5AssetBundle
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 ||= ActionView::Base.new.extend(GetOriginalAssetsHelper)
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
@@ -11,8 +11,7 @@ module Jasmine
11
11
  end
12
12
 
13
13
  def run
14
- formatters = config.formatters.map { |formatter_class| formatter_class.new }
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
@@ -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
- assets_pipeline_available = (rails4? || rails5?) && Rails.respond_to?(:application) && Rails.application.respond_to?(:assets) && !Rails.application.assets.nil?
19
- assets_pipeline_available && (rails4? || rails5?)
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
- "\e[32m.\e[0m"
95
+ colored(:green, '.')
95
96
  elsif result.pending?
96
- "\e[33m*\e[0m"
97
+ colored(:yellow, '*')
97
98
  elsif result.disabled?
98
99
  ""
99
100
  else
100
- "\e[31mF\e[0m"
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 \e[33m#{reason}\e[0m"
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
- \e[31m#{expectation.message}\e[0m
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
- 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
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
- raise "Chrome did't seam to start the webSocketDebugger at port: 9222, timeout #{config.chrome_startup_timeout}sec"
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
-