jasmine 3.5.1 → 3.8.1

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
  SHA256:
3
- metadata.gz: 1c3adadebd009bfacd1fab26771b31c42b76ee42068e88cd61bc71e5a259c884
4
- data.tar.gz: 82c143fa60146d38d0c5f1c920f36b63552d6a08040358a8d8bffcdbe0ff424a
3
+ metadata.gz: 495a350989ec280a34ba219588ce3bf7f980c20df5807e35bd0deb3af813858f
4
+ data.tar.gz: ffb7929ff320417cf5ac930c2c7a2ac17c17000fa1d42c3edcb10ce21e9c49bc
5
5
  SHA512:
6
- metadata.gz: b7be5ec8f81a983be7dce34d006d46e836f39f27e455548ae73f4463e03d3886bfd5a9b4c831d2de814a42798feb6eff1e80d1a2f420706dd5fb6d81fb5a466e
7
- data.tar.gz: 9ab969b3f529485c9633ad5d21e9953bead00bbe45ea9f8874ddccbf59cf862a152954410a1f5c1c85f08463120fadeab0895f3dab4e152331916b0e01d87b14
6
+ metadata.gz: b64e95c10f01ab4edfd0e44a2d08d01f44614c8179f97ed7991f6722b67601d4e9a4bf7d7321157f7bbdf0ffb60e9bf5636146da66d0bd2aaa3b84b29389f5ed
7
+ data.tar.gz: 7b3fbc0f01c441d5a6396f7113cf61d4bcd67dcb6049d5f3d6939972b7e3752c59a122ad6f6ea3981df21c01c9faaf3b78e73cd2da8310d1ef86ff0945e9448a
@@ -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,25 +2,18 @@ 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
13
12
 
14
- if ENV['RAILS_VERSION'] == "rails4"
15
- gem 'rack', '~> 1.6.0'
16
- elsif ENV['RAILS_VERSION'] == "pojs"
17
- gem 'rack', '< 2.0'
18
- else
19
- gem 'rack', '>= 2.0'
20
- end
13
+ gem 'rack', '>= 2.0'
21
14
 
22
15
  gem 'mime-types', '< 3.0', platform: [:jruby]
23
16
 
24
17
  if ENV['RAILS_VERSION'] != 'rails4'
25
- gem "bundler", "~> 2.1"
18
+ gem "bundler", ">= 2.1.4"
26
19
  end
