jasmine 2.0.0.rc2 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -11
  3. data/Gemfile +4 -2
  4. data/HOW_TO_TEST.markdown +1 -1
  5. data/README.markdown +23 -14
  6. data/RELEASE.markdown +6 -13
  7. data/Rakefile +21 -23
  8. data/jasmine.gemspec +9 -16
  9. data/{generators/jasmine/templates/jasmine-example/spec → lib/generators/jasmine/examples/templates/spec/javascripts/helpers/jasmine_examples}/SpecHelper.js +0 -0
  10. data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +1 -1
  11. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +15 -2
  12. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb +2 -2
  13. data/lib/jasmine.rb +5 -7
  14. data/lib/jasmine/asset_bundle.rb +9 -10
  15. data/lib/jasmine/command_line_install.txt +13 -0
  16. data/lib/jasmine/command_line_tool.rb +100 -58
  17. data/lib/jasmine/config.rb +25 -13
  18. data/lib/jasmine/configuration.rb +21 -16
  19. data/lib/jasmine/dependencies.rb +1 -1
  20. data/lib/jasmine/formatters/console.rb +21 -13
  21. data/lib/jasmine/formatters/exit_code.rb +21 -0
  22. data/lib/jasmine/formatters/multi.rb +25 -0
  23. data/lib/jasmine/result.rb +46 -0
  24. data/lib/jasmine/run.html.erb +3 -1
  25. data/lib/jasmine/runners/phantom_jasmine_run.js +54 -0
  26. data/lib/jasmine/runners/phantom_js.rb +29 -0
  27. data/lib/jasmine/tasks/jasmine.rake +42 -21
  28. data/lib/jasmine/version.rb +1 -1
  29. data/spec/configuration_spec.rb +34 -72
  30. data/spec/fixture/coffee_spec.coffee +3 -0
  31. data/spec/fixture/failing_runner.rb +9 -0
  32. data/spec/fixture/failing_test.js +5 -0
  33. data/spec/fixture/large_test_suite_spec.js +20 -0
  34. data/spec/jasmine_command_line_tool_spec.rb +94 -52
  35. data/spec/jasmine_pojs_spec.rb +37 -21
  36. data/spec/jasmine_rails_spec.rb +89 -49
  37. data/spec/lib/jasmine/formatters/console_spec.rb +50 -35
  38. data/spec/lib/jasmine/formatters/multi_spec.rb +17 -0
  39. data/spec/performance/phantom_js_runner_performance_spec.rb +23 -0
  40. data/spec/result_spec.rb +34 -0
  41. data/spec/spec_helper.rb +40 -16
  42. metadata +34 -84
  43. data/generators/jasmine/jasmine_generator.rb +0 -25
  44. data/generators/jasmine/templates/INSTALL +0 -9
  45. data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +0 -58
  46. data/generators/jasmine/templates/jasmine-example/src/Player.js +0 -22
  47. data/generators/jasmine/templates/jasmine-example/src/Song.js +0 -7
  48. data/generators/jasmine/templates/lib/tasks/jasmine.rake +0 -8
  49. data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +0 -81
  50. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +0 -88
  51. data/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb +0 -12
  52. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +0 -15
  53. data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
  54. data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
  55. data/lib/jasmine/firebug/firebug-license.txt +0 -30
  56. data/lib/jasmine/firebug/firebug.rb +0 -30
  57. data/lib/jasmine/formatters/base.rb +0 -9
  58. data/lib/jasmine/formatters/junit_xml.rb +0 -47
  59. data/lib/jasmine/reporters/api_reporter.rb +0 -38
  60. data/lib/jasmine/results.rb +0 -38
  61. data/lib/jasmine/results_processor.rb +0 -38
  62. data/lib/jasmine/run_specs.rb +0 -33
  63. data/lib/jasmine/runners/http.rb +0 -33
  64. data/lib/jasmine/selenium_driver.rb +0 -45
  65. data/spec/asset_expander_spec.rb +0 -13
  66. data/spec/asset_pipeline_mapper_spec.rb +0 -19
  67. data/spec/jasmine_command_line_tool_rakeless_spec.rb +0 -20
  68. data/spec/lib/jasmine/formatters/base_spec.rb +0 -9
  69. data/spec/lib/jasmine/formatters/junit_xml_spec.rb +0 -55
  70. data/spec/lib/jasmine/reporters/api_reporter_spec.rb +0 -53
  71. data/spec/lib/jasmine/runners/http_spec.rb +0 -21
  72. data/spec/results_processor_spec.rb +0 -3
  73. data/spec/results_spec.rb +0 -69
  74. data/spec/support/fake_selenium_driver.rb +0 -35
