jasmine 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/Rakefile +11 -2
  2. data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +2 -2
  3. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +2 -1
  4. data/jasmine.gemspec +1 -1
  5. data/lib/jasmine.rb +10 -2
  6. data/lib/jasmine/application.rb +6 -33
  7. data/lib/jasmine/asset_expander.rb +19 -0
  8. data/lib/jasmine/asset_pipeline_mapper.rb +11 -14
  9. data/lib/jasmine/asset_pipeline_utility.rb +19 -0
  10. data/lib/jasmine/base.rb +4 -0
  11. data/lib/jasmine/config.rb +74 -111
  12. data/lib/jasmine/configuration.rb +83 -0
  13. data/lib/jasmine/core_configuration.rb +28 -0
  14. data/lib/jasmine/javascripts/boot.js +28 -0
  15. data/lib/jasmine/path_expander.rb +18 -0
  16. data/lib/jasmine/path_mapper.rb +29 -0
  17. data/lib/jasmine/results_processor.rb +21 -20
  18. data/lib/jasmine/run.html.erb +0 -37
  19. data/lib/jasmine/run_specs.rb +12 -8
  20. data/lib/jasmine/server.rb +1 -1
  21. data/lib/jasmine/tasks/jasmine.rake +3 -4
  22. data/lib/jasmine/version.rb +1 -1
  23. data/lib/jasmine/yaml_config_parser.rb +54 -0
  24. data/spec/application_integration_spec.rb +15 -0
  25. data/spec/application_spec.rb +37 -92
  26. data/spec/asset_expander_spec.rb +42 -0
  27. data/spec/asset_pipeline_mapper_spec.rb +12 -11
  28. data/spec/base_spec.rb +14 -0
  29. data/spec/configuration_spec.rb +163 -0
  30. data/spec/jasmine_self_test_spec.rb +14 -7
  31. data/spec/page_spec.rb +2 -4
  32. data/spec/path_expander_spec.rb +96 -0
  33. data/spec/path_mapper_spec.rb +33 -0
  34. data/spec/server_spec.rb +2 -2
  35. data/spec/yaml_config_parser_spec.rb +182 -0
  36. metadata +34 -23
  37. data/lib/jasmine/runner_config.rb +0 -71
  38. data/lib/jasmine/sprockets_mapper.rb +0 -13
  39. data/lib/rack/jasmine/redirect.rb +0 -20
  40. data/spec/config_spec.rb +0 -309
  41. data/spec/fixture/jasmine.erb.yml +0 -4
  42. data/spec/fixture/spec/example_spec.js +0 -5
  43. data/spec/fixture/src/example.js +0 -3
  44. data/spec/jasmine_self_test_config.rb +0 -19
  45. data/spec/runner_config_spec.rb +0 -136
  46. data/spec/sprockets_mapper_spec.rb +0 -17
