jasmine 3.5.1 → 3.6.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
2
  SHA256:
3
- metadata.gz: 1c3adadebd009bfacd1fab26771b31c42b76ee42068e88cd61bc71e5a259c884
4
- data.tar.gz: 82c143fa60146d38d0c5f1c920f36b63552d6a08040358a8d8bffcdbe0ff424a
3
+ metadata.gz: f5041dde9ff09182c2b5a3df9c1197f5271688e38f0e823155d069ae4bfdc473
4
+ data.tar.gz: a6b003232f7ef9a71ae0283b9b486ff275efdeaed368f08fa6f2576c9050382d
5
5
  SHA512:
6
- metadata.gz: b7be5ec8f81a983be7dce34d006d46e836f39f27e455548ae73f4463e03d3886bfd5a9b4c831d2de814a42798feb6eff1e80d1a2f420706dd5fb6d81fb5a466e
7
- data.tar.gz: 9ab969b3f529485c9633ad5d21e9953bead00bbe45ea9f8874ddccbf59cf862a152954410a1f5c1c85f08463120fadeab0895f3dab4e152331916b0e01d87b14
6
+ metadata.gz: 5709eb88e178882d97c11dc350fc7c55857f4612b8372e2b1ac1cc3504e8e386bcb578db024372d2454621cbd647713bcac68c9fccb85c31b7fa89785b0785bd
7
+ data.tar.gz: ebcfdb3e7b9b41cda30b63e29d692701d2ec88f820202cf2e4ff5dbff2bbf420edec9cb102f2881266efeb19ab6208610f37fdb0bfa712105123e0ab02524d16
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
@@ -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
@@ -1,4 +1,4 @@
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 [![Build Status](https://travis-ci.org/jasmine/jasmine-gem.png?branch=main)](https://travis-ci.org/jasmine/jasmine-gem)
2
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
3
  [![Gem Version](https://badge.fury.io/rb/jasmine.svg)](https://badge.fury.io/rb/jasmine)
4
4
 
@@ -93,6 +93,16 @@ Jasmine.configure do |config|
93
93
  end
94
94
  ```
95
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
+
96
106
  ## Using headless Chrome
97
107
 
98
108
  * Add `chrome_remote` as a dependency
@@ -37,7 +37,7 @@ 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'
40
+ s.add_dependency 'jasmine-core', '~> 3.6.0'
41
41
  s.add_dependency 'rack', '>= 1.2.1'
42
42
  s.add_dependency 'rake'
43
43
  s.add_dependency 'phantomjs'
@@ -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
-
@@ -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.6.0"
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)_
@@ -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.6.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: 2020-02-06 00:00:00.000000000 Z
11
+ date: 2020-07-24 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,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 3.5.0
95
+ version: 3.6.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.6.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rack
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -215,6 +215,7 @@ files:
215
215
  - release_notes/3.4.0.md
216
216
  - release_notes/3.5.0.md
217
217
  - release_notes/3.5.1.md
218
+ - release_notes/3.6.0.md
218
219
  - release_notes/v1.2.1.md
219
220
  - release_notes/v1.3.2.md
220
221
  - release_notes/v2.0.0.md