@@ -1,3 +1,3 @@
1
1
  module Jasmine
2
- VERSION = "2.0.0.rc2"
2
+ VERSION = "2.0.0.rc3"
3
3
  end
@@ -87,7 +87,6 @@ describe Jasmine::Configuration do
87
87
  map['some/path'].should be
88
88
  map['some/path'].call.should == result
89
89
  end
90
-
91
90
  end
92
91
 
93
92
  describe 'rack apps' do
@@ -106,46 +105,6 @@ describe Jasmine::Configuration do
106
105
  end
107
106
  end
108
107
 
109
- describe 'port' do
110
- it 'returns new port and caches return value' do
111
- config = Jasmine::Configuration.new()
112
- Jasmine.stub(:find_unused_port).and_return('1234')
113
- config.port.should == '1234'
114
- Jasmine.stub(:find_unused_port).and_return('4321')
115
- config.port.should == '1234'
116
- end
117
- it 'returns port if configured' do
118
- config = Jasmine::Configuration.new()
119
- config.port = '5678'
120
- Jasmine.stub(:find_unused_port).and_return('1234')
121
- config.port.should == '5678'
122
- end
123
- end
124
-
125
- describe 'browser' do
126
- it 'should default to firefox' do
127
- Jasmine::Configuration.new().browser.should == 'firefox'
128
- end
129
-
130
- it 'returns browser if set' do
131
- config = Jasmine::Configuration.new()
132
- config.browser = 'foo'
133
- config.browser.should == 'foo'
134
- end
135
- end
136
-
137
- describe 'result_batch_size' do
138
- it 'should default to 50' do
139
- Jasmine::Configuration.new().result_batch_size.should == 50
140
- end
141
-
142
- it 'returns result_batch_size if set' do
143
- config = Jasmine::Configuration.new()
144
- config.result_batch_size = 25
145
- config.result_batch_size.should == 25
146
- end
147
- end
148
-
149
108
  describe 'host' do
150
109
  it 'should default to localhost' do
151
110
  Jasmine::Configuration.new().host.should == 'http://localhost'
@@ -158,55 +117,44 @@ describe Jasmine::Configuration do
158
117
  end
159
118
  end
160
119
 
161
- describe 'selenium config' do
162
- it 'returns server if set' do
163
- config = Jasmine::Configuration.new()
164
- config.selenium_server = 'fish'
165
- config.selenium_server.should == 'fish'
166
-
167
- config.selenium_server_port = 'turnip'
168
- config.selenium_server_port.should == 'turnip'
169
- end
170
- end
171
-
172
- describe 'junit xml' do
120
+ describe 'spec format' do
173
121
  it 'returns value if set' do
174
122
  config = Jasmine::Configuration.new()
175
-
176
- config.junit_xml_path = 'turnip'
177
- config.junit_xml_path.should == 'turnip'
123
+ config.spec_format = 'fish'
124
+ config.spec_format.should == 'fish'
178
125
  end
126
+ end
179
127
 
180
- it 'returns defaults' do
128
+ describe 'jasmine ports' do
129
+ it 'returns new CI port and caches return value' do
181
130
  config = Jasmine::Configuration.new()
182
-
183
- config.junit_xml_path.should == Dir.getwd
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'
184
135
  end
185
- end
186
136
 
187
- describe 'spec format' do
188
- it 'returns value if set' do
137
+ it 'returns ci port if configured' do
189
138
  config = Jasmine::Configuration.new()