data/README.markdown CHANGED
@@ -1,9 +1,15 @@
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)
3
4
  [![Gem Version](https://badge.fury.io/rb/jasmine.svg)](https://badge.fury.io/rb/jasmine)
4
5
 
5
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.
6
7
 
8
+ Webpacker support is provided via the
9
+ [jasmine-browser-runner](https://jasmine.github.io/setup/browser.html#use-with-rails)
10
+ NPM package, not this gem. `jasmine-browser-runner` can also be used to test
11
+ JavaScript in Rails applications that use the Asset Pipeline.
12
+
7
13
  ## Contents
8
14
  This gem contains:
9
15
 
@@ -93,6 +99,16 @@ Jasmine.configure do |config|
93
99
  end
94
100
  ```
95
101
 
102
+ By default `rake jasmine:ci` will print results in color, to change this configuration:
103
+
104
+ In your jasmine_helper.rb:
105
+
106
+ ```ruby
107
+ Jasmine.configure do |config|
108
+ config.color = false
109
+ end
110
+ ```
111
+
96
112
  ## Using headless Chrome
97
113
 
98
114
  * Add `chrome_remote` as a dependency
data/jasmine.gemspec CHANGED
@@ -37,8 +37,9 @@ Gem::Specification.new do |s|
37
37
  s.add_development_dependency 'rspec', '>= 2.5.0'
38
38
  s.add_development_dependency 'nokogiri'
39
39
 
40
- s.add_dependency 'jasmine-core', '~> 3.5.0'
41
- s.add_dependency 'rack', '>= 1.2.1'
40
+ s.add_dependency 'jasmine-core', '~> 3.8.0'
41
+ s.add_dependency 'rack', '>= 2.1.4'
42
+ s.add_dependency 'webrick'
42
43
  s.add_dependency 'rake'
43
44
  s.add_dependency 'phantomjs'
44
45
  end
@@ -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
@@ -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
-
@@ -1,4 +1,5 @@
1
1
  require 'phantomjs'
2
+ require 'json'
2
3
 
3
4
  module Jasmine
4
5
  module Runners
@@ -59,7 +59,11 @@ namespace :jasmine do
59
59
  config = Jasmine.config
60
60
  port = config.port(:server)
61
61
  server = Jasmine::Server.new(port, Jasmine::Application.app(Jasmine.config), config.rack_options)
62
- puts "your server is running here: http://localhost:#{port}/"
62
+ if config.random
63
+ puts "your server is running here: http://localhost:#{port}/"
64
+ else
65
+ puts "your server is running here: http://localhost:#{port}/?random=false"
66
+ end
63
67
  puts "your tests are here: #{config.spec_dir}"
64
68
  puts "your source files are here: #{config.src_dir}"
65
69
  puts ''
@@ -1,3 +1,3 @@
1
1
  module Jasmine
2
- VERSION = "3.5.1"
2
+ VERSION = "3.8.1"
3
3
  end
@@ -7,11 +7,11 @@ This update allows the gem to continue working with Sprockets in Rails 6
7
7
  ## Changes
8
8
 
9
9
  * Various readme improvements
10
- - Merges #312 from @cprodhomme
10
+ - Merges [#312](https://github.com/jasmine/jasmine-gem/issues/312) from @cprodhomme
11
11
 
12
12
  * Allow Jasmine to continue to work with Rails 6
13
- - Merges #310 from @cbaines
14
- - Fixes #311
13
+ - Merges [#310](https://github.com/jasmine/jasmine-gem/issues/310) from @cbaines
14
+ - Fixes [#311](https://github.com/jasmine/jasmine-gem/issues/311)
15
15
 
16
16
  ------
17
17
 
@@ -0,0 +1,31 @@
1
+ # Jasmine Gem 3.6 Release Notes
2
+
3
+ ## Summary
4
+
5
+ This release updates the jasmine-core dependency to 3.6.0. See the
6
+ [jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/3.6.0.md)
7
+ for more information
8
+
9
+
10
+ ## Changes
11
+
12
+ * Change jasmine:server url depending on random flag
13
+ * Merges #317 from @vimalloc
14
+ * Fixes #307
15
+
16
+ * Fix Action View deprecation warnings in Rails 6
17
+ * Merges #318 from @pixeltrix
18
+
19
+ * Prevent race condition with Chrome Remote startup
20
+ * Merges #316 from @stoivo
21
+
22
+ * Add API to enable/disable coloring text
23
+ * Merges #313 from @soutaro
24
+
25
+ * Add support for chrome from yaourt
26
+ * Merges #315 from @TheBlackArroVV
27
+ * Fixes #314
28
+
29
+ ------
30
+
31
+ _Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
@@ -0,0 +1,7 @@
1
+ # Jasmine Gem 3.7 Release Notes
2
+
3
+ ## Summary
4
+
5
+ This release updates the jasmine-core dependency to 3.7.0. See the
6
+ [jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/3.7.0.md)
7
+ for more information
@@ -0,0 +1,38 @@
1
+ # Jasmine Gem 3.8 Release Notes
2
+
3
+ ## Summary
4
+
5
+ This release updates the jasmine-core dependency to 3.8.0. See the
6
+ [jasmine-core release notes](https://github.com/pivotal/jasmine/blob/main/release_notes/3.8.0.md)
7
+ for more information.
8
+
9
+ ## Changes
10
+
11
+ * Ruby 3.0 compatibility
12
+
13
+ # Internal notes
14
+
15
+ * Added Ruby 2.7 and Ruby 3.0 to CI matrix
16
+
17
+ * Migrated from Travis to Circle CI
18
+
19
+ ## Supported Environments
20
+
21
+ The Jasmine gem has been tested in the following environments:
22
+
23
+ | Rails version | Ruby versions |
24
+ |-----------------|---------------|
25
+ | 6 | 2.5-3.0 |
26
+ | 5 | 2.3-2.7 |
27
+ | 4 | 2.3-2.6 |
28
+ | Non-Rails usage | 2.3-3.0 |
29
+
30
+ See the
31
+ [jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/3.8.0.md)
32
+ for supported browsers.
33
+
34
+
35
+
36
+ ------
37
+
38
+ _Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
@@ -0,0 +1,19 @@
1
+ # Jasmine Gem 3.8.1 Release Notes
2
+
3
+ This release updates the Rack dependency to >= 2.1.4 due to security
4
+ vulnerabilities in earlier versions of Rack. There are no other changes.
5
+
6
+ ## Supported Environments
7
+
8
+ The Jasmine gem has been tested in the following environments:
9
+
10
+ | Rails version | Ruby versions |
11
+ |-----------------|---------------|
12
+ | 6 | 2.5-3.0 |
13
+ | 5 | 2.3-2.7 |
14
+ | 4 | 2.3-2.6 |
15
+ | Non-Rails usage | 2.3-3.0 |
16
+
17
+ See the
18
+ [jasmine-core release notes](https://github.com/jasmine/jasmine/blob/main/release_notes/3.8.0.md)
19
+ for supported browsers.
@@ -61,6 +61,149 @@ describe Jasmine::CiRunner do
61
61
  expect(runner).to have_received(:run)
62
62
  end
63
63
 
64
+ it 'instantiates all formatters' do
65
+ class SimpleFormatter1
66
+ end
67
+
68
+ class SimpleFormatter2
69
+ end
70
+
71
+ expect(config).to receive(:formatters) { [SimpleFormatter1, SimpleFormatter2] }
72
+
73
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
74
+
75
+ ci_runner.run
76
+
77
+ expect(runner_factory).to have_received(:call).with(anything, anything) do |multi_formatter, url|
78
+ expect_any_instance_of(SimpleFormatter1).to receive(:format)
79
+ expect_any_instance_of(SimpleFormatter2).to receive(:format)
80
+
81
+ multi_formatter.format([])
82
+ end
83
+ end
84
+
85
+ it 'instantiates formatters with arguments' do
86
+ class SimpleFormatter
87
+ attr_reader :obj
88
+ def initialize(obj)
89
+ @obj = obj
90
+ end
91
+ end
92
+
93
+ expect(config).to receive(:formatters) { [SimpleFormatter] }
94
+
95
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
96
+
97
+ ci_runner.run
98
+
99
+ expect(runner_factory).to have_received(:call).with(anything, anything) do |multi_formatter, url|
100
+ expect_any_instance_of(SimpleFormatter).to receive(:format) do |formatter, results|
101
+ expect(formatter.obj).to eq(config)
102
+ end
103
+
104
+ multi_formatter.format([])
105
+ end
106
+ end
107
+
108
+ it 'works with formatters that are not classes' do
109
+ class Factory1
110
+ attr_reader :called
111
+ def new
112
+ @called = true
113
+ nil
114
+ end
115
+ end
116
+
117
+ class Factory2
118
+ attr_reader :called
119
+ attr_reader :obj
120
+ def new(obj)
121
+ @obj = obj
122
+ @called = true
123
+ nil
124
+ end
125
+ end
126
+
127
+ factory1 = Factory1.new
128
+ factory2 = Factory2.new
129
+
130
+ expect(config).to receive(:formatters) { [factory1, factory2] }
131
+
132
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
133
+
134
+ ci_runner.run
135
+
136
+ expect(factory1.called).to eq(true)
137
+ expect(factory2.called).to eq(true)
138
+ expect(factory2.obj).to eq(config)
139
+ end
140
+
141
+ it 'handles optional arguments by only passing config when it is required' do
142
+ class NoConfigFormatter
143
+ attr_reader :optional
144
+ def initialize(optional = {config: 'no'})
145
+ @optional = optional
146
+ end
147
+ end
148
+
149
+ class HasConfigFormatter
150
+ attr_reader :obj, :optional
151
+ def initialize(obj, optional = {config: 'no'})
152
+ @obj = obj
153
+ @optional = optional
154
+ end
155
+ end
156
+
157
+ class NoConfigFactory
158
+ def initialize(dummy_formatter)
159
+ @dummy_formatter = dummy_formatter
160
+ end
161
+ attr_reader :optional
162
+ def new(optional = {config: 'no'})
163
+ @optional = optional
164
+ @dummy_formatter
165
+ end
166
+ end
167
+
168
+ class HasConfigFactory
169
+ def initialize(dummy_formatter)
170
+ @dummy_formatter = dummy_formatter
171
+ end
172
+ attr_reader :obj, :optional
173
+ def new(obj, optional = {config: 'no'})
174
+ @obj = obj
175
+ @optional = optional
176
+ @dummy_formatter
177
+ end
178
+ end
179
+
180
+ no_config_factory = NoConfigFactory.new(double(:formatter, format: nil))
181
+ has_config_factory = HasConfigFactory.new(double(:formatter, format: nil))
182
+
183
+ expect(config).to receive(:formatters) { [NoConfigFormatter, HasConfigFormatter, no_config_factory, has_config_factory] }
184
+
185
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
186
+
187
+ ci_runner.run
188
+
189
+ expect(no_config_factory.optional).to eq({config: 'no'})
190
+ expect(has_config_factory.optional).to eq({config: 'no'})
191
+ expect(has_config_factory.obj).to eq(config)
192
+
193
+ expect(runner_factory).to have_received(:call).with(anything, anything) do |multi_formatter, url|
194
+ expect_any_instance_of(NoConfigFormatter).to receive(:format) do |formatter, results|
195
+ expect(formatter.optional).to eq({config: 'no'})
196
+ end
197
+
198
+ expect_any_instance_of(HasConfigFormatter).to receive(:format) do |formatter, results|
199
+ expect(formatter.optional).to eq({config: 'no'})
200
+ expect(formatter.obj).to eq(config)
201
+ end
202
+
203
+ multi_formatter.format([])
204
+ end
205
+ end
206
+
64
207
  it 'adds runner boot files when necessary' do
65
208
  expect(runner).to receive(:boot_js).at_least(:once) { 'foo/bar/baz.js' }
66
209
  expect(config).to receive(:runner_boot_dir=).with('foo/bar')
@@ -215,5 +215,18 @@ describe Jasmine::Configuration do
215
215
  config.runner.call('hi')
216
216
  end
217
217
  end
218
+
219
+ describe 'colorization settings' do
220
+ it 'defaults to color' do
221
+ config = Jasmine::Configuration.new
222
+ expect(config.color).to eq(true)
223
+ end
224
+
225
+ it 'can be set to false' do
226
+ config = Jasmine::Configuration.new
227
+ config.color = false
228
+ expect(config.color).to eq(false)
229
+ end
230
+ end
218
231
  end
219
232
 
@@ -36,7 +36,7 @@ if rails_available?
36
36
 
37
37
  open('Gemfile', 'a') { |f|
38
38
  f.puts "gem 'jasmine', :path => '#{base}'"
39
- f.puts "gem 'jasmine-core', :git => 'http://github.com/jasmine/jasmine.git'"
39
+ f.puts "gem 'jasmine-core', :git => 'http://github.com/jasmine/jasmine.git', ref: 'main'"
40
40
  if RUBY_PLATFORM != 'java' && rails_version == 'rails4'
41
41
  f.puts "gem 'thin'"
42
42
  end
@@ -13,28 +13,28 @@ describe Jasmine::Formatters::Console do
13
13
 
14
14
  describe '#format' do
15
15
  it 'prints a dot for a successful spec' do
16
- formatter = Jasmine::Formatters::Console.new(outputter)
16
+ formatter = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
17
17
  formatter.format([passing_result])
18
18
 
19
19
  expect(outputter_output).to include('.')
20
20
  end
21
21
 
22
22
  it 'prints a star for a pending spec' do
23
- formatter = Jasmine::Formatters::Console.new(outputter)
23
+ formatter = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
24
24
  formatter.format([pending_result])
25
25
 
26
26
  expect(outputter_output).to include('*')
27
27
  end
28
28
 
29
29
  it 'prints an F for a failing spec' do
30
- formatter = Jasmine::Formatters::Console.new(outputter)
30
+ formatter = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
31
31
  formatter.format([failing_result])
32
32
 
33
33
  expect(outputter_output).to include('F')
34
34
  end
35
35
 
36
36
  it 'prints a dot for a disabled spec' do
37
- formatter = Jasmine::Formatters::Console.new(outputter)
37
+ formatter = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
38
38
  formatter.format([disabled_result])
39
39
 
40
40
  expect(outputter_output).to eq('')
@@ -44,7 +44,7 @@ describe Jasmine::Formatters::Console do
44
44
  describe '#summary' do
45
45
  it 'shows the failure messages' do
46
46
  results = [failing_result, failing_result]
47
- formatter = Jasmine::Formatters::Console.new(outputter)
47
+ formatter = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
48
48
  formatter.format(results)
49
49
  formatter.done(run_details)
50
50
  expect(outputter_output).to match(/a suite with a failing spec/)
@@ -55,7 +55,7 @@ describe Jasmine::Formatters::Console do
55
55
  describe 'when the full suite passes' do
56
56
  it 'shows the spec counts' do
57
57
  results = [passing_result]
58
- console = Jasmine::Formatters::Console.new(outputter)
58
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
59
59
  console.format(results)
60
60
  console.done(run_details)
61
61
 
@@ -65,7 +65,7 @@ describe Jasmine::Formatters::Console do
65
65
 
66
66
  it 'shows the spec counts (pluralized)' do
67
67
  results = [passing_result, passing_result]
68
- console = Jasmine::Formatters::Console.new(outputter)
68
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
69
69
  console.format(results)
70
70
  console.done(run_details)
71
71
 
@@ -77,7 +77,7 @@ describe Jasmine::Formatters::Console do
77
77
  describe 'when there are failures' do
78
78
  it 'shows the spec counts' do
79
79
  results = [passing_result, failing_result]
80
- console = Jasmine::Formatters::Console.new(outputter)
80
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
81
81
  console.format(results)
82
82
  console.done(run_details)
83
83
 
@@ -87,7 +87,7 @@ describe Jasmine::Formatters::Console do
87
87
 
88
88
  it 'shows the spec counts (pluralized)' do
89
89
  results = [failing_result, failing_result]
90
- console = Jasmine::Formatters::Console.new(outputter)
90
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
91
91
  console.format(results)
92
92
  console.done(run_details)
93
93
 
@@ -97,7 +97,7 @@ describe Jasmine::Formatters::Console do
97
97
 
98
98
  it 'shows the failure message' do
99
99
  results = [failing_result]
100
- console = Jasmine::Formatters::Console.new(outputter)
100
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
101
101
  console.format(results)
102
102
  console.done(run_details)
103
103
 
@@ -108,7 +108,7 @@ describe Jasmine::Formatters::Console do
108
108
  describe 'when there are pending specs' do
109
109
  it 'shows the spec counts' do
110
110
  results = [passing_result, pending_result]
111
- console = Jasmine::Formatters::Console.new(outputter)
111
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
112
112
  console.format(results)
113
113
  console.done(run_details)
114
114
 
@@ -117,7 +117,7 @@ describe Jasmine::Formatters::Console do
117
117
 
118
118
  it 'shows the spec counts (pluralized)' do
119
119
  results = [pending_result, pending_result]
120
- console = Jasmine::Formatters::Console.new(outputter)
120
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
121
121
  console.format(results)
122
122
  console.done(run_details)
123
123
 
@@ -126,7 +126,7 @@ describe Jasmine::Formatters::Console do
126
126
 
127
127
  it 'shows the pending reason' do
128
128
  results = [pending_result]
129
- console = Jasmine::Formatters::Console.new(outputter)
129
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
130
130
  console.format(results)
131
131
  console.done(run_details)
132
132
 
@@ -135,7 +135,7 @@ describe Jasmine::Formatters::Console do
135
135
 
136
136
  it 'shows the default pending reason' do
137
137
  results = [Jasmine::Result.new(pending_raw_result.merge('pendingReason' => ''))]
138
- console = Jasmine::Formatters::Console.new(outputter)
138
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
139
139
  console.format(results)
140
140
  console.done(run_details)
141
141
 
@@ -147,7 +147,7 @@ describe Jasmine::Formatters::Console do
147
147
 
148
148
  it 'should not mention pending specs' do
149
149
  results = [passing_result]
150
- console = Jasmine::Formatters::Console.new(outputter)
150
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
151
151
  console.format(results)
152
152
  console.done(run_details)
153
153
 
@@ -158,7 +158,7 @@ describe Jasmine::Formatters::Console do
158
158
  describe 'when the tests were randomized' do
159
159
  it 'should print a message with the seed' do
160
160
  results = [passing_result]
161
- console = Jasmine::Formatters::Console.new(outputter)
161
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
162
162
  console.format(results)
163
163
  console.done({ 'order' => { 'random' => true, 'seed' => '4325' } })
164
164
 
@@ -168,7 +168,7 @@ describe Jasmine::Formatters::Console do
168
168
 
169
169
  describe 'with loading errors' do
170
170
  it 'should show the errors' do
171
- console = Jasmine::Formatters::Console.new(outputter)
171
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
172
172
  console.done({ 'failedExpectations' => [
173
173
  {
174
174
  'globalErrorType' => 'load',
@@ -190,7 +190,7 @@ describe Jasmine::Formatters::Console do
190
190
 
191
191
  describe 'with errors in a global afterAll' do
192
192
  it 'should show the errors' do
193
- console = Jasmine::Formatters::Console.new(outputter)
193
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
194
194
  console.done({ 'failedExpectations' => [
195
195
  {
196
196
  'globalErrorType' => 'afterAll',
@@ -212,7 +212,7 @@ describe Jasmine::Formatters::Console do
212
212
 
213
213
  describe 'when the overall status is incomplete' do
214
214
  it 'shows the reason' do
215
- console = Jasmine::Formatters::Console.new(outputter)
215
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
216
216
  console.done({
217
217
  'overallStatus' => 'incomplete',
218
218
  'incompleteReason' => 'not all bars were frobnicated'
@@ -223,7 +223,7 @@ describe Jasmine::Formatters::Console do
223
223
  end
224
224
 
225
225
  it 'shows deprecation warnings' do
226
- console = Jasmine::Formatters::Console.new(outputter)
226
+ console = Jasmine::Formatters::Console.new(double(:config, color: true), outputter)
227
227
  console.format([Jasmine::Result.new(deprecation_raw_result)])
228
228
  console.done({ 'deprecationWarnings' => [{ 'message' => 'globally deprecated', 'stack' => nil }] })
229
229
 
@@ -232,6 +232,40 @@ describe Jasmine::Formatters::Console do
232
232
  end
233
233
  end
234
234
 
235
+ describe 'enabling and disabling colorized output' do
236
+ context '.color_enabled controls whether it outputs with color or not' do
237
+ it 'prints colored outputs' do
238
+ config = double(:config, color: true)
239
+
240
+ formatter = Jasmine::Formatters::Console.new(config, outputter)
241
+ formatter.format([passing_result])
242
+ formatter.format([failing_result])
243
+ formatter.format([pending_result])
244
+ formatter.done(run_details)
245
+
246
+ expect(outputter_output).to include("\e[31m")
247
+ expect(outputter_output).to include("\e[32m")
248
+ expect(outputter_output).to include("\e[33m")
249
+ expect(outputter_output).to include("\e[0m")
250
+ end
251
+
252
+ it "doesn't print colored outputs" do
253
+ config = double(:config, color: false)
254
+
255
+ formatter = Jasmine::Formatters::Console.new(config, outputter)
256
+ formatter.format([passing_result])
257
+ formatter.format([failing_result])
258
+ formatter.format([pending_result])
259
+ formatter.done(run_details)
260
+
261
+ expect(outputter_output).not_to include("\e[31m")
262
+ expect(outputter_output).not_to include("\e[32m")
263
+ expect(outputter_output).not_to include("\e[33m")
264
+ expect(outputter_output).not_to include("\e[0m")
265
+ end
266
+ end
267
+ end
268
+
235
269
  def failing_result
236
270
  Jasmine::Result.new(failing_raw_result)
237
271
  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.5.1
4
+ version: 3.8.1
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: 2020-02-06 00:00:00.000000000 Z
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '6'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 6.0.0
22
+ version: 7.0.0
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '5'
29
+ version: '6'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 6.0.0
32
+ version: 7.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rack-test
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,42 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 3.5.0
95
+ version: 3.8.0
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 3.5.0
102
+ version: 3.8.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rack
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 1.2.1
109
+ version: 2.1.4
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: 1.2.1
116
+ version: 2.1.4
117
+ - !ruby/object:Gem::Dependency
118
+ name: webrick
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
117
131
  - !ruby/object:Gem::Dependency
118
132
  name: rake
119
133
  requirement: !ruby/object:Gem::Requirement
@@ -150,10 +164,10 @@ executables:
150
164
  extensions: []
151
165
  extra_rdoc_files: []
152
166
  files:
167
+ - ".circleci/config.yml"
153
168
  - ".editorconfig"
154
169
  - ".gitignore"
155
170
  - ".rspec"
156
- - ".travis.yml"
157
171
  - Gemfile
158
172
  - HOW_TO_TEST.markdown
159
173
  - MIT.LICENSE
@@ -215,6 +229,10 @@ files:
215
229
  - release_notes/3.4.0.md
216
230
  - release_notes/3.5.0.md
217
231
  - release_notes/3.5.1.md
232
+ - release_notes/3.6.0.md
233
+ - release_notes/3.7.0.md
234
+ - release_notes/3.8.0.md
235
+ - release_notes/3.8.1.md
218
236
  - release_notes/v1.2.1.md
219
237
  - release_notes/v1.3.2.md
220
238
  - release_notes/v2.0.0.md
@@ -289,8 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
307
  - !ruby/object:Gem::Version
290
308
  version: '0'
291
309
  requirements: []
292
- rubyforge_project:
293
- rubygems_version: 2.7.6.2
310
+ rubygems_version: 3.1.2
294
311
  signing_key:
295
312
  specification_version: 4
296
313
  summary: JavaScript BDD framework
data/.travis.yml DELETED
@@ -1,35 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
-
5
- addons:
6
- chrome: stable
7
-
8
- rvm:
9
- - "2.3"
10
- - "2.5"
11
- - "2.6"
12
-
13
- env:
14
- - "RAILS_VERSION=rails6"
15
- - "RAILS_VERSION=rails5"
16
- - "RAILS_VERSION=rails4"
17
- - "RAILS_VERSION=pojs"
18
-
19
- script: "if [ $PERFORMANCE_SPECS ];then bundle exec rake performance_specs --trace; else bundle exec rake --trace; fi"
20
-
21
- jobs:
22
- fast_finish: true
23
- include:
24
- - env:
25
- - "PERFORMANCE_SPECS=true"
26
- - "RAILS_VERSION=rails5"
27
- exclude:
28
- - rvm: "2.3"
29
- env: "RAILS_VERSION=rails6"
30
-
31
- before_install:
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