jasmine 2.0.0.rc2 → 2.0.0.rc3
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 +4 -4
- data/.travis.yml +9 -11
- data/Gemfile +4 -2
- data/HOW_TO_TEST.markdown +1 -1
- data/README.markdown +23 -14
- data/RELEASE.markdown +6 -13
- data/Rakefile +21 -23
- data/jasmine.gemspec +9 -16
- data/{generators/jasmine/templates/jasmine-example/spec → lib/generators/jasmine/examples/templates/spec/javascripts/helpers/jasmine_examples}/SpecHelper.js +0 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +1 -1
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +15 -2
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb +2 -2
- data/lib/jasmine.rb +5 -7
- data/lib/jasmine/asset_bundle.rb +9 -10
- data/lib/jasmine/command_line_install.txt +13 -0
- data/lib/jasmine/command_line_tool.rb +100 -58
- data/lib/jasmine/config.rb +25 -13
- data/lib/jasmine/configuration.rb +21 -16
- data/lib/jasmine/dependencies.rb +1 -1
- data/lib/jasmine/formatters/console.rb +21 -13
- data/lib/jasmine/formatters/exit_code.rb +21 -0
- data/lib/jasmine/formatters/multi.rb +25 -0
- data/lib/jasmine/result.rb +46 -0
- data/lib/jasmine/run.html.erb +3 -1
- data/lib/jasmine/runners/phantom_jasmine_run.js +54 -0
- data/lib/jasmine/runners/phantom_js.rb +29 -0
- data/lib/jasmine/tasks/jasmine.rake +42 -21
- data/lib/jasmine/version.rb +1 -1
- data/spec/configuration_spec.rb +34 -72
- data/spec/fixture/coffee_spec.coffee +3 -0
- data/spec/fixture/failing_runner.rb +9 -0
- data/spec/fixture/failing_test.js +5 -0
- data/spec/fixture/large_test_suite_spec.js +20 -0
- data/spec/jasmine_command_line_tool_spec.rb +94 -52
- data/spec/jasmine_pojs_spec.rb +37 -21
- data/spec/jasmine_rails_spec.rb +89 -49
- data/spec/lib/jasmine/formatters/console_spec.rb +50 -35
- data/spec/lib/jasmine/formatters/multi_spec.rb +17 -0
- data/spec/performance/phantom_js_runner_performance_spec.rb +23 -0
- data/spec/result_spec.rb +34 -0
- data/spec/spec_helper.rb +40 -16
- metadata +34 -84
- data/generators/jasmine/jasmine_generator.rb +0 -25
- data/generators/jasmine/templates/INSTALL +0 -9
- data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +0 -58
- data/generators/jasmine/templates/jasmine-example/src/Player.js +0 -22
- data/generators/jasmine/templates/jasmine-example/src/Song.js +0 -7
- data/generators/jasmine/templates/lib/tasks/jasmine.rake +0 -8
- data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +0 -81
- data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +0 -88
- data/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb +0 -12
- data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +0 -15
- data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
- data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
- data/lib/jasmine/firebug/firebug-license.txt +0 -30
- data/lib/jasmine/firebug/firebug.rb +0 -30
- data/lib/jasmine/formatters/base.rb +0 -9
- data/lib/jasmine/formatters/junit_xml.rb +0 -47
- data/lib/jasmine/reporters/api_reporter.rb +0 -38
- data/lib/jasmine/results.rb +0 -38
- data/lib/jasmine/results_processor.rb +0 -38
- data/lib/jasmine/run_specs.rb +0 -33
- data/lib/jasmine/runners/http.rb +0 -33
- data/lib/jasmine/selenium_driver.rb +0 -45
- data/spec/asset_expander_spec.rb +0 -13
- data/spec/asset_pipeline_mapper_spec.rb +0 -19
- data/spec/jasmine_command_line_tool_rakeless_spec.rb +0 -20
- data/spec/lib/jasmine/formatters/base_spec.rb +0 -9
- data/spec/lib/jasmine/formatters/junit_xml_spec.rb +0 -55
- data/spec/lib/jasmine/reporters/api_reporter_spec.rb +0 -53
- data/spec/lib/jasmine/runners/http_spec.rb +0 -21
- data/spec/results_processor_spec.rb +0 -3
- data/spec/results_spec.rb +0 -69
- data/spec/support/fake_selenium_driver.rb +0 -35
data/lib/jasmine/version.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
@@ -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 '
|
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.
|
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
|
-
|
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.
|
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
|
-
|
188
|
-
it 'returns value if set' do
|
137
|
+
it 'returns ci port if configured' do
|
189
138
|
config = Jasmine::Configuration.new()
|
190
|
-
config.
|
191
|
-
|
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
|
-
|
196
|
-
it 'returns value if set' do
|
144
|
+
it 'returns configured server port' do
|
197
145
|
config = Jasmine::Configuration.new()
|
198
|
-
config.
|
199
|
-
config.
|
146
|
+
config.server_port = 'fish'
|
147
|
+
config.port(:server).should == 'fish'
|
200
148
|
end
|
201
149
|
|
202
|
-
it 'returns
|
150
|
+
it 'returns default server port' do
|
203
151
|
config = Jasmine::Configuration.new()
|
204
152
|
|
205
|
-
config.
|
153
|
+
config.port(:server).should == 8888
|
206
154
|
end
|
207
155
|
end
|
208
156
|
|
209
|
-
describe 'jasmine
|
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,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
|
17
|
+
output.should =~ /Jasmine has been installed\./
|
17
18
|
|
18
|
-
|
19
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
data/spec/jasmine_pojs_spec.rb
CHANGED
@@ -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
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
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
27
|
|
26
|
-
|
27
|
-
|
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
|
-
|
31
|
-
|
31
|
+
File.exists?("spec/javascripts/support/jasmine.yml").should == true
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
43
|
-
|
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
|
data/spec/jasmine_rails_spec.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
82
|
-
|
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
|
-
|
85
|
-
|
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
|
-
|
88
|
-
|
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
|