190
- config.spec_format = 'fish'
191
- config.spec_format.should == 'fish'
139
+ config.ci_port = '5678'
140
+ Jasmine.stub(:find_unused_port).and_return('1234')
141
+ config.port(:ci).should == '5678'
192
142
  end
193
- end
194
143
 
195
- describe 'jasmine ports' do
196
- it 'returns value if set' do
144
+ it 'returns configured server port' do
197
145
  config = Jasmine::Configuration.new()
198
- config.jasmine_port = 'fish'
199
- config.jasmine_port.should == 'fish'
146
+ config.server_port = 'fish'
147
+ config.port(:server).should == 'fish'
200
148
  end
201
149
 
202
- it 'returns defaults' do
150
+ it 'returns default server port' do
203
151
  config = Jasmine::Configuration.new()
204
152
 
205
- config.jasmine_port.should == 8888
153
+ config.port(:server).should == 8888
206
154
  end
207
155
  end
208
156
 
209
- describe 'jasmine ports' do
157
+ describe 'jasmine formatters' do
210
158
  it 'returns value if set' do
211
159
  config = Jasmine::Configuration.new()
212
160
  config.formatters = ['pants']
@@ -219,5 +167,19 @@ describe Jasmine::Configuration do
219
167
  config.formatters.should == [Jasmine::Formatters::Console]
220
168
  end
221
169
  end
170
+
171
+ describe 'custom runner' do
172
+ it 'stores and returns what is passed' do
173
+ config = Jasmine::Configuration.new
174
+ foo = double(:foo)
175
+ config.runner = foo
176
+ config.runner.should == foo
177
+ end
178
+
179
+ it 'does nothing by default' do
180
+ config = Jasmine::Configuration.new
181
+ config.runner.call('hi')
182
+ end
183
+ end
222
184
  end
223
185
 
@@ -0,0 +1,3 @@
1
+ describe "coffee specs", ->
2
+ it "should work", ->
3
+ expect(true).toBe true
@@ -0,0 +1,9 @@
1
+ class FailingRunner
2
+ def run
3
+ raise
4
+ end
5
+ end
6
+
7
+ Jasmine.configure do |config|
8
+ config.runner = lambda { |_, _| FailingRunner.new }
9
+ end
@@ -0,0 +1,5 @@
1
+ describe("failing", function() {
2
+ it('should fail', function() {
3
+ expect(true).toBe(false);
4
+ });
5
+ });
@@ -0,0 +1,20 @@
1
+ function nestedBlock(nestingDepth, index) {
2
+ if (nestingDepth == 0) {
3
+ return;
4
+ } else {
5
+ describe('Suite ' + index + ' at depth ' + nestingDepth, function() {
6
+ it('should be a failing test', function() {
7
+ expect(true).toBe(false);
8
+ });
9
+ it('should be a passing test', function() {
10
+ expect(true).toBe(true);
11
+ });
12
+ nestedBlock(nestingDepth - 1, index);
13
+ });
14
+ }
15
+ }
16
+
17
+ for (i=0; i<2000; i++) {
18
+ nestedBlock(10, i);
19
+ }
20
+
@@ -11,71 +11,113 @@ describe 'Jasmine command line tool' do
11
11
  end
12
12
 
13
13
  describe '.init' do
14
+ describe 'without a Gemfile' do
14
15
  it 'should create files on init' do
15
16
  output = capture_stdout { Jasmine::CommandLineTool.new.process ['init'] }
16
- output.should =~ /Jasmine has been installed with example specs./
17
+ output.should =~ /Jasmine has been installed\./
17
18
 
18
- my_jasmine_lib = File.expand_path(File.join(@root, 'lib'))
19
- bootstrap = "$:.unshift('#{my_jasmine_lib}')"
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
22
+ ci_output = `rake --trace jasmine:ci`
23
+ ci_output.should =~ (/0 specs, 0 failures/)
24
+ end
25
+
26
+ it 'should create a new Rakefile if it does not exist' do
27
+ 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')
30
+ end
20
31
 
