rally-jasmine 1.2.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 (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,99 @@
1
+ require 'spec_helper'
2
+ require 'rack/test'
3
+
4
+ describe "Jasmine::Application" do
5
+ include Rack::Test::Methods
6
+
7
+ def app
8
+ @root = File.join(File.dirname(__FILE__))
9
+ runner_config = double("config",
10
+ :project_root => @root,
11
+ :spec_dir => File.join(@root, "fixture", "spec"),
12
+ :spec_path => "/__spec__",
13
+ :root_path => "/__root__",
14
+ :css_files => [],
15
+ :jasmine_files => [],
16
+ :js_files => ["path/file1.js", "path/file2.js"],
17
+ :src_dir => File.join(@root, "fixture", "src"),
18
+ :src_files => ["file1.js"],
19
+ :spec_files => ["example_spec.js"])
20
+ Jasmine::Application.app(runner_config)
21
+ end
22
+
23
+ it "includes no-cache headers for specs" do
24
+ get "/__spec__/example_spec.js"
25
+ last_response.headers.should have_key("Cache-Control")
26
+ last_response.headers["Cache-Control"].should == "max-age=0, private, must-revalidate"
27
+ end
28
+
29
+ it "should serve static files from spec dir under __spec__" do
30
+ get "/__spec__/example_spec.js"
31
+ last_response.status.should == 200
32
+ last_response.content_type.should == "application/javascript"
33
+ last_response.body.should == File.read(File.join(@root, "fixture/spec/example_spec.js"))
34
+ end
35
+
36
+ it "should serve static files from root dir under __root__" do
37
+ get "/__root__/fixture/src/example.js"
38
+ last_response.status.should == 200
39
+ last_response.content_type.should == "application/javascript"
40
+ last_response.body.should == File.read(File.join(@root, "fixture/src/example.js"))
41
+ end
42
+
43
+ it "should serve static files from src dir under /" do
44
+ get "/example.js"
45
+ last_response.status.should == 200
46
+ last_response.content_type.should == "application/javascript"
47
+ last_response.body.should == File.read(File.join(@root, "fixture/src/example.js"))
48
+ end
49
+
50
+ it "should serve Jasmine static files under /__JASMINE_ROOT__/" do
51
+ get "/__JASMINE_ROOT__/jasmine.css"
52
+ last_response.status.should == 200
53
+ last_response.content_type.should == "text/css"
54
+ last_response.body.should == File.read(File.join(Jasmine::Core.path, "jasmine.css"))
55
+ end
56
+
57
+ it "should serve focused suites when prefixing spec files with /__suite__/" do
58
+ pending "Temporarily removing this feature (maybe permanent)"
59
+ Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
60
+ get "/__suite__/file2.js"
61
+ last_response.status.should == 200
62
+ last_response.content_type.should == "text/html"
63
+ last_response.body.should include("\"/__spec__/file2.js")
64
+ end
65
+
66
+ it "should redirect /run.html to /" do
67
+ get "/run.html"
68
+ last_response.status.should == 302
69
+ last_response.location.should == "/"
70
+ end
71
+
72
+ it "should 404 non-existent files" do
73
+ get "/some-non-existent-file"
74
+ last_response.should be_not_found
75
+ end
76
+
77
+ describe "/ page" do
78
+ it "should load each js file in order" do
79
+ get "/"
80
+ last_response.status.should == 200
81
+ last_response.body.should include("path/file1.js")
82
+ last_response.body.should include("path/file2.js")
83
+ end
84
+
85
+ it "should return an empty 200 for HEAD requests to /" do
86
+ head "/"
87
+ last_response.status.should == 200
88
+ last_response.headers['Content-Type'].should == 'text/html'
89
+ last_response.body.should == ''
90
+ end
91
+
92
+ it "should tell the browser not to cache any assets" do
93
+ head "/"
94
+ ['Pragma'].each do |key|
95
+ last_response.headers[key].should == 'no-cache'
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::AssetPipelineMapper do
4
+ describe "mapping files" do
5
+ it "should retrieve asset paths from the asset pipeline for passed files" do
6
+ #TODO: this expects all src files to be asset pipeline files
7
+ src_files = ["assets/application.js", "assets/other_manifest.js"]
8
+ asset_context = double("asset context")
9
+ asset_context.stub_chain(:asset_paths, :asset_for).with("application", "js").and_return(['asset1.js', 'asset2.js'])
10
+ asset_context.stub_chain(:asset_paths, :asset_for).with("other_manifest", "js").and_return(['asset1.js', 'asset3.js'])
11
+ asset_context.stub(:asset_path) do |asset|
12
+ "/some_location/#{asset}"
13
+ end
14
+ mapper = Jasmine::AssetPipelineMapper.new(asset_context)
15
+ mapper.files(src_files).should == ['some_location/asset1.js?body=true', 'some_location/asset2.js?body=true', 'some_location/asset3.js?body=true']
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,309 @@
1
+ require 'spec_helper'
2
+ require 'selenium-webdriver'
3
+
4
+ describe Jasmine::Config do
5
+ describe "configuration" do
6
+ before :each do
7
+ Jasmine::Dependencies.stub(:rails_3_asset_pipeline?) { false }
8
+
9
+ temp_dir_before
10
+
11
+ Dir::chdir @tmp
12
+ dir_name = "test_js_project"
13
+ `mkdir -p #{dir_name}`
14
+ Dir::chdir dir_name
15
+ `#{@root}/bin/jasmine init .`
16
+
17
+ @project_dir = Dir.pwd
18
+
19
+ @template_dir = File.expand_path(File.join(@root, "generators/jasmine/templates"))
20
+ @config = Jasmine::Config.new
21
+ end
22
+
23
+ after(:each) do
24
+ temp_dir_after
25
+ end
26
+
27
+ describe "defaults" do
28
+ it "src_dir uses root when src dir is blank" do
29
+ @config.stub!(:project_root).and_return('some_project_root')
30
+ @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
31
+ YAML.stub!(:load).and_return({'src_dir' => nil})
32
+ @config.src_dir.should == 'some_project_root'
33
+ end
34
+
35
+ it "should use correct default yaml config" do
36
+ @config.stub!(:project_root).and_return('some_project_root')
37
+ @config.simple_config_file.should == (File.join('some_project_root', 'spec/javascripts/support/jasmine.yml'))
38
+ end
39
+ end
40
+
41
+ describe "simple_config" do
42
+ before(:each) do
43
+ @config.stub!(:src_dir).and_return(File.join(@project_dir, "."))
44
+ @config.stub!(:spec_dir).and_return(File.join(@project_dir, "spec/javascripts"))
45
+ end
46
+
47
+ describe "using default jasmine.yml" do
48
+ before(:each) do
49
+ @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
50
+ end
51
+
52
+ it "should find the source files" do
53
+ @config.src_files.should =~ ['public/javascripts/Player.js', 'public/javascripts/Song.js']
54
+ end
55
+
56
+ it "should find the stylesheet files" do
57
+ @config.stylesheets.should == []
58
+ end
59
+
60
+ it "should find the spec files" do
61
+ @config.spec_files.should == ['PlayerSpec.js']
62
+ end
63
+
64
+ it "should find any helpers" do
65
+ @config.helpers.should == ['helpers/SpecHelper.js']
66
+ end
67
+
68
+ it "should build an array of all the JavaScript files to include, source files then spec files" do
69
+ @config.js_files.should == [
70
+ '/public/javascripts/Player.js',
71
+ '/public/javascripts/Song.js',
72
+ '/__spec__/helpers/SpecHelper.js',
73
+ '/__spec__/PlayerSpec.js'
74
+ ]
75
+ end
76
+
77
+ it "should allow the js_files to be filtered" do
78
+ @config.js_files("PlayerSpec.js").should == [
79
+ '/public/javascripts/Player.js',
80
+ '/public/javascripts/Song.js',
81
+ '/__spec__/helpers/SpecHelper.js',
82
+ '/__spec__/PlayerSpec.js'
83
+ ]
84
+ end
85
+
86
+ it "should report the full paths of the spec files" do
87
+ @config.spec_files_full_paths.should == [File.join(@project_dir, 'spec/javascripts/PlayerSpec.js')]
88
+ end
89
+ end
90
+
91
+ it "should parse ERB" do
92
+ @config.stub!(:simple_config_file).and_return(File.expand_path(File.join(@root, 'spec', 'fixture','jasmine.erb.yml')))
93
+ Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
94
+ @config.src_files.should == ['file0.js', 'file1.js', 'file2.js',]
95
+ end
96
+
97
+ describe "if jasmine.yml not found" do
98
+ before(:each) do
99
+ File.stub!(:exist?).and_return(false)
100
+ end
101
+
102
+ it "should default to loading no source files" do
103
+ @config.src_files.should be_empty
104
+ end
105
+
106
+ it "should default to loading no stylesheet files" do
107
+ @config.stylesheets.should be_empty
108
+ end
109
+
110
+ end
111
+
112
+ describe "if jasmine.yml is empty" do
113
+ before(:each) do
114
+ @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
115
+ YAML.stub!(:load).and_return(false)
116
+ end
117
+
118
+ it "should default to loading no source files" do
119
+ @config.src_files.should be_empty
120
+ end
121
+
122
+ it "should default to loading no stylesheet files" do
123
+ @config.stylesheets.should be_empty
124
+ end
125
+ end
126
+
127
+ describe "should use the first appearance of duplicate filenames" do
128
+ before(:each) do
129
+ Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
130
+ fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "file2.ext", "file1.ext"] }
131
+ @config.stub!(:simple_config).and_return(fake_config)
132
+ end
133
+
134
+ it "src_files" do
135
+ @config.src_files.should == ['file1.ext', 'file2.ext']
136
+ end
137
+
138
+ it "stylesheets" do
139
+ @config.stylesheets.should == ['file1.ext', 'file2.ext']
140
+ end
141
+
142
+ it "spec_files" do
143
+ @config.spec_files.should == ['file1.ext', 'file2.ext']
144
+ end
145
+
146
+ it "helpers" do
147
+ @config.spec_files.should == ['file1.ext', 'file2.ext']
148
+ end
149
+
150
+ it "js_files" do
151
+ @config.js_files.should == ["/file1.ext",
152
+ "/file2.ext",
153
+ "/__spec__/file1.ext",
154
+ "/__spec__/file2.ext",
155
+ "/__spec__/file1.ext",
156
+ "/__spec__/file2.ext"]
157
+ end
158
+
159
+ it "spec_files_full_paths" do
160
+ @config.spec_files_full_paths.should == [
161
+ File.expand_path("spec/javascripts/file1.ext", @project_dir),
162
+ File.expand_path("spec/javascripts/file2.ext", @project_dir)
163
+ ]
164
+ end
165
+ end
166
+
167
+ describe "should permit explicity-declared filenames to pass through regardless of their existence" do
168
+ before(:each) do
169
+ Dir.stub!(:glob).and_return { |glob_string| [] }
170
+ fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "!file2.ext", "**/*file3.ext"] }
171
+ @config.stub!(:simple_config).and_return(fake_config)
172
+ end
173
+
174
+ it "should contain explicitly files" do
175
+ @config.src_files.should == ["file1.ext"]
176
+ end
177
+ end
178
+
179
+ describe "should allow .gitignore style negation (!pattern)" do
180
+ before(:each) do
181
+ Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
182
+ fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "!file1.ext", "file2.ext"] }
183
+ @config.stub!(:simple_config).and_return(fake_config)
184
+ end
185
+
186
+ it "should not contain negated files" do
187
+ @config.src_files.should == ["file2.ext"]
188
+ end
189
+ end
190
+
191
+ it "simple_config stylesheets" do
192
+ @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
193
+
194
+ YAML.stub!(:load).and_return({'stylesheets' => ['foo.css', 'bar.css']})
195
+ Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
196
+
197
+ @config.stylesheets.should == ['foo.css', 'bar.css']
198
+ end
199
+
200
+ it "using rails jasmine.yml" do
201
+ ['public/javascripts/prototype.js',
202
+ 'public/javascripts/effects.js',
203
+ 'public/javascripts/controls.js',
204
+ 'public/javascripts/dragdrop.js',
205
+ 'public/javascripts/application.js'].each { |f| `touch #{f}` }
206
+
207
+ @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine-rails.yml'))
208
+
209
+ @config.spec_files.should == ['PlayerSpec.js']
210
+ @config.helpers.should == ['helpers/SpecHelper.js']
211
+ @config.src_files.should == ['public/javascripts/prototype.js',
212
+ 'public/javascripts/effects.js',
213
+ 'public/javascripts/controls.js',
214
+ 'public/javascripts/dragdrop.js',
215
+ 'public/javascripts/application.js',
216
+ 'public/javascripts/Player.js',
217
+ 'public/javascripts/Song.js']
218
+ @config.js_files.should == [
219
+ '/public/javascripts/prototype.js',
220
+ '/public/javascripts/effects.js',
221
+ '/public/javascripts/controls.js',
222
+ '/public/javascripts/dragdrop.js',
223
+ '/public/javascripts/application.js',
224
+ '/public/javascripts/Player.js',
225
+ '/public/javascripts/Song.js',
226
+ '/__spec__/helpers/SpecHelper.js',
227
+ '/__spec__/PlayerSpec.js',
228
+ ]
229
+ @config.js_files("PlayerSpec.js").should == [
230
+ '/public/javascripts/prototype.js',
231
+ '/public/javascripts/effects.js',
232
+ '/public/javascripts/controls.js',
233
+ '/public/javascripts/dragdrop.js',
234
+ '/public/javascripts/application.js',
235
+ '/public/javascripts/Player.js',
236
+ '/public/javascripts/Song.js',
237
+ '/__spec__/helpers/SpecHelper.js',
238
+ '/__spec__/PlayerSpec.js'
239
+ ]
240
+ end
241
+ end
242
+ end
243
+
244
+
245
+ describe "jasmine_stylesheets" do
246
+ it "should return the relative web server path to the core Jasmine css stylesheets" do
247
+ #TODO: wrap Jasmine::Core with a class that knows about the core path and the relative mapping.
248
+ Jasmine::Core.stub(:css_files).and_return(["my_css_file1.css", "my_css_file2.css"])
249
+ Jasmine::Config.new.jasmine_stylesheets.should == ["/__JASMINE_ROOT__/my_css_file1.css", "/__JASMINE_ROOT__/my_css_file2.css"]
250
+ end
251
+ end
252
+
253
+ describe "jasmine_javascripts" do
254
+ it "should return the relative web server path to the core Jasmine css javascripts" do
255
+ Jasmine::Core.stub(:js_files).and_return(["my_js_file1.js", "my_js_file2.js"])
256
+ Jasmine::Config.new.jasmine_javascripts.should == ["/__JASMINE_ROOT__/my_js_file1.js", "/__JASMINE_ROOT__/my_js_file2.js"]
257
+ end
258
+ end
259
+
260
+ describe "when the asset pipeline (or any other sprockets environment) is active" do
261
+ let(:src_files) { ["assets/some.js", "assets/files.js"] }
262
+ let(:mapped_files) { ["some.js", "files.js"] }
263
+ let(:mapper) { double("mapper") }
264
+
265
+ let(:config) do
266
+ Jasmine::Config.new.tap do |config|
267
+ #TODO: simple_config should be a passed in hash
268
+ config.stub(:simple_config) { { 'src_files' => src_files} }
269
+ config.src_mapper = mapper
270
+ end
271
+ end
272
+
273
+ it "should use the mapper to return src_files" do
274
+ mapper.should_receive(:files).with(src_files).and_return(mapped_files)
275
+ config.src_files.should == mapped_files
276
+ end
277
+ end
278
+
279
+ describe "jasmine_host" do
280
+ it "should default to localhost" do
281
+ Jasmine::Config.new.jasmine_host.should == 'http://localhost'
282
+ end
283
+
284
+ it "should use ENV['JASMINE_HOST'] if it exists" do
285
+ ENV.stub(:[], "JASMINE_HOST").and_return("foo")
286
+ Jasmine::Config.new.jasmine_host.should == 'foo'
287
+ end
288
+ end
289
+
290
+ describe "port" do
291
+ it "should find an unused port" do
292
+ Jasmine.should_receive(:find_unused_port).and_return('1234')
293
+ Jasmine::Config.new.port.should == '1234'
294
+ end
295
+
296
+ it "should use ENV['JASMINE_PORT'] if it exists" do
297
+ ENV.stub(:[], "JASMINE_PORT").and_return("foo")
298
+ Jasmine::Config.new.port.should == 'foo'
299
+ end
300
+
301
+ it "should cache port" do
302
+ config = Jasmine::Config.new
303
+ Jasmine.stub(:find_unused_port).and_return('1234')
304
+ config.port.should == '1234'
305
+ Jasmine.stub(:find_unused_port).and_return('4321')
306
+ config.port.should == '1234'
307
+ end
308
+ end
309
+ end