jasmine 2.0.0 → 2.99.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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +27 -13
  3. data/Gemfile +9 -9
  4. data/HOW_TO_TEST.markdown +1 -0
  5. data/README.markdown +18 -11
  6. data/jasmine.gemspec +14 -6
  7. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/jasmine_examples/SpecHelper.js +1 -1
  8. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +38 -5
  9. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb +14 -9
  10. data/lib/jasmine/application.rb +2 -2
  11. data/lib/jasmine/asset_expander.rb +56 -8
  12. data/lib/jasmine/base.rb +5 -5
  13. data/lib/jasmine/ci_runner.rb +50 -0
  14. data/lib/jasmine/command_line_tool.rb +4 -4
  15. data/lib/jasmine/config.rb +34 -5
  16. data/lib/jasmine/configuration.rb +31 -11
  17. data/lib/jasmine/dependencies.rb +8 -37
  18. data/lib/jasmine/formatters/console.rb +69 -4
  19. data/lib/jasmine/formatters/exit_code.rb +4 -6
  20. data/lib/jasmine/formatters/multi.rb +3 -11
  21. data/lib/jasmine/path_expander.rb +5 -1
  22. data/lib/jasmine/path_mapper.rb +11 -2
  23. data/lib/jasmine/railtie.rb +1 -1
  24. data/lib/jasmine/result.rb +21 -9
  25. data/lib/jasmine/ruby_versions.rb +11 -0
  26. data/lib/jasmine/run.html.erb +1 -1
  27. data/lib/jasmine/runners/phantom_boot.js +15 -0
  28. data/lib/jasmine/runners/phantom_jasmine_run.js +39 -43
  29. data/lib/jasmine/runners/phantom_js.rb +53 -8
  30. data/lib/jasmine/server.rb +7 -10
  31. data/lib/jasmine/tasks/jasmine.rake +29 -25
  32. data/lib/jasmine/version.rb +1 -1
  33. data/lib/jasmine/yaml_config_parser.rb +28 -0
  34. data/lib/jasmine.rb +1 -1
  35. data/release_notes/v2.0.1.md +31 -0
  36. data/release_notes/v2.0.2.md +17 -0
  37. data/release_notes/v2.0.3.md +31 -0
  38. data/release_notes/v2.1.0.md +11 -0
  39. data/release_notes/v2.2.0.md +31 -0
  40. data/release_notes/v2.3.0.md +27 -0
  41. data/release_notes/v2.3.1.md +14 -0
  42. data/release_notes/v2.4.0.md +20 -0
  43. data/release_notes/v2.5.0.md +35 -0
  44. data/release_notes/v2.5.1.md +12 -0
  45. data/release_notes/v2.5.2.md +22 -0
  46. data/release_notes/v2.6.0.md +17 -0
  47. data/release_notes/v2.6.1.md +11 -0
  48. data/release_notes/v2.7.0.md +28 -0
  49. data/release_notes/v2.8.0.md +21 -0
  50. data/release_notes/v2.9.0.md +22 -0
  51. data/release_notes/v2.99.md +13 -0
  52. data/spec/application_integration_spec.rb +3 -3
  53. data/spec/application_spec.rb +27 -11
  54. data/spec/base_spec.rb +27 -6
  55. data/spec/ci_runner_spec.rb +137 -0
  56. data/spec/configuration_spec.rb +57 -23
  57. data/spec/fixture/afterall_spec.js +8 -0
  58. data/spec/fixture/console_log_spec.js +5 -0
  59. data/spec/fixture/exception_test.js +1 -0
  60. data/spec/fixture/phantomConfig.js +6 -0
  61. data/spec/fixture/viewport_spec.js +6 -0
  62. data/spec/jasmine_command_line_tool_spec.rb +46 -27
  63. data/spec/jasmine_pojs_spec.rb +73 -12
  64. data/spec/jasmine_rails_spec.rb +107 -41
  65. data/spec/lib/jasmine/formatters/console_spec.rb +124 -26
  66. data/spec/lib/jasmine/formatters/exit_code_spec.rb +34 -0
  67. data/spec/lib/jasmine/formatters/multi_spec.rb +16 -6
  68. data/spec/page_spec.rb +2 -2
  69. data/spec/path_expander_spec.rb +22 -5
  70. data/spec/path_mapper_spec.rb +14 -9
  71. data/spec/performance/phantom_js_runner_performance_spec.rb +1 -1
  72. data/spec/phantom_js_spec.rb +14 -0
  73. data/spec/rack/jasmine/runner_spec.rb +2 -2
  74. data/spec/result_spec.rb +17 -7
  75. data/spec/server_spec.rb +13 -39
  76. data/spec/spec_helper.rb +54 -6
  77. data/spec/yaml_config_parser_spec.rb +21 -21
  78. metadata +75 -36
  79. data/lib/jasmine/asset_bundle.rb +0 -68