21
- ENV['JASMINE_GEM_PATH'] = "#{@root}/lib"
22
- ci_output = `rake -E "#{bootstrap}" --trace jasmine:ci`
23
- ci_output.should =~ (/[1-9][0-9]* specs, 0 failures/)
32
+ it "should append to an existing Rakefile" do
33
+ FileUtils.cp("#{@old_dir}/spec/fixture/Rakefile", @tmp)
34
+ 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')
24
37
  end
38
+ end
25
39
 
26
- describe 'with a Gemfile containing Rails' do
27
- before :each do
28
- open(File.join(@tmp, "Gemfile"), 'w') do |f|
29
- f.puts "rails"
30
- end
31
- end
32
-
33
- it 'should warn the user' do
34
- output = capture_stdout {
35
- expect {
36
- Jasmine::CommandLineTool.new.process ['init']
37
- }.to raise_error SystemExit
38
- }
39
- output.should =~ /attempting to run jasmine init in a Rails project/
40
-
41
- Dir.entries(@tmp).sort.should == [".", "..", "Gemfile"]
42
- end
43
-
44
- it 'should allow the user to override the warning' do
45
- output = capture_stdout {
46
- expect {
47
- Jasmine::CommandLineTool.new.process ['init', '--force']
48
- }.not_to raise_error
49
- }
50
- output.should =~ /Jasmine has been installed with example specs./
51
-
52
- Dir.entries(@tmp).sort.should == [".", "..", "Gemfile", "Rakefile", "public", "spec"]
53
- end
40
+ describe 'with a Gemfile containing Rails' do
41
+ before :each do
42
+ open(File.join(@tmp, "Gemfile"), 'w') do |f|
43
+ f.puts "rails"
44
+ end
54
45
  end
55
-
56
- describe 'with a Gemfile not containing Rails' do
57
- before :each do
58
- open(File.join(@tmp, "Gemfile"), 'w') do |f|
59
- f.puts "sqlite3"
60
- end
61
- end
62
-
63
- it 'should perform normally' do
64
- output = capture_stdout {
65
- expect {
66
- Jasmine::CommandLineTool.new.process ['init']
67
- }.not_to raise_error
68
- }
69
- output.should =~ /Jasmine has been installed with example specs./
70
-
71
- Dir.entries(@tmp).sort.should == [".", "..", "Gemfile", "Rakefile", "public", "spec"]
72
- end
46
+
47
+ it 'should warn the user' do
48
+ output = capture_stdout {
49
+ expect {
50
+ Jasmine::CommandLineTool.new.process ['init']
51
+ }.to raise_error SystemExit
52
+ }
53
+ output.should =~ /attempting to run jasmine init in a Rails project/
54
+
55
+ Dir.entries(@tmp).sort.should == [".", "..", "Gemfile"]
73
56
  end
57
+
58
+ it 'should allow the user to override the warning' do
59
+ output = capture_stdout {
60
+ expect {
61
+ Jasmine::CommandLineTool.new.process ['init', '--force']
62
+ }.not_to raise_error
63
+ }
64
+ output.should =~ /Jasmine has been installed\./
65
+
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
68
+ end
69
+ end
70
+
71
+ describe 'with a Gemfile not containing Rails' do
72
+ before :each do
73
+ open(File.join(@tmp, "Gemfile"), 'w') do |f|
74
+ f.puts "sqlite3"
75
+ end
76
+ end
77
+
78
+ it 'should perform normally' do
79
+ output = capture_stdout {
80
+ expect {
81
+ Jasmine::CommandLineTool.new.process ['init']
82
+ }.not_to raise_error
83
+ }
84
+ output.should =~ /Jasmine has been installed\./
85
+
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
88
+ end
89
+ end
74
90
  end
75
91
 
92
+ it 'should install the examples' do
93
+ 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
99
+
100
+ capture_stdout { Jasmine::CommandLineTool.new.process ['init'] }
101
+ ci_output = `rake --trace jasmine:ci`
102
+ ci_output.should =~ (/[1-9]\d* specs, 0 failures/)
103
+ end
76
104
 
77
105
  it 'should include license info' do
78
106
  output = capture_stdout { Jasmine::CommandLineTool.new.process ['license'] }