@@ -1,309 +0,0 @@
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
@@ -1,4 +0,0 @@
1
- src_files:
2
- <% 3.times do |i| %>
3
- - <%= "file#{i}.js" %>
4
- <% end %>
@@ -1,5 +0,0 @@
1
- describe("example_spec", function() {
2
- it("should be here for path loading tests", function() {
3
- expect(true).toBe(true);
4
- }
5
- })
@@ -1,3 +0,0 @@
1
- function Example() {
2
- this.is_here = "for path loading tests";
3
- }
@@ -1,19 +0,0 @@
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
@@ -1,136 +0,0 @@
1
- require 'spec_helper'
2
- require 'selenium-webdriver'
3
-
4
- describe Jasmine::RunnerConfig do
5
- describe "css_files" do
6
- it "should return the jasmine stylesheets and any user defined stylesheets" do
7
- jasmine_stylesheets = ['some/css/file']
8
- user_stylesheets = ['some/user/file']
9
- user_config = double("config", :jasmine_stylesheets => jasmine_stylesheets, :user_stylesheets => user_stylesheets)
10
- Jasmine::RunnerConfig.new(user_config).css_files.should == jasmine_stylesheets + user_stylesheets
11
- end
12
- end
13
-
14
- describe "jasmine_files" do
15
- it "should return the jasmine files from the config" do
16
- jasmine_files = ['some/file']
17
- user_config = double('config', :jasmine_javascripts => jasmine_files)
18
- Jasmine::RunnerConfig.new(user_config).jasmine_files.should == jasmine_files
19
- end
20
- end
21
-
22
- describe "js_files" do
23
- it "should return the user js files from the config" do
24
- js_files = ['some/file']
25
- user_config = double('config', :js_files => js_files)
26
- Jasmine::RunnerConfig.new(user_config).js_files.should == js_files
27
- end
28
- end
29
-
30
- describe "spec_files" do
31
- it "should return the user spec_files from the config" do
32
- spec_files = ['some/file']
33
- user_config = double('config', :spec_files => spec_files)
34
- Jasmine::RunnerConfig.new(user_config).spec_files.should == spec_files
35
- end
36
- end
37
-
38
- describe "spec_files_full_paths" do
39
- it "should return the user spec_files_full_paths from the config" do
40
- spec_files_full_paths = ['some/file_path']
41
- user_config = double('config', :spec_files_full_paths => spec_files_full_paths)
42
- Jasmine::RunnerConfig.new(user_config).spec_files_full_paths.should == spec_files_full_paths
43
- end
44
- end
45
-
46
- describe "spec_path" do
47
- it "should return the user spec_path from the config" do
48
- spec_path = ['some/path']
49
- user_config = double('config', :spec_path => spec_path)
50
- Jasmine::RunnerConfig.new(user_config).spec_path.should == spec_path
51
- end
52
- end
53
-
54
- describe "spec_dir" do
55
- it "should return the user spec_dir from the config" do
56
- spec_dir = ['some/dir']
57
- user_config = double('config', :spec_dir => spec_dir)
58
- Jasmine::RunnerConfig.new(user_config).spec_dir.should == spec_dir
59
- end
60
- end
61
-
62
- describe "src_dir" do
63
- it "should return the user src_dir from the config" do
64
- src_dir = ['some/dir']
65
- user_config = double('config', :src_dir => src_dir)
66
- Jasmine::RunnerConfig.new(user_config).src_dir.should == src_dir
67
- end
68
- end
69
-
70
- describe "project_root" do
71
- it "should return the user project_root from the config" do
72
- project_root = ['some/dir']
73
- user_config = double('config', :project_root => project_root)
74
- Jasmine::RunnerConfig.new(user_config).project_root.should == project_root
75
- end
76
- end
77
-
78
- describe "root_path" do
79
- it "should return the user root_path from the config" do
80
- root_path = ['some/path']
81
- user_config = double('config', :root_path => root_path)
82
- Jasmine::RunnerConfig.new(user_config).root_path.should == root_path
83
- end
84
- end
85
-
86
- describe "browser" do
87
- it "should default to firefox" do
88
- Jasmine::RunnerConfig.new.browser.should == 'firefox'
89
- end
90
-
91
- it "should use ENV['JASMINE_BROWSER'] if it exists" do
92
- ENV.stub(:[], "JASMINE_BROWSER").and_return("foo")
93
- Jasmine::RunnerConfig.new.browser.should == 'foo'
94
- end
95
- end
96
-
97
-
98
- describe "src_mapper" do
99
- it "should update the src_mapper in the user_config" do
100
- config = Jasmine::RunnerConfig.new(user_config = Jasmine::Config.new)
101
- mapper = double("mapper")
102
- config.src_mapper = mapper
103
- config.src_mapper.should == mapper
104
- user_config.src_mapper.should == mapper
105
- end
106
- end
107
-
108
- describe "jasmine_server_url" do
109
- it "should return the correct server url" do
110
- host = "the host"
111
- port = "484"
112
- user_config = double('config', :jasmine_host => host, :port => port)
113
- Jasmine::RunnerConfig.new(user_config).jasmine_server_url.should == "#{host}:#{port}/"
114
- end
115
- end
116
-
117
- describe "port" do
118
- it "should return the port from the config" do
119
- user_config = double('config', :port => 80)
120
- Jasmine::RunnerConfig.new(user_config).port.should == 80
121
- end
122
- end
123
- describe "result batch size" do
124
- subject { Jasmine::RunnerConfig.new.result_batch_size }
125
-
126
- context "when not specified" do
127
- it("should use default") { should == 50 }
128
- end
129
-
130
- context "when overridden" do
131
- before { ENV.stub(:[], "JASMINE_RESULT_BATCH_SIZE").and_return("500") }
132
- it { should be(500) }
133
- end
134
- end
135
- end
136
-