@@ -0,0 +1,137 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::CiRunner do
4
+ let(:runner) { double(:runner, :run => nil) }
5
+ let(:runner_factory) { double(:runner_factory, :call => runner) }
6
+
7
+ let(:config) do
8
+ double(:configuration,
9
+ :runner => runner_factory,
10
+ :formatters => [],
11
+ :host => 'http://foo.bar.com',
12
+ :port => '1234',
13
+ :rack_options => 'rack options',
14
+ :stop_spec_on_expectation_failure => false,
15
+ :random => false
16
+ )
17
+ end
18
+
19
+ let(:thread_instance) { double(:thread, :abort_on_exception= => nil) }
20
+ let(:fake_thread) do
21
+ thread = double(:thread)
22
+ allow(thread).to receive(:new) do |&block|
23
+ @thread_block = block
24
+ thread_instance
25
+ end
26
+ thread
27
+ end
28
+ let(:application_factory) { double(:application, :app => 'my fake app') }
29
+ let(:fake_server) { double(:server, :start => nil) }
30
+ let(:server_factory) { double(:server_factory, :new => fake_server) }
31
+ let(:outputter) { double(:outputter, :puts => nil) }
32
+
33
+ before do
34
+ allow(Jasmine).to receive(:wait_for_listener)
35
+ end
36
+
37
+ it 'starts a server and runner' do
38
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
39
+
40
+ ci_runner.run
41
+
42
+ expect(config).to have_received(:port).with(:ci).at_least(:once)
43
+ expect(config).not_to have_received(:port).with(:server)
44
+
45
+ expect(runner_factory).to have_received(:call).with(instance_of(Jasmine::Formatters::Multi), /\bthrowFailures=false\b/)
46
+ expect(runner_factory).to have_received(:call).with(instance_of(Jasmine::Formatters::Multi), /\brandom=false\b/)
47
+
48
+ expect(application_factory).to have_received(:app).with(config)
49
+ expect(server_factory).to have_received(:new).with('1234', 'my fake app', 'rack options')
50
+
51
+ expect(fake_thread).to have_received(:new)
52
+ expect(thread_instance).to have_received(:abort_on_exception=).with(true)
53
+
54
+ @thread_block.call
55
+ expect(fake_server).to have_received(:start)
56
+
57
+ expect(Jasmine).to have_received(:wait_for_listener).with('1234', 'foo.bar.com')
58
+
59
+ expect(runner).to have_received(:run)
60
+ end
61
+
62
+ it 'adds runner boot files when necessary' do
63
+ expect(runner).to receive(:boot_js).at_least(:once) { 'foo/bar/baz.js' }
64
+ expect(config).to receive(:runner_boot_dir=).with('foo/bar')
65
+ expect(config).to receive(:runner_boot_files=) do |proc|
66
+ expect(proc.call).to eq ['foo/bar/baz.js']
67
+ end
68
+
69
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
70
+
71
+ ci_runner.run
72
+ end
73
+
74
+ it 'returns true for a successful run' do
75
+ allow(Jasmine::Formatters::ExitCode).to receive(:new) { double(:exit_code, :succeeded? => true) }
76
+
77
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
78
+
79
+ expect(ci_runner.run).to be(true)
80
+ end
81
+
82
+ it 'returns false for a failed run' do
83
+ allow(Jasmine::Formatters::ExitCode).to receive(:new) { double(:exit_code, :succeeded? => false) }
84
+
85
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
86
+
87
+ expect(ci_runner.run).to be(false)
88
+ end
89
+
90
+ it 'can tell the jasmine page to throw expectation failures' do
91
+ allow(config).to receive(:stop_spec_on_expectation_failure) { true }
92
+
93
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
94
+
95
+ ci_runner.run
96
+
97
+ expect(runner_factory).to have_received(:call).with(instance_of(Jasmine::Formatters::Multi), /\bthrowFailures=true\b/)
98
+ end
99
+
100
+ it 'can tell the jasmine page to randomize' do
101
+ allow(config).to receive(:random) { true }
102
+
103
+ ci_runner = Jasmine::CiRunner.new(config, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
104
+
105
+ ci_runner.run
106
+
107
+ expect(runner_factory).to have_received(:call).with(instance_of(Jasmine::Formatters::Multi), /\brandom=true\b/)
108
+ end
109
+
110
+ it 'allows randomization to be turned on, overriding the config' do
111
+ allow(config).to receive(:random) { false }
112
+
113
+ ci_runner = Jasmine::CiRunner.new(config, random: true, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
114
+
115
+ ci_runner.run
116
+
117
+ expect(runner_factory).to have_received(:call).with(instance_of(Jasmine::Formatters::Multi), /\brandom=true\b/)
118
+ end
119
+
120
+ it 'allows randomization to be turned off, overriding the config' do
121
+ allow(config).to receive(:random) { true }
122
+
123
+ ci_runner = Jasmine::CiRunner.new(config, random: false, thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
124
+
125
+ ci_runner.run
126
+
127
+ expect(runner_factory).to have_received(:call).with(instance_of(Jasmine::Formatters::Multi), /\brandom=false\b/)
128
+ end
129
+
130
+ it 'allows a randomization seed to be specified' do
131
+ ci_runner = Jasmine::CiRunner.new(config, seed: '4231', thread: fake_thread, application_factory: application_factory, server_factory: server_factory, outputter: outputter)
132
+
133
+ ci_runner.run
134
+
135
+ expect(runner_factory).to have_received(:call).with(instance_of(Jasmine::Formatters::Multi), /\bseed=4231\b/)
136
+ end
137
+ end
@@ -53,10 +53,10 @@ describe Jasmine::Configuration do
53
53
  config.add_path_mapper(lambda { |c| test_mapper1.new(c) })
54
54
  config.add_path_mapper(lambda { |c| test_mapper2.new(c) })
55
55
  config.add_path_mapper(lambda { |c| test_mapper3.new(c) })
56
- config.css_files.should == []
56
+ expect(config.css_files).to eq []
57
57
  config.jasmine_css_files = lambda { %w(jasmine_css) }
58
58
  config.css_files = lambda { %w(css) }
59
- config.css_files.should == %w(mapped_jasmine/jasmine_css/jasmine mapped_src/css/src)
59
+ expect(config.css_files).to eq %w(mapped_jasmine/jasmine_css/jasmine mapped_src/css/src)
60
60
  end
61
61
  end
62
62
 
@@ -66,14 +66,16 @@ describe Jasmine::Configuration do
66
66
  config.add_path_mapper(lambda { |c| test_mapper1.new(c) })
67
67
  config.add_path_mapper(lambda { |c| test_mapper2.new(c) })
68
68
  config.add_path_mapper(lambda { |c| test_mapper3.new(c) })
69
- config.js_files.should == []
69
+ expect(config.js_files).to eq []
70
70
  config.jasmine_files = lambda { %w(jasmine) }
71
71
  config.src_files = lambda { %w(src) }
72
72
  config.boot_files = lambda { %w(boot) }
73
73
  config.spec_files = lambda { %w(spec) }
74
- config.js_files.should == %w(
74
+ config.helper_files = lambda { %w(helper) }
75
+ expect(config.js_files).to eq %w(
75
76
  mapped_jasmine/jasmine/jasmine
76
77
  mapped_boot/boot/boot mapped_src/src/src
78
+ mapped_spec/helper/spec
77
79
  mapped_spec/spec/spec)
78
80
  end
79
81
  end
@@ -84,8 +86,8 @@ describe Jasmine::Configuration do
84
86
  result = double
85
87
  config.add_rack_path('some/path', lambda { result })
86
88
  map = config.rack_path_map
87
- map['some/path'].should be
88
- map['some/path'].call.should == result
89
+ expect(map['some/path']).to be
90
+ expect(map['some/path'].call).to eq result
89
91
  end
90
92
  end
91
93
 
@@ -94,26 +96,42 @@ describe Jasmine::Configuration do
94
96
  config = Jasmine::Configuration.new()
95
97
  app = double
96
98
  config.add_rack_app(app)
97
- config.rack_apps.should == [[app, nil]]
99
+ expect(config.rack_apps).to eq [{ :app => app, :args => [], :block => nil }]
98
100
  end
99
- it 'permits the addition of arbitary rack apps with arbitrary config' do
101
+
102
+ it 'permits the addition of arbitary rack apps with a config block' do
100
103
  config = Jasmine::Configuration.new()
101
104
  app = double
102
105
  block = lambda { 'foo' }
103
106
  config.add_rack_app(app, &block)
104
- config.rack_apps.should == [[app, block]]
107
+ expect(config.rack_apps).to eq [{ :app => app, :args => [], :block => block }]
108
+ end
109
+
110
+ it 'permits the addition of arbitary rack apps with arbitrary config' do
111
+ config = Jasmine::Configuration.new()
112
+ app = double
113
+ config.add_rack_app(app, { :foo => 'bar' })
114
+ expect(config.rack_apps).to eq [{ :app => app, :args => [{ :foo => 'bar' }], :block => nil }]
115
+ end
116
+
117
+ it 'permits the addition of arbitary rack apps with arbitrary config and a config block' do
118
+ config = Jasmine::Configuration.new()
119
+ app = double
120
+ block = lambda { 'foo' }
121
+ config.add_rack_app(app, { :foo => 'bar' }, &block)
122
+ expect(config.rack_apps).to eq [{ :app => app, :args => [{ :foo => 'bar' }], :block => block }]
105
123
  end
106
124
  end
107
125
 
108
126
  describe 'host' do
109
127
  it 'should default to localhost' do
110
- Jasmine::Configuration.new().host.should == 'http://localhost'
128
+ expect(Jasmine::Configuration.new().host).to eq 'http://localhost'
111
129
  end
112
130
 
113
131
  it 'returns host if set' do
114
132
  config = Jasmine::Configuration.new()
115
133
  config.host = 'foo'
116
- config.host.should == 'foo'
134
+ expect(config.host).to eq 'foo'
117
135
  end
118
136
  end
119
137
 
@@ -121,36 +139,52 @@ describe Jasmine::Configuration do
121
139
  it 'returns value if set' do
122
140
  config = Jasmine::Configuration.new()
123
141
  config.spec_format = 'fish'
124
- config.spec_format.should == 'fish'
142
+ expect(config.spec_format).to eq 'fish'
143
+ end
144
+ end
145
+
146
+ describe 'prevent phantomjs auto install' do
147
+ it 'returns value if set' do
148
+ config = Jasmine::Configuration.new()
149
+ config.prevent_phantom_js_auto_install = true
150
+ expect(config.prevent_phantom_js_auto_install).to eq true
151
+ end
152
+ end
153
+
154
+ describe 'show full stack trace' do
155
+ it 'returns value if set' do
156
+ config = Jasmine::Configuration.new()
157
+ config.show_full_stack_trace = true
158
+ expect(config.show_full_stack_trace).to eq true
125
159
  end
126
160
  end
127
161
 
128
162
  describe 'jasmine ports' do
129
163
  it 'returns new CI port and caches return value' do
130
164
  config = Jasmine::Configuration.new()
131
- Jasmine.stub(:find_unused_port).and_return('1234')
132
- config.port(:ci).should == '1234'
133
- Jasmine.stub(:find_unused_port).and_return('4321')
134
- config.port(:ci).should == '1234'
165
+ allow(Jasmine).to receive(:find_unused_port).and_return('1234')
166
+ expect(config.port(:ci)).to eq '1234'
167
+ allow(Jasmine).to receive(:find_unused_port).and_return('4321')
168
+ expect(config.port(:ci)).to eq '1234'
135
169
  end
136
170
 
137
171
  it 'returns ci port if configured' do
138
172
  config = Jasmine::Configuration.new()
139
173
  config.ci_port = '5678'
140
- Jasmine.stub(:find_unused_port).and_return('1234')
141
- config.port(:ci).should == '5678'
174
+ allow(Jasmine).to receive(:find_unused_port).and_return('1234')
175
+ expect(config.port(:ci)).to eq '5678'
142
176
  end
143
177
 
144
178
  it 'returns configured server port' do
145
179
  config = Jasmine::Configuration.new()
146
180
  config.server_port = 'fish'
147
- config.port(:server).should == 'fish'
181
+ expect(config.port(:server)).to eq 'fish'
148
182
  end
149
183
 
150
184
  it 'returns default server port' do
151
185
  config = Jasmine::Configuration.new()
152
186
 
153
- config.port(:server).should == 8888
187
+ expect(config.port(:server)).to eq 8888
154
188
  end
155
189
  end
156
190
 
@@ -158,13 +192,13 @@ describe Jasmine::Configuration do
158
192
  it 'returns value if set' do
159
193
  config = Jasmine::Configuration.new()
160
194
  config.formatters = ['pants']
161
- config.formatters.should == ['pants']
195
+ expect(config.formatters).to eq ['pants']
162
196
  end
163
197
 
164
198
  it 'returns defaults' do
165
199
  config = Jasmine::Configuration.new()
166
200
 
167
- config.formatters.should == [Jasmine::Formatters::Console]
201
+ expect(config.formatters).to eq [Jasmine::Formatters::Console]
168
202
  end
169
203
  end
170
204
 
@@ -173,7 +207,7 @@ describe Jasmine::Configuration do
173
207
  config = Jasmine::Configuration.new
174
208
  foo = double(:foo)
175
209
  config.runner = foo
176
- config.runner.should == foo
210
+ expect(config.runner).to eq foo
177
211
  end
178
212
 
179
213
  it 'does nothing by default' do
@@ -0,0 +1,8 @@
1
+ describe('failing afterAll', function() {
2
+ afterAll(function() {
3
+ throw 'afterAll go boom';
4
+ });
5
+
6
+ it('is fine otherwise', function() {
7
+ });
8
+ });
@@ -0,0 +1,5 @@
1
+ describe('console.log', function() {
2
+ it('can be passed through', function() {
3
+ console.log("I'm in the webpage!");
4
+ });
5
+ });
@@ -0,0 +1 @@
1
+ desibe('oops', function() {});
@@ -0,0 +1,6 @@
1
+ exports.configure = function (page) {
2
+ page.viewportSize = {
3
+ width: 200,
4
+ height: 400
5
+ };
6
+ };
@@ -0,0 +1,6 @@
1
+ describe('having a viewport', function() {
2
+ it('should have a small viewport', function() {
3
+ expect(window.innerWidth).toBe(200);
4
+ expect(window.innerHeight).toBe(400);
5
+ });
6
+ });
@@ -14,26 +14,35 @@ describe 'Jasmine command line tool' do
14
14
  describe 'without a Gemfile' do
15
15
  it 'should create files on init' do
16
16
  output = capture_stdout { Jasmine::CommandLineTool.new.process ['init'] }
17
- output.should =~ /Jasmine has been installed\./
17
+ expect(output).to match /Jasmine has been installed\./
18
18
 
19
- File.exists?(File.join(@tmp, 'spec/javascripts/helpers/.gitkeep')).should == true
20
- File.exists?(File.join(@tmp, 'spec/javascripts/support/jasmine.yml')).should == true
21
- File.exists?(File.join(@tmp, 'Rakefile')).should == true
19
+ expect(File.exists?(File.join(@tmp, 'spec/javascripts/helpers/.gitkeep'))).to eq true
20
+ expect(File.exists?(File.join(@tmp, 'spec/javascripts/support/jasmine.yml'))).to eq true
21
+ expect(File.exists?(File.join(@tmp, 'Rakefile'))).to eq true
22
22
  ci_output = `rake --trace jasmine:ci`
23
- ci_output.should =~ (/0 specs, 0 failures/)
23
+ expect(ci_output).to match (/0 specs, 0 failures/)
24
+ end
25
+
26
+ it 'should not have rails-like paths' do
27
+ output = capture_stdout { Jasmine::CommandLineTool.new.process ['init'] }
28
+ expect(output).to match /Jasmine has been installed\./
29
+
30
+ config = YAML.load_file(File.join(@tmp, 'spec/javascripts/support/jasmine.yml'))
31
+ expect(config['src_files']).to eq ['public/javascripts/**/*.js']
32
+ expect(config['stylesheets']).to eq ['stylesheets/**/*.css']
24
33
  end
25
34
 
26
35
  it 'should create a new Rakefile if it does not exist' do
27
36
  output = capture_stdout { Jasmine::CommandLineTool.new.process ["init"] }
28
- output.should =~ /Jasmine has been installed\./
29
- File.read(File.join(@tmp, 'Rakefile')).should include('jasmine.rake')
37
+ expect(output).to match /Jasmine has been installed\./
38
+ expect(File.read(File.join(@tmp, 'Rakefile'))).to include('jasmine.rake')
30
39
  end
31
40
 
32
41
  it "should append to an existing Rakefile" do
33
42
  FileUtils.cp("#{@old_dir}/spec/fixture/Rakefile", @tmp)
34
43
  output = capture_stdout { Jasmine::CommandLineTool.new.process ["init"] }
35
- output.should =~ /Jasmine has been installed\./
36
- File.read(File.join(@tmp, 'Rakefile')).should include('jasmine_flunk')
44
+ expect(output).to match /Jasmine has been installed\./
45
+ expect(File.read(File.join(@tmp, 'Rakefile'))).to include('jasmine_flunk')
37
46
  end
38
47
  end
39
48
 
@@ -50,9 +59,9 @@ describe 'Jasmine command line tool' do
50
59
  Jasmine::CommandLineTool.new.process ['init']
51
60
  }.to raise_error SystemExit
52
61
  }
53
- output.should =~ /attempting to run jasmine init in a Rails project/
62
+ expect(output).to match /attempting to run jasmine init in a Rails project/
54
63
 
55
- Dir.entries(@tmp).sort.should == [".", "..", "Gemfile"]
64
+ expect(Dir.entries(@tmp).sort).to eq [".", "..", "Gemfile"]
56
65
  end
57
66
 
58
67
  it 'should allow the user to override the warning' do
@@ -61,10 +70,10 @@ describe 'Jasmine command line tool' do
61
70
  Jasmine::CommandLineTool.new.process ['init', '--force']
62
71
  }.not_to raise_error
63
72
  }