79
107
  output.should =~ /Copyright/
80
108
  end
109
+
110
+ it 'should copy boot.js' do
111
+ output = capture_stdout { Jasmine::CommandLineTool.new.process ['copy_boot_js'] }
112
+ output.should =~ /Jasmine has copied an example boot.js to spec\/javascripts\/support/
113
+
114
+ File.exists?(File.join(@tmp, 'spec/javascripts/support/boot.js')).should == true
115
+ end
116
+
117
+ it 'should not overwrite an existing boot.js' do
118
+ capture_stdout { Jasmine::CommandLineTool.new.process ['copy_boot_js'] }
119
+ output = capture_stdout { Jasmine::CommandLineTool.new.process ['copy_boot_js'] }
120
+
121
+ output.should =~ /already exists/
122
+ end
81
123
  end
@@ -8,40 +8,56 @@ describe "POJS jasmine install" do
8
8
  @install_directory = 'pojs-example'
9
9
  Dir::mkdir @install_directory
10
10
  Dir::chdir @install_directory
11
+
12
+ `jasmine init`
13
+ `jasmine examples`
11
14
  end
12
15
 
13
16
  after :each do
14
17
  temp_dir_after
15
18
  end
16
19
 
17
- context "when the Jasmine generators are available" do
18
- before :each do
19
- `jasmine init`
20
- end
20
+ it "should find the Jasmine configuration files" do
21
+ File.exists?("spec/javascripts/support/jasmine.yml").should == true
22
+ end
21
23
 
22
- it "should find the Jasmine configuration files" do
23
- File.exists?("spec/javascripts/support/jasmine.yml").should == true
24
- end
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
27
 
26
- it "should find the Jasmine example files" do
27
- File.exists?("public/javascripts/Player.js").should == true
28
- File.exists?("public/javascripts/Song.js").should == true
28
+ File.exists?("spec/javascripts/jasmine_examples/PlayerSpec.js").should == true
29
+ File.exists?("spec/javascripts/helpers/jasmine_examples/SpecHelper.js").should == true
29
30
 
30
- File.exists?("spec/javascripts/PlayerSpec.js").should == true
31
- File.exists?("spec/javascripts/helpers/SpecHelper.js").should == true
31
+ File.exists?("spec/javascripts/support/jasmine.yml").should == true
32
+ end
32
33
 
33
- File.exists?("spec/javascripts/support/jasmine.yml").should == true
34
- end
34
+ it "should show jasmine rake task" do
35
+ output = `rake -T`
36
+ output.should include("jasmine ")
37
+ output.should include("jasmine:ci")
38
+ end
35
39
 
36
- it "should show jasmine rake task" do
37
- output = `rake -T`
38
- output.should include("jasmine ")
39
- output.should include("jasmine:ci")
40
- end
40
+ it "should successfully run rake jasmine:ci" do
41
+ output = `rake jasmine:ci`
42
+ output.should =~ (/[1-9]\d* specs, 0 failures/)
43
+ end
41
44
 
42
- it "should successfully run rake jasmine:ci" do
43
- output = `rake jasmine:ci`
45
+ it "should raise an error when jasmine.yml cannot be found" do
46
+ config_path = 'some/thing/that/doesnt/exist'
47
+ 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}/
50
+ end
51
+
52
+ it "rake jasmine:ci returns proper exit code when the runner raises" do
53
+ failing_runner = File.join('spec', 'javascripts', 'support', 'failing_runner.rb')
54
+ failing_yaml = custom_jasmine_config('raises_exception') do |config|
55
+ config['spec_helper'] = failing_runner
44
56
  end
45
57
 
58
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'failing_runner.rb'), failing_runner)
59
+
60
+ `rake jasmine:ci JASMINE_CONFIG_PATH=#{failing_yaml}`
61
+ $?.should_not be_success
46
62
  end
47
63
  end
@@ -1,7 +1,21 @@
1
1
  require 'spec_helper'
2
+ require 'net/http'
3
+ require 'yaml'
2
4
 
3
5
  if Jasmine::Dependencies.rails_available?
