rally-jasmine 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.gitignore +13 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +58 -0
  4. data/Gemfile +8 -0
  5. data/HOW_TO_TEST.markdown +9 -0
  6. data/MIT.LICENSE +20 -0
  7. data/README.markdown +77 -0
  8. data/RELEASE.markdown +22 -0
  9. data/RELEASE_NOTES.markdown +6 -0
  10. data/Rakefile +53 -0
  11. data/bin/jasmine +6 -0
  12. data/generators/jasmine/jasmine_generator.rb +24 -0
  13. data/generators/jasmine/templates/INSTALL +9 -0
  14. data/generators/jasmine/templates/jasmine-example/SpecRunner.html +54 -0
  15. data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
  16. data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
  17. data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
  18. data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
  19. data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
  20. data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
  21. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
  22. data/lib/generators/jasmine/examples/USAGE +11 -0
  23. data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
  24. data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Player.js +22 -0
  25. data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Song.js +7 -0
  26. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
  27. data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
  28. data/lib/generators/jasmine/install/USAGE +11 -0
  29. data/lib/generators/jasmine/install/install_generator.rb +18 -0
  30. data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
  31. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +76 -0
  32. data/lib/jasmine/application.rb +43 -0
  33. data/lib/jasmine/asset_pipeline_mapper.rb +19 -0
  34. data/lib/jasmine/base.rb +50 -0
  35. data/lib/jasmine/command_line_tool.rb +70 -0
  36. data/lib/jasmine/config.rb +121 -0
  37. data/lib/jasmine/dependencies.rb +59 -0
  38. data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
  39. data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
  40. data/lib/jasmine/firebug/firebug-license.txt +30 -0
  41. data/lib/jasmine/firebug/firebug.rb +30 -0
  42. data/lib/jasmine/page.rb +11 -0
  43. data/lib/jasmine/railtie.rb +21 -0
  44. data/lib/jasmine/results.rb +19 -0
  45. data/lib/jasmine/results_processor.rb +37 -0
  46. data/lib/jasmine/rspec_formatter.rb +92 -0
  47. data/lib/jasmine/run.html.erb +55 -0
  48. data/lib/jasmine/run_specs.rb +32 -0
  49. data/lib/jasmine/runner_config.rb +71 -0
  50. data/lib/jasmine/runners/http.rb +71 -0
  51. data/lib/jasmine/selenium_driver.rb +52 -0
  52. data/lib/jasmine/server.rb +20 -0
  53. data/lib/jasmine/sprockets_mapper.rb +13 -0
  54. data/lib/jasmine/tasks/jasmine.rake +56 -0
  55. data/lib/jasmine/tasks/jasmine_rails3.rake +1 -0
  56. data/lib/jasmine/version.rb +3 -0
  57. data/lib/jasmine.rb +23 -0
  58. data/lib/rack/jasmine/cache_control.rb +20 -0
  59. data/lib/rack/jasmine/focused_suite.rb +17 -0
  60. data/lib/rack/jasmine/redirect.rb +20 -0
  61. data/lib/rack/jasmine/runner.rb +27 -0
  62. data/spec/application_spec.rb +99 -0
  63. data/spec/asset_pipeline_mapper_spec.rb +18 -0
  64. data/spec/config_spec.rb +309 -0
  65. data/spec/dependencies_spec.rb +327 -0
  66. data/spec/fixture/Rakefile +4 -0
  67. data/spec/fixture/jasmine.erb.yml +4 -0
  68. data/spec/fixture/spec/example_spec.js +5 -0
  69. data/spec/fixture/src/example.js +3 -0
  70. data/spec/jasmine_command_line_tool_rakeless_spec.rb +20 -0
  71. data/spec/jasmine_command_line_tool_spec.rb +29 -0
  72. data/spec/jasmine_pojs_spec.rb +47 -0
  73. data/spec/jasmine_rails2_spec.rb +89 -0
  74. data/spec/jasmine_rails3_spec.rb +69 -0
  75. data/spec/jasmine_self_test_config.rb +19 -0
  76. data/spec/jasmine_self_test_spec.rb +22 -0
  77. data/spec/page_spec.rb +25 -0
  78. data/spec/rack/jasmine/runner_spec.rb +25 -0
  79. data/spec/results_processor_spec.rb +3 -0
  80. data/spec/results_spec.rb +27 -0
  81. data/spec/rspec_formatter_spec.rb +88 -0
  82. data/spec/runner_config_spec.rb +136 -0
  83. data/spec/server_spec.rb +48 -0
  84. data/spec/spec_helper.rb +55 -0
  85. data/spec/sprockets_mapper_spec.rb +17 -0
  86. metadata +319 -0