64
- output.should =~ /Jasmine has been installed\./
73
+ expect(output).to match /Jasmine has been installed\./
65
74
 
66
- File.exists?(File.join(@tmp, 'spec/javascripts/helpers/.gitkeep')).should == true
67
- File.exists?(File.join(@tmp, 'spec/javascripts/support/jasmine.yml')).should == true
75
+ expect(File.exists?(File.join(@tmp, 'spec/javascripts/helpers/.gitkeep'))).to eq true
76
+ expect(File.exists?(File.join(@tmp, 'spec/javascripts/support/jasmine.yml'))).to eq true
68
77
  end
69
78
  end
70
79
 
@@ -81,43 +90,53 @@ describe 'Jasmine command line tool' do
81
90
  Jasmine::CommandLineTool.new.process ['init']
82
91
  }.not_to raise_error
83
92
  }
84
- output.should =~ /Jasmine has been installed\./
93
+ expect(output).to match /Jasmine has been installed\./
85
94
 
86
- File.exists?(File.join(@tmp, 'spec/javascripts/helpers/.gitkeep')).should == true
87
- File.exists?(File.join(@tmp, 'spec/javascripts/support/jasmine.yml')).should == true
95
+ expect(File.exists?(File.join(@tmp, 'spec/javascripts/helpers/.gitkeep'))).to eq true
96
+ expect(File.exists?(File.join(@tmp, 'spec/javascripts/support/jasmine.yml'))).to eq true
88
97
  end