4
6
  describe 'A Rails app' do
7
+ def bundle_install
8
+ tries_remaining = 3
9
+ while tries_remaining > 0
10
+ puts `NOKOGIRI_USE_SYSTEM_LIBRARIES=true bundle install --path vendor;`
11
+ if $?.success?
12
+ tries_remaining = 0
13
+ else
14
+ tries_remaining -= 1
15
+ puts "\n\nBundle failed, trying #{tries_remaining} more times\n\n"
16
+ end
17
+ end
18
+ end
5
19
 
6
20
  before :all do
7
21
  temp_dir_before
@@ -12,14 +26,22 @@ if Jasmine::Dependencies.rails_available?
12
26
 
13
27
  base = File.absolute_path(File.join(__FILE__, '../..'))
14
28
 
15
- open('Gemfile', 'a') { |f|
16
- f.puts "gem 'jasmine', :path => '#{base}'"
17
- f.puts "gem 'jasmine-core', :github => 'pivotal/jasmine'"
29
+ open('Gemfile', 'a') { |f|
30
+ f.puts "gem 'jasmine', :path => '#{base}'"
31
+ f.puts "gem 'jasmine-core', :github => 'pivotal/jasmine'"
18
32
  f.flush
19
33
  }
20
34
 
21
35
  Bundler.with_clean_env do
22
- puts `NOKOGIRI_USE_SYSTEM_LIBRARIES=true bundle install --path vendor;`
36
+ bundle_install
37
+ `bundle exec rails g jasmine:install`
38
+ File.exists?('spec/javascripts/helpers/.gitkeep').should == true
39
+ File.exists?('spec/javascripts/support/jasmine.yml').should == true
40
+ `bundle exec rails g jasmine:examples`
41
+ File.exists?('app/assets/javascripts/jasmine_examples/Player.js').should == true
42
+ File.exists?('app/assets/javascripts/jasmine_examples/Song.js').should == true
43
+ File.exists?('spec/javascripts/jasmine_examples/PlayerSpec.js').should == true
44
+ File.exists?('spec/javascripts/helpers/jasmine_examples/SpecHelper.js').should == true
23
45
  end
24
46
  end
25
47
 
@@ -27,65 +49,83 @@ if Jasmine::Dependencies.rails_available?
27
49
  temp_dir_after
28
50
  end
29
51
 
30
- context 'when Jasmine has been required' do
31
- it 'should show the Jasmine generators' do
32
- Bundler.with_clean_env do
33
- output = `bundle exec rails g`
34
- output.should include('jasmine:install')
35
- output.should include('jasmine:examples')
36
- end
52
+ it 'should have the jasmine & jasmine:ci rake task' do
53
+ #See https://github.com/jimweirich/rake/issues/220 and https://github.com/jruby/activerecord-jdbc-adapter/pull/467
54
+ #There's a workaround, but requires setting env vars & jruby opts (non-trivial when inside of a jruby process), so skip for now.
55
+ pending "activerecord-jdbc + rake -T doesn't work correctly under Jruby" if ENV['RAILS_VERSION'] == 'rails3' && RUBY_PLATFORM == 'java'
56
+ Bundler.with_clean_env do
57
+ output = `bundle exec rake -T`
58
+ output.should include('jasmine ')
59
+ output.should include('jasmine:ci')
37
60
  end
61
+ end
38
62
 
39
- it 'should show jasmine:install help' do
40
- Bundler.with_clean_env do
41
- output = `bundle exec rails g jasmine:install --help`
42
- output.should include('rails generate jasmine:install')
43
- end
63
+ it "rake jasmine:ci runs and returns expected results" do
64
+ Bundler.with_clean_env do
65
+ output = `bundle exec rake jasmine:ci`
66
+ output.should include('5 specs, 0 failures')
44
67
  end
68
+ end
45
69
 
46
- it 'should have the jasmine rake task' do
47
- Bundler.with_clean_env do
48
- output = `bundle exec rake -T`
49
- output.should include('jasmine ')
70
+ it "rake jasmine:ci returns proper exit code when specs fail" do
71
+ Bundler.with_clean_env do
72
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'failing_test.js'), File.join('spec', 'javascripts'))
73
+ failing_yaml = custom_jasmine_config('failing') do |jasmine_config|
74
+ jasmine_config['spec_files'] << 'failing_test.js'
50
75
  end