@@ -0,0 +1,327 @@
1
+ require 'spec_helper'
2
+
3
+ #rspec 1 fails to stub respond_to
4
+ if Jasmine::Dependencies.rspec2?
5
+ describe Jasmine::Dependencies do
6
+ module Rails
7
+ end
8
+
9
+ context "with ruby_gems > 1.8" do
10
+ before do
11
+ Gem::Specification.should_receive(:respond_to?).with(:find_by_name).and_return(true)
12
+ end
13
+
14
+ describe ".rspec2?" do
15
+ subject { Jasmine::Dependencies.rspec2? }
16
+ context "when rspec 2 is present" do
17
+ before do
18
+ Gem::Specification.should_receive(:find_by_name).with("rspec", ">= 2.0").and_return(true)
19
+ end
20
+ it { should be_true }
21
+ end
22
+ context "when rspec 2 is not present" do
23
+ before do
24
+ Gem::Specification.should_receive(:find_by_name).with("rspec", ">= 2.0").and_raise(Gem::LoadError)
25
+ end
26
+ it { should be_false }
27
+ end
28
+ end
29
+
30
+ describe ".rails2?" do
31
+ subject { Jasmine::Dependencies.rails2? }
32
+ context "when rails 2 is present and running" do
33
+ before do
34
+ Gem::Specification.should_receive(:find_by_name).with("rails", "~> 2.3").and_return(true)
35
+ Rails.stub(:respond_to?).with(:version).and_return(true)
36
+ Rails.stub(:version).and_return(running_rails_version)
37
+ end
38
+ let(:running_rails_version) { "2.3.11" }
39
+ it { should be_true }
40
+ end
41
+ context "when rails 2 is present but not running" do
42
+ before do
43
+ Gem::Specification.should_receive(:find_by_name).with("rails", "~> 2.3").and_raise(Gem::LoadError)
44
+ end
45
+ it { should be_false }
46
+ end
47
+ context "when rails 2 is not present" do
48
+ before do
49
+ Gem::Specification.should_receive(:find_by_name).with("rails", "~> 2.3").and_raise(Gem::LoadError)
50
+ end
51
+ it { should be_false }
52
+ end
53
+ end
54
+
55
+ describe ".legacy_rails?" do
56
+ subject { Jasmine::Dependencies.legacy_rails? }
57
+ context "when rails < 2.3.11 is present and running" do
58
+ before do
59
+ Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_return(true)
60
+ Rails.stub(:respond_to?).with(:version).and_return(true)
61
+ Rails.stub(:version).and_return(running_rails_version)
62
+ end
63
+ let(:running_rails_version) { "2.3.8" }
64
+ it { should be_true }
65
+ end
66
+ context "when rails < 2.3.11 is present but not running" do
67
+ before do
68
+ Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_return(true)
69
+ end
70
+ it { should be_false }
71
+ end
72
+ context "when rails < 2.3.11 is not present" do
73
+ before do
74
+ Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_raise(Gem::LoadError)
75
+ end
76
+ it { should be_false }
77
+ end
78
+ end
79
+
80
+ describe ".rails3?" do
81
+ subject { Jasmine::Dependencies.rails3? }
82
+ context "when rails 3 is present and running" do
83
+ before do
84
+ Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
85
+ Rails.stub(:respond_to?).with(:version).and_return(true)
86
+ Rails.stub(:version).and_return(running_rails_version)
87
+ end
88
+ let(:running_rails_version) { "3.2" }
89
+ it { should be_true }
90
+ end
91
+ context "when rails 3 is present but not running" do
92
+ before do
93
+ Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
94
+ end
95
+ it { should be_false }
96
+ end
97
+ context "when rails 3 is not present" do
98
+ before do
99
+ Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_raise(Gem::LoadError)
100
+ end
101
+ it { should be_false }
102
+ end
103
+ end
104
+
105
+ describe ".rails_3_asset_pipeline?" do
106
+ subject { Jasmine::Dependencies.rails_3_asset_pipeline? }
107
+ let(:application) { double(:application) }
108
+ let(:running_rails_version) { "3.2" }
109
+ before do
110
+ Rails.stub(:respond_to?).with(:application).and_return(respond_to_application)
111
+ Rails.stub(:application).and_return(application)
112
+ Rails.stub(:respond_to?).with(:version).and_return(true)
113
+ Rails.stub(:version).and_return(running_rails_version)
114
+ end
115
+ context "when rails 3 is present and the application pipeline is in use" do
116
+ before do
117
+ Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
118
+ application.stub(:assets).and_return(rails_application_assets)
119
+ end
120
+ let(:rails3_present) { true }
121
+ let(:respond_to_application) { true }
122
+ let(:rails_application_assets) { true }
123
+ it { should be_true }
124
+ end
125
+ context "when rails 3 is present and the application pipeline is not in use" do
126
+ before do
127
+ Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
128
+ application.stub(:assets).and_return(rails_application_assets)
129
+ end
130
+ let(:rails3_present) { true }
131
+ let(:respond_to_application) { true }
132
+ let(:rails_application_assets) { false }
133
+ it { should be_false }
134
+ end
135
+ context "when rails 3 is present but not loaded" do
136
+ before do
137
+ Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
138
+ application.stub(:assets).and_return(rails_application_assets)
139
+ end
140
+ let(:rails3_present) { true }
141
+ let(:respond_to_application) { false }
142
+ let(:rails_application_assets) { false }
143
+ it { should be_false }
144
+ end
145
+ context "when rails 3 is present but doesn't respond to assets" do
146
+ before do
147
+ Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
148
+ end
149
+ let(:rails3_present) { true }
150
+ let(:respond_to_application) { true }
151
+ it { should be_false }
152
+ end
153
+ context "when rails 3 is not present" do
154
+ before do
155
+ Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_raise(Gem::LoadError)
156
+ end
157
+ let(:rails3_present) { false }
158
+ let(:respond_to_application) { false }
159
+ let(:rails_application_assets) { false }
160
+ it { should be_false }
161
+ end
162
+ end
163
+ end
164
+
165
+ context "with ruby_gems < 1.8" do
166
+ before do
167
+ Gem::Specification.should_receive(:respond_to?).with(:find_by_name).and_return(false)
168
+ end
169
+
170
+ describe ".rspec2?" do
171
+ subject { Jasmine::Dependencies.rspec2? }
172
+ before do
173
+ Gem.should_receive(:available?).with("rspec", ">= 2.0").and_return(rspec2_present)
174
+ end
175
+ context "when rspec 2 is present" do
176
+ let(:rspec2_present) { true }
177
+ it { should be_true }
178
+ end
179
+ context "when rspec 2 is not present" do
180
+ let(:rspec2_present) { false }
181
+ it { should be_false }
182
+ end
183
+ end
184
+
185
+ describe ".rails2?" do
186
+ subject { Jasmine::Dependencies.rails2? }
187
+ before do
188
+ Gem.should_receive(:available?).with("rails", "~> 2.3").and_return(rails2_present)
189
+ end
190
+ context "when rails 2 is present and running" do
191
+ before do
192
+ Rails.stub(:respond_to?).with(:version).and_return(true)
193
+ Rails.stub(:version).and_return(running_rails_version)
194
+ end
195
+
196
+ let(:running_rails_version) { "2.3" }
197
+ let(:rails2_present) { true }
198
+ it { should be_true }
199
+ end
200
+ context "when rails 2 is present but not running" do
201
+ before do
202
+ Rails.stub(:respond_to?).with(:version).and_return(true)
203
+ Rails.stub(:version).and_return(running_rails_version)
204
+ end
205
+
206
+ let(:running_rails_version) { "3.2" }
207
+ let(:rails2_present) { true }
208
+ it { should be_false }
209
+ end
210
+ context "when rails 2 is not present" do
211
+ let(:rails2_present) { false }
212
+ it { should be_false }
213
+ end
214
+ end
215
+
216
+ describe ".legacy_rails?" do
217
+ subject { Jasmine::Dependencies.legacy_rails? }
218
+ before do
219
+ Gem.should_receive(:available?).with("rails", "< 2.3.11").and_return(legacy_rails_present)
220
+ end
221
+ context "when rails < 2.3.11 is present and running" do
222
+ before do
223
+ Rails.stub(:respond_to?).with(:version).and_return(true)
224
+ Rails.stub(:version).and_return(running_rails_version)
225
+ end
226
+ let(:running_rails_version) { "2.3.8" }
227
+ let(:legacy_rails_present) { true }
228
+ it { should be_true }
229
+ end
230
+
231
+ context "when rails < 2.3.11 is present but not running" do
232
+ let(:legacy_rails_present) { true }
233
+ it { should be_false }
234
+ end
235
+
236
+ context "when rails < 2.3.11 is not present" do
237
+ let(:legacy_rails_present) { false }
238
+ it { should be_false }
239
+ end
240
+ end
241
+
242
+ describe ".rails3?" do
243
+ subject { Jasmine::Dependencies.rails3? }
244
+ before do
245
+ Gem.should_receive(:available?).with("rails", ">= 3.0").and_return(rails3_present)
246
+ end
247
+ context "when rails 3 is present" do
248
+ before do
249
+ Rails.stub(:respond_to?).with(:version).and_return(true)
250
+ Rails.stub(:version).and_return(running_rails_version)
251
+ end
252
+ let(:running_rails_version) { "3.2" }
253
+ let(:rails3_present) { true }
254
+ it { should be_true }
255
+ end
256
+ context "when rails 3 is not present" do
257
+ let(:rails3_present) { false }
258
+ it { should be_false }
259
+ end
260
+ end
261
+
262
+ describe ".rails_3_asset_pipeline?" do
263
+ subject { Jasmine::Dependencies.rails_3_asset_pipeline? }
264
+ let(:application) { double(:application, :assets => rails_application_assets)}
265
+ before do
266
+ Gem.should_receive(:available?).with("rails", ">= 3.0").and_return(rails3_present)
267
+ Rails.stub(:respond_to?).with(:application).and_return(respond_to_application)
268
+ Rails.stub(:respond_to?).with(:version).and_return(true)
269
+ Rails.stub(:application).and_return(application)
270
+ end
271
+
272
+ context "when rails 3 is present, running, and the application pipeline is in use" do
273
+ before do
274
+ Rails.stub(:respond_to?).with(:version).and_return(true)
275
+ Rails.stub(:version).and_return(running_rails_version)
276
+ end
277
+ let(:rails3_present) { true }
278
+ let(:running_rails_version) { "3.2" }
279
+ let(:respond_to_application) { true }
280
+ let(:rails_application_assets) { true }
281
+ it { should be_true }
282
+ end
283
+ context "when rails 3 is present, running, and the application pipeline is not in use" do
284
+ before do
285
+ Rails.stub(:respond_to?).with(:version).and_return(true)
286
+ Rails.stub(:version).and_return(running_rails_version)
287
+ end
288
+ let(:rails3_present) { true }
289
+ let(:running_rails_version) { "3.2" }
290
+ let(:respond_to_application) { true }
291
+ let(:rails_application_assets) { false }
292
+ it { should be_false }
293
+ end
294
+ context "when rails 3 is present but not loaded" do
295
+ before do
296
+ Rails.stub(:respond_to?).with(:version).and_return(false)
297
+ end
298
+ let(:rails3_present) { true }
299
+ let(:respond_to_application) { false }
300
+ let(:rails_application_assets) { false }
301
+ it { should be_false }
302
+ end
303
+ context "when rails 3 is not present" do
304
+ before do
305
+ Rails.stub(:respond_to?).with(:version).and_return(false)
306
+ end
307
+ let(:rails3_present) { false }
308
+ let(:respond_to_application) { false }
309
+ let(:rails_application_assets) { false }
310
+ it { should be_false }
311
+ end
312
+ end
313
+ end
314
+
315
+ describe "legacy_rack?" do
316
+ it "should return false if Rack::Server exists" do
317
+ Rack.stub(:constants).and_return([:Server])
318
+ Jasmine::Dependencies.legacy_rack?.should be_false
319
+ end
320
+ it "should return true if Rack::Server does not exist" do
321
+ Rack.stub(:constants).and_return([])
322
+ Jasmine::Dependencies.legacy_rack?.should be_true
323
+ end
324
+ end
325
+ end
326
+
327
+ end
@@ -0,0 +1,4 @@
1
+ desc "A flunk task that does not want to be trampled"
2
+ task :jasmine_flunk do
3
+ nil
4
+ end
@@ -0,0 +1,4 @@
1
+ src_files:
2
+ <% 3.times do |i| %>
3
+ - <%= "file#{i}.js" %>
4
+ <% end %>
@@ -0,0 +1,5 @@
1
+ describe("example_spec", function() {
2
+ it("should be here for path loading tests", function() {
3
+ expect(true).toBe(true);
4
+ }
5
+ })
@@ -0,0 +1,3 @@
1
+ function Example() {
2
+ this.is_here = "for path loading tests";
3
+ }
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Jasmine command line tool" do
4
+ context "when rake has not been required yet" do
5
+ before :each do
6
+ temp_dir_before
7
+ Dir::chdir @tmp
8
+ end
9
+
10
+ after :each do
11
+ temp_dir_after
12
+ end
13
+
14
+ it "should append to an existing Rakefile" do
15
+ FileUtils.cp("#{@old_dir}/spec/fixture/Rakefile", @tmp)
16
+ output = capture_stdout { Jasmine::CommandLineTool.new.process ["init"] }
17
+ output.should =~ /Jasmine has been installed with example specs./
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Jasmine command line tool" do
4
+ before :each do
5
+ temp_dir_before
6
+ Dir::chdir @tmp
7
+ end
8
+
9
+ after :each do
10
+ temp_dir_after
11
+ end
12
+
13
+ it "should create files on init" do
14
+ output = capture_stdout { Jasmine::CommandLineTool.new.process ["init"] }
15
+ output.should =~ /Jasmine has been installed with example specs./
16
+
17
+ my_jasmine_lib = File.expand_path(File.join(@root, "lib"))
18
+ bootstrap = "$:.unshift('#{my_jasmine_lib}')"
19
+
20
+ ENV['JASMINE_GEM_PATH'] = "#{@root}/lib"
21
+ ci_output = `rake -E "#{bootstrap}" --trace jasmine:ci`
22
+ ci_output.should =~ (/[1-9][0-9]* examples, 0 failures/)
23
+ end
24
+
25
+ it "should include license info" do
26
+ output = capture_stdout { Jasmine::CommandLineTool.new.process ["license"] }
27
+ output.should =~ /Copyright/
28
+ end
29
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe "POJS jasmine install" do
4
+
5
+ before :each do
6
+ temp_dir_before
7
+ Dir::chdir @tmp
8
+ @install_directory = 'pojs-example'
9
+ Dir::mkdir @install_directory
10
+ Dir::chdir @install_directory
11
+ end
12
+
13
+ after :each do
14
+ temp_dir_after
15
+ end
16
+
17
+ context "when the Jasmine generators are available" do
18
+ before :each do
19
+ `jasmine init`
20
+ end
21
+
22
+ it "should find the Jasmine configuration files" do
23
+ File.exists?("spec/javascripts/support/jasmine.yml").should == true
24
+ end
25
+
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
29
+
30
+ File.exists?("spec/javascripts/PlayerSpec.js").should == true
31
+ File.exists?("spec/javascripts/helpers/SpecHelper.js").should == true
32
+
33
+ File.exists?("spec/javascripts/support/jasmine.yml").should == true
34
+ end
35
+
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
41
+
42
+ it "should successfully run rake jasmine:ci" do
43
+ output = `rake jasmine:ci`
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ if Jasmine::Dependencies.rails2? && !Jasmine::Dependencies.legacy_rails?
4
+
5
+ describe "A Rails 2 app" do
6
+
7
+ before :each do
8
+ temp_dir_before
9
+ Dir::chdir @tmp
10
+ create_rails 'rails-example'
11
+ Dir::chdir 'rails-example'
12
+ end
13
+
14
+ after :each do
15
+ temp_dir_after
16
+ end
17
+
18
+ context "before Jasmine has been installed" do
19
+
20
+ it "should not show the jasmine:install generator" do
21
+ output = `./script/generate --help`
22
+ output.should_not include('jasmine:install')
23
+ end
24
+
25
+ it "should not show jasmine:install help" do
26
+ output = `rails g`
27
+ output.should_not include('This will create')
28
+ end
29
+
30
+ it "should not show jasmine rake task" do
31
+ output = `rake -T`
32
+ output.should_not include("jasmine ")
33
+ end
34
+
35
+ it "should not show jasmine:ci rake task" do
36
+ output = `rake -T`
37
+ output.should_not include("jasmine:ci")
38
+ end
39
+
40
+ end
41
+
42
+ context "when the Jasmine generators are available" do
43
+ before :each do
44
+ `mkdir -p lib/generators && ln -s #{@root}/generators/jasmine lib/generators/jasmine`
45
+ end
46
+
47
+ it "should show the Jasmine generator" do
48
+ output = `./script/generate --help`
49
+ output.should include("Lib: jasmine")
50
+ end
51
+
52
+ it "should show jasmine:install help" do
53
+ output = `./script/generate jasmine --help`
54
+
55
+ output.should include("Usage: ./script/generate jasmine")
56
+ end
57
+
58
+ context "and been run" do
59
+ before :each do
60
+ `./script/generate jasmine`
61
+ end
62
+
63
+ it "should find the Jasmine configuration files" do
64
+ File.exists?("spec/javascripts/support/jasmine.yml").should == true
65
+ end
66
+
67
+ it "should find the Jasmine example files" do
68
+ File.exists?("public/javascripts/Player.js").should == true
69
+ File.exists?("public/javascripts/Song.js").should == true
70
+
71
+ File.exists?("spec/javascripts/PlayerSpec.js").should == true
72
+ File.exists?("spec/javascripts/helpers/SpecHelper.js").should == true
73
+
74
+ File.exists?("spec/javascripts/support/jasmine.yml").should == true
75
+ end
76
+
77
+ it "should show jasmine rake task" do
78
+ output = `rake -T`
79
+ output.should include("jasmine ")
80
+ end
81
+
82
+ it "should show jasmine:ci rake task" do
83
+ output = `rake -T`
84
+ output.should include("jasmine:ci")
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ if Jasmine::Dependencies.rails3?
4
+
5
+ describe "A Rails 3 app" do
6
+
7
+ before :each do
8
+ temp_dir_before
9
+ Dir::chdir @tmp
10
+
11
+ create_rails 'rails-example'
12
+ Dir::chdir 'rails-example'
13
+ open('Gemfile', 'a') { |f| f.puts "gem \"jasmine\", \"#{Jasmine::VERSION}\"" }
14
+ end
15
+
16
+ after :each do
17
+ temp_dir_after
18
+ end
19
+
20
+ context "when Jasmine has been required" do
21
+ it "should show the Jasmine generators" do
22
+ output = `rails g`
23
+ output.should include("jasmine:install")
24
+ output.should include("jasmine:examples")
25
+ end
26
+
27
+ it "should show jasmine:install help" do
28
+ output = `rails g jasmine:install --help`
29
+ output.should include("rails generate jasmine:install")
30
+ end
31
+
32
+ it "should have the jasmine rake task" do
33
+ output = `rake -T`
34
+ output.should include("jasmine ")
35
+ end
36
+
37
+ it "should have the jasmine:ci rake task" do
38
+ output = `rake -T`
39
+ output.should include("jasmine:ci")
40
+ end
41
+
42
+ context "and then installed" do
43
+ before :each do
44
+ @output = `rails g jasmine:install`
45
+ end
46
+
47
+ it "should have the Jasmine config files" do
48
+ @output.should include("create")
49
+
50
+ File.exists?("spec/javascripts/helpers/.gitkeep").should == true
51
+ File.exists?("spec/javascripts/support/jasmine.yml").should == true
52
+ end
53
+ end
54
+
55
+ context "and the jasmine examples have been installed" do
56
+ it "should find the Jasmine example files" do
57
+ output = `rails g jasmine:examples`
58
+ output.should include("create")
59
+
60
+ File.exists?("app/assets/javascripts/jasmine_examples/Player.js").should == true
61
+ File.exists?("app/assets/javascripts/jasmine_examples/Song.js").should == true
62
+
63
+ File.exists?("spec/javascripts/jasmine_examples/PlayerSpec.js").should == true
64
+ File.exists?("spec/javascripts/helpers/SpecHelper.js").should == true
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,19 @@
1
+ require 'jasmine'
2
+
3
+ class JasmineSelfTestConfig < Jasmine::Config
4
+ def project_root
5
+ File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
+ end
7
+
8
+ def src_dir
9
+ File.join(project_root, 'src')
10
+ end
11
+
12
+ def spec_dir
13
+ Jasmine::Core.path
14
+ end
15
+
16
+ def spec_files
17
+ Jasmine::Core.html_spec_files + Jasmine::Core.core_spec_files
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'jasmine_self_test_config'
3
+
4
+ jasmine_runner_config = Jasmine::RunnerConfig.new(JasmineSelfTestConfig.new)
5
+ server = Jasmine::Server.new(jasmine_runner_config.port, Jasmine::Application.app(jasmine_runner_config))
6
+ client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser, jasmine_runner_config.jasmine_server_url)
7
+
8
+ t = Thread.new do
9
+ begin
10
+ server.start
11
+ rescue ChildProcess::TimeoutError
12
+ end
13
+ # # ignore bad exits
14
+ end
15
+ t.abort_on_exception = true
16
+ Jasmine::wait_for_listener(jasmine_runner_config.port, "jasmine server")
17
+ puts "jasmine server started."
18
+
19
+ results_processor = Jasmine::ResultsProcessor.new(jasmine_runner_config)
20
+ results = Jasmine::Runners::HTTP.new(client, results_processor, jasmine_runner_config.result_batch_size).run
21
+ formatter = Jasmine::RspecFormatter.new
22
+ formatter.format_results(results)
data/spec/page_spec.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'nokogiri'
3
+ require 'ostruct'
4
+
5
+ describe Jasmine::Page do
6
+ describe "#render" do
7
+ subject { Nokogiri::HTML(page.render) }
8
+ let(:fake_config) do
9
+ OpenStruct.new(:js_files => ["file1.js", "file2.js"],
10
+ :css_files => ["file1.css", "file2.css"],
11
+ :jasmine_files => ["jasmine_file1.js", "jasmine_file2.js"])
12
+ end
13
+ let(:context) { fake_config }
14
+ let(:page) { Jasmine::Page.new(context) }
15
+ it "should render javascript files in the correct order" do
16
+ js_files = subject.css("script")
17
+ js_files.map { |file| file["src"] }.compact.should == ["jasmine_file1.js", "jasmine_file2.js", "file1.js", "file2.js"]
18
+ end
19
+
20
+ it "should render css files in the correct order" do
21
+ css_files = subject.css("link[type='text/css']")
22
+ css_files.map { |file| file["href"] }.compact.should == ["file1.css", "file2.css"]
23
+ end
24
+ end
25
+ end