89
98
  end
90
99
  end
91
100
 
92
101
  it 'should install the examples' do
93
102
  output = capture_stdout { Jasmine::CommandLineTool.new.process ['examples'] }
94
- output.should =~ /Jasmine has installed some examples\./
95
- File.exists?(File.join(@tmp, 'public/javascripts/jasmine_examples/Player.js')).should == true
96
- File.exists?(File.join(@tmp, 'public/javascripts/jasmine_examples/Song.js')).should == true
97
- File.exists?(File.join(@tmp, 'spec/javascripts/jasmine_examples/PlayerSpec.js')).should == true
98
- File.exists?(File.join(@tmp, 'spec/javascripts/helpers/jasmine_examples/SpecHelper.js')).should == true
103
+ expect(output).to match /Jasmine has installed some examples\./
104
+ expect(File.exists?(File.join(@tmp, 'public/javascripts/jasmine_examples/Player.js'))).to eq true
105
+ expect(File.exists?(File.join(@tmp, 'public/javascripts/jasmine_examples/Song.js'))).to eq true
106
+ expect(File.exists?(File.join(@tmp, 'spec/javascripts/jasmine_examples/PlayerSpec.js'))).to eq true
107
+ expect(File.exists?(File.join(@tmp, 'spec/javascripts/helpers/jasmine_examples/SpecHelper.js'))).to eq true
99
108
 