76
+ output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{failing_yaml}`
77
+ $?.should_not be_success
78
+ output.should include('6 specs, 1 failure')
51
79
  end
80
+ end
52
81
 
53
- it 'should have the jasmine:ci rake task' do
54
- Bundler.with_clean_env do
55
- output = `bundle exec rake -T`
56
- output.should include('jasmine:ci')
57
- end
82
+ it "runs specs written in coffeescript" do
83
+ coffee_yaml = custom_jasmine_config('coffee') do |jasmine_config|
84
+ jasmine_config['spec_files'] << 'coffee_spec.coffee'
58
85
  end
86
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'coffee_spec.coffee'), File.join('spec', 'javascripts'))
59
87
 
60
- context 'and then installed' do
61
- before :each do
62
- Bundler.with_clean_env do
63
- @output = `bundle exec rails g jasmine:install`
64
- end
65
- end
66
-
67
- it 'should have the Jasmine config files' do
68
- @output.should include('create')
69
-
70
- File.exists?('spec/javascripts/helpers/.gitkeep').should == true
71
- File.exists?('spec/javascripts/support/jasmine.yml').should == true
72
- end
88
+ Bundler.with_clean_env do
89
+ output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{coffee_yaml}`
90
+ output.should include('6 specs, 0 failures')
73
91
  end
92
+ end
74
93
 
75
- context 'and the jasmine examples have been installed' do
76
- it 'should find the Jasmine example files' do
77
- Bundler.with_clean_env do
78
- output = `bundle exec rails g jasmine:examples`
79
- output.should include('create')
94
+ it "rake jasmine runs and serves the expected webpage when using asset pipeline" do
95
+ open('app/assets/stylesheets/foo.css', 'w') { |f|
96
+ f.puts "/* hi dere */"
97
+ f.flush
98
+ }
80
99
 
81
- File.exists?('app/assets/javascripts/jasmine_examples/Player.js').should == true
82
- File.exists?('app/assets/javascripts/jasmine_examples/Song.js').should == true
100
+ css_yaml = custom_jasmine_config('css') do |jasmine_config|
101
+ jasmine_config['src_files'] = ['assets/application.js']
102
+ jasmine_config['stylesheets'] = ['assets/application.css']
103
+ end
83
104
 
84
- File.exists?('spec/javascripts/jasmine_examples/PlayerSpec.js').should == true
85
- File.exists?('spec/javascripts/helpers/SpecHelper.js').should == true
105
+ Bundler.with_clean_env do
106
+ begin
107
+ pid = IO.popen("bundle exec rake jasmine JASMINE_CONFIG_PATH=#{css_yaml}").pid
108
+ Jasmine::wait_for_listener(8888, 'jasmine server', 60)
109
+
110
+ # if the process we started is not still running, it's very likely this test
111
+ # will fail because another server is already running on port 8888
112
+ # (kill -0 will check if you can send *ANY* signal to this process)
113
+ # (( it does not actually kill the process, that happens below))
114
+ `kill -0 #{pid}`
115
+ unless $?.success?
116
+ puts "someone else is running a server on port 8888"
117
+ $?.should be_success
118
+ end
86
119
 
87
- output = `bundle exec rake jasmine:ci`
88
- output.should include('5 specs, 0 failures')
120
+ output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
121
+ output.should match(%r{script src.*/assets/jasmine_examples/Player.js})
122
+ output.should match(%r{script src.*/assets/jasmine_examples/Song.js})
123
+ output.should match(%r{<link rel=.stylesheet.*?href=./assets/foo.css\?.*?>})
124
+ ensure
125
+ Process.kill(:SIGINT, pid)
126
+ begin
127
+ Process.waitpid pid
128
+ rescue Errno::ECHILD
89
129
  end
90
130
  end
91
131
  end