100
109
  capture_stdout { Jasmine::CommandLineTool.new.process ['init'] }
101
110
  ci_output = `rake --trace jasmine:ci`
102
- ci_output.should =~ (/[1-9]\d* specs, 0 failures/)
111
+ expect(ci_output).to match (/[1-9]\d* specs, 0 failures/)
103
112
  end
104
113
 
105
114
  it 'should include license info' do
106
115
  output = capture_stdout { Jasmine::CommandLineTool.new.process ['license'] }
107
- output.should =~ /Copyright/
116
+ expect(output).to match /Copyright/
108
117
  end
109
118
 
110
119
  it 'should copy boot.js' do
111
120
  output = capture_stdout { Jasmine::CommandLineTool.new.process ['copy_boot_js'] }
112
- output.should =~ /Jasmine has copied an example boot.js to spec\/javascripts\/support/
121
+ expect(output).to match /Jasmine has copied an example boot.js to spec\/javascripts\/support/
113
122
 
114
- File.exists?(File.join(@tmp, 'spec/javascripts/support/boot.js')).should == true
123
+ expect(File.exists?(File.join(@tmp, 'spec/javascripts/support/boot.js'))).to eq true
115
124
  end
116
125
 
117
126
  it 'should not overwrite an existing boot.js' do
118
127
  capture_stdout { Jasmine::CommandLineTool.new.process ['copy_boot_js'] }
119
128
  output = capture_stdout { Jasmine::CommandLineTool.new.process ['copy_boot_js'] }
120
129
 
121
- output.should =~ /already exists/
130
+ expect(output).to match /already exists/
131
+ end
132
+
133
+ it 'should show help' do
134
+ no_arg_output = capture_stdout { Jasmine::CommandLineTool.new.process [] }
135
+ expect(no_arg_output).to_not match /unknown command/
136
+ expect(no_arg_output).to match /Usage:/
137
+
138
+ unknown_arg_output = capture_stdout { Jasmine::CommandLineTool.new.process ['blurgh', 'blargh'] }
139
+ expect(unknown_arg_output).to match /unknown command blurgh blargh/
140
+ expect(unknown_arg_output).to match /Usage:/
122
141
  end
123
142
  end
@@ -18,35 +18,36 @@ describe "POJS jasmine install" do
18
18
  end
19
19
 
20
20
  it "should find the Jasmine configuration files" do
21
- File.exists?("spec/javascripts/support/jasmine.yml").should == true
21
+ expect(File.exists?("spec/javascripts/support/jasmine.yml")).to eq true
22
22
  end
23
23
 
24
24
  it "should find the Jasmine example files" do
25
- File.exists?("public/javascripts/jasmine_examples/Player.js").should == true
26
- File.exists?("public/javascripts/jasmine_examples/Song.js").should == true
25
+ expect(File.exists?("public/javascripts/jasmine_examples/Player.js")).to eq true
26
+ expect(File.exists?("public/javascripts/jasmine_examples/Song.js")).to eq true
27
27
 
28
- File.exists?("spec/javascripts/jasmine_examples/PlayerSpec.js").should == true
29
- File.exists?("spec/javascripts/helpers/jasmine_examples/SpecHelper.js").should == true
28
+ expect(File.exists?("spec/javascripts/jasmine_examples/PlayerSpec.js")).to eq true
29
+ expect(File.exists?("spec/javascripts/helpers/jasmine_examples/SpecHelper.js")).to eq true
30
30
 
31
- File.exists?("spec/javascripts/support/jasmine.yml").should == true
31
+ expect(File.exists?("spec/javascripts/support/jasmine.yml")).to eq true
32
32
  end
33
33
 
34
34
  it "should show jasmine rake task" do
35
35
  output = `rake -T`
36
- output.should include("jasmine ")
37
- output.should include("jasmine:ci")
36
+ expect(output).to include("jasmine ")
37
+ expect(output).to include("jasmine:ci")
38
38
  end
39
39
 
40
40
  it "should successfully run rake jasmine:ci" do
41
41
  output = `rake jasmine:ci`
42
- output.should =~ (/[1-9]\d* specs, 0 failures/)
42
+ expect(output).to match (/[1-9]\d* specs, 0 failures/)
43
+ expect(output).to_not match /Randomized with seed/
43
44
  end
44
45
 
45
46
  it "should raise an error when jasmine.yml cannot be found" do
46
47
  config_path = 'some/thing/that/doesnt/exist'
47
48
  output = `rake jasmine:ci JASMINE_CONFIG_PATH=#{config_path}`
48
- $?.should_not be_success
49
- output.should =~ /Unable to load jasmine config from #{config_path}/
49
+ expect($?).to_not be_success
50
+ expect(output).to match /Unable to load jasmine config from #{config_path}/
50
51
  end
51
52
 
52
53
  it "rake jasmine:ci returns proper exit code when the runner raises" do
@@ -58,6 +59,66 @@ describe "POJS jasmine install" do
58
59
  FileUtils.cp(File.join(@root, 'spec', 'fixture', 'failing_runner.rb'), failing_runner)
59
60
 
60
61
  `rake jasmine:ci JASMINE_CONFIG_PATH=#{failing_yaml}`
61
- $?.should_not be_success
62
+ expect($?).to_not be_success
63
+ end
64
+
65
+ context 'with a spec with a console.log' do
66
+ before do
67
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'console_log_spec.js'), File.join('spec', 'javascripts'))
68
+ end
69
+
70
+ it 'hides console.log by default' do
71
+ output = `rake jasmine:ci`
72
+ expect(output).to_not include("I'm in the webpage!")
73
+ end
74
+
75
+ it 'can be told to show console.log' do
76
+ log_yaml = custom_jasmine_config('log') do |jasmine_config|
77
+ jasmine_config['show_console_log'] = true
78
+ end
79
+ output = `rake jasmine:ci JASMINE_CONFIG_PATH=#{log_yaml}`
80
+ expect(output).to include("I'm in the webpage!")
81
+ end
82
+ end
83
+
84
+ it 'should allow customizing the phantom page' do
85
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'viewport_spec.js'), File.join('spec', 'javascripts'))
86
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'phantomConfig.js'), File.join('spec', 'javascripts', 'support'))
87
+ viewport_yaml = custom_jasmine_config('viewport') do |jasmine_config|
88
+ jasmine_config['phantom_config_script'] = 'spec/javascripts/support/phantomConfig.js'
89
+ jasmine_config['show_console_log'] = true
90
+ end
91
+
92
+ output = `rake jasmine:ci JASMINE_CONFIG_PATH=#{viewport_yaml}`
93
+ expect(output).to match /[1-9]\d* specs, 0 failures/
94
+ end
95
+
96
+ it 'should throw a useful error when the phantom customization fails' do
97
+ bad_phantom_yaml = custom_jasmine_config('viewport') do |jasmine_config|
98
+ jasmine_config['phantom_config_script'] = 'spec/javascripts/support/doesNotExist.js'
99
+ jasmine_config['show_console_log'] = true
100
+ end
101
+
102
+ output = `rake jasmine:ci JASMINE_CONFIG_PATH=#{bad_phantom_yaml}`
103
+ expect($?).to_not be_success
104
+ expect(output).to match /Failed to configure phantom/
105
+ end
106
+
107
+ it 'should fail correctly with a failure in afterAll' do
108
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'afterall_spec.js'), File.join('spec', 'javascripts'))
109
+
110
+ output = `rake jasmine:ci`
111
+ expect($?).to_not be_success
112
+ expect(output).to match /afterAll go boom/
113
+ end
114
+
115
+ it 'should tell jasmine to randomize the execution order' do
116
+ randomized_yaml = custom_jasmine_config('random') do |jasmine_config|
117
+ jasmine_config['random'] = true
118
+ end
119
+
120
+ output = `rake jasmine:ci JASMINE_CONFIG_PATH=#{randomized_yaml}`
121
+ expect($?).to be_success
122
+ expect(output).to match /Randomized with seed/
62
123
  end
63
124
  end