jasmine 1.3.2 → 2.0.0.rc2

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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +3 -37
  3. data/Gemfile +11 -2
  4. data/HOW_TO_TEST.markdown +1 -1
  5. data/README.markdown +10 -10
  6. data/Rakefile +18 -29
  7. data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +2 -2
  8. data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +14 -8
  9. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +3 -3
  10. data/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb +1 -0
  11. data/jasmine.gemspec +11 -41
  12. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +15 -9
  13. data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +1 -1
  14. data/lib/jasmine.rb +10 -7
  15. data/lib/jasmine/asset_bundle.rb +69 -0
  16. data/lib/jasmine/asset_expander.rb +7 -7
  17. data/lib/jasmine/command_line_tool.rb +18 -0
  18. data/lib/jasmine/config.rb +23 -15
  19. data/lib/jasmine/configuration.rb +14 -8
  20. data/lib/jasmine/core_configuration.rb +7 -4
  21. data/lib/jasmine/dependencies.rb +14 -18
  22. data/lib/jasmine/formatters/base.rb +9 -0
  23. data/lib/jasmine/formatters/console.rb +45 -0
  24. data/lib/jasmine/formatters/junit_xml.rb +47 -0
  25. data/lib/jasmine/path_expander.rb +1 -1
  26. data/lib/jasmine/railtie.rb +7 -6
  27. data/lib/jasmine/reporters/api_reporter.rb +38 -0
  28. data/lib/jasmine/results.rb +28 -9
  29. data/lib/jasmine/results_processor.rb +1 -1
  30. data/lib/jasmine/run.html.erb +1 -1
  31. data/lib/jasmine/run_specs.rb +12 -15
  32. data/lib/jasmine/runners/http.rb +11 -49
  33. data/lib/jasmine/selenium_driver.rb +17 -14
  34. data/lib/jasmine/tasks/jasmine.rake +21 -30
  35. data/lib/jasmine/tasks/{jasmine_rails3.rake → jasmine_rails.rake} +0 -0
  36. data/lib/jasmine/version.rb +1 -1
  37. data/lib/jasmine/yaml_config_parser.rb +9 -0
  38. data/release_notes/v2.0.0.rc2.md +44 -0
  39. data/spec/application_spec.rb +33 -38
  40. data/spec/asset_expander_spec.rb +4 -32
  41. data/spec/configuration_spec.rb +95 -35
  42. data/spec/jasmine_command_line_tool_spec.rb +63 -11
  43. data/spec/jasmine_rails_spec.rb +94 -0
  44. data/spec/lib/jasmine/formatters/base_spec.rb +9 -0
  45. data/spec/lib/jasmine/formatters/console_spec.rb +92 -0
  46. data/spec/lib/jasmine/formatters/junit_xml_spec.rb +55 -0
  47. data/spec/lib/jasmine/reporters/api_reporter_spec.rb +53 -0
  48. data/spec/lib/jasmine/runners/http_spec.rb +21 -0
  49. data/spec/path_expander_spec.rb +25 -0
  50. data/spec/results_spec.rb +59 -17
  51. data/spec/spec_helper.rb +36 -18
  52. data/spec/support/fake_selenium_driver.rb +35 -0
  53. data/spec/yaml_config_parser_spec.rb +37 -0
  54. metadata +65 -103
  55. data/generators/jasmine/templates/jasmine-example/SpecRunner.html +0 -54
  56. data/lib/jasmine/asset_pipeline_utility.rb +0 -19
  57. data/lib/jasmine/javascripts/boot.js +0 -28
  58. data/lib/jasmine/rspec_formatter.rb +0 -92
  59. data/spec/dependencies_spec.rb +0 -315
  60. data/spec/jasmine_rails2_spec.rb +0 -89
  61. data/spec/jasmine_rails3_spec.rb +0 -69
  62. data/spec/jasmine_self_test_spec.rb +0 -29
  63. data/spec/rspec_formatter_spec.rb +0 -88
@@ -2,40 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Jasmine::AssetExpander do
4
4
  it "expands asset files" do
5
- bundled_asset = double(:bundled_asset,
6
- :to_a => ['asset1', 'asset2'],
7
- :pathname => double(:pathname, :to_s => '/some_src_dir/asset_file'))
8
-
9
- bundled_asset_getter = lambda do |filepath, ext|
10
- if filepath == 'asset_file' && ext == 'js'
11
- bundled_asset
12
- end
13
- end
14
-
15
- asset_path_getter = lambda do |asset|
16
- if asset == 'asset1'
17
- 'asset1_path'
18
- elsif asset == 'asset2'
19
- 'asset2_path'
20
- end
21
- end
22
-
23
- expander = Jasmine::AssetExpander.new(bundled_asset_getter, asset_path_getter)
5
+ bundled_asset = double(:bundled_asset, :assets => ['asset1_path', 'asset2_path'])
6
+ bundled_asset_factory = double(:bundled_asset_factory)
7
+ bundled_asset_factory.should_receive(:new).with('asset_file').and_return(bundled_asset)
8
+ expander = Jasmine::AssetExpander.new(bundled_asset_factory)
24
9
  expanded_assets = expander.expand('/some_src_dir', 'asset_file')
25
10
  expanded_assets.should == ['/asset1_path?body=true',
26
11
  '/asset2_path?body=true']
27
12
  end
28
-
29
- it "return nil if no bundled asset is found" do
30
- bundled_asset = nil
31
- bundled_asset_getter = lambda do |filepath, ext|
32
- if filepath == 'asset_file' && ext == 'js'
33
- bundled_asset
34
- end
35
- end
36
-
37
- expander = Jasmine::AssetExpander.new(bundled_asset_getter, lambda {})
38
- expanded_assets = expander.expand('/some_src_dir', 'asset_file')
39
- expanded_assets.should be_nil
40
- end
41
13
  end
@@ -47,41 +47,39 @@ describe Jasmine::Configuration do
47
47
  end
48
48
  end
49
49
 
50
- describe "returning css files" do
51
- it "returns mapped jasmine_css_files + css_files" do
50
+ describe 'returning css files' do
51
+ it 'returns mapped jasmine_css_files + css_files' do
52
52
  config = Jasmine::Configuration.new()
53
53
  config.add_path_mapper(lambda { |c| test_mapper1.new(c) })
54
54
  config.add_path_mapper(lambda { |c| test_mapper2.new(c) })
55
55
  config.add_path_mapper(lambda { |c| test_mapper3.new(c) })
56
56
  config.css_files.should == []
57
- config.jasmine_css_files = lambda { ["jasmine_css"] }
58
- config.css_files = lambda { ["css"] }
59
- config.css_files.should == ['mapped_jasmine/jasmine_css/jasmine', 'mapped_src/css/src']
57
+ config.jasmine_css_files = lambda { %w(jasmine_css) }
58
+ config.css_files = lambda { %w(css) }
59
+ config.css_files.should == %w(mapped_jasmine/jasmine_css/jasmine mapped_src/css/src)
60
60
  end
61
61
  end
62
62
 
63
- describe "returning javascript files" do
64
- it "returns the jasmine core files, then srcs, then specs, then boot" do
63
+ describe 'returning javascript files' do
64
+ it 'returns the jasmine core files, then srcs, then specs, then boot' do
65
65
  config = Jasmine::Configuration.new()
66
66
  config.add_path_mapper(lambda { |c| test_mapper1.new(c) })
67
67
  config.add_path_mapper(lambda { |c| test_mapper2.new(c) })
68
68
  config.add_path_mapper(lambda { |c| test_mapper3.new(c) })
69
69
  config.js_files.should == []
70
- config.jasmine_files = lambda { ['jasmine'] }
71
- config.src_files = lambda { ['src'] }
72
- config.boot_files = lambda { ['boot'] }
73
- config.spec_files = lambda { ['spec'] }
74
- config.js_files.should == [
75
- 'mapped_jasmine/jasmine/jasmine',
76
- 'mapped_src/src/src',
77
- 'mapped_spec/spec/spec',
78
- 'mapped_boot/boot/boot',
79
- ]
70
+ config.jasmine_files = lambda { %w(jasmine) }
71
+ config.src_files = lambda { %w(src) }
72
+ config.boot_files = lambda { %w(boot) }
73
+ config.spec_files = lambda { %w(spec) }
74
+ config.js_files.should == %w(
75
+ mapped_jasmine/jasmine/jasmine
76
+ mapped_boot/boot/boot mapped_src/src/src
77
+ mapped_spec/spec/spec)
80
78
  end
81
79
  end
82
80
 
83
- describe "returning rack map" do
84
- it "permits arbitrary rack app path mapping" do
81
+ describe 'returning rack map' do
82
+ it 'permits arbitrary rack app path mapping' do
85
83
  config = Jasmine::Configuration.new()
86
84
  result = double
87
85
  config.add_rack_path('some/path', lambda { result })
@@ -92,31 +90,31 @@ describe Jasmine::Configuration do
92
90
 
93
91
  end
94
92
 
95
- describe "rack apps" do
96
- it "permits the addition of arbitary rack apps" do
93
+ describe 'rack apps' do
94
+ it 'permits the addition of arbitary rack apps' do
97
95
  config = Jasmine::Configuration.new()
98
96
  app = double
99
97
  config.add_rack_app(app)
100
98
  config.rack_apps.should == [[app, nil]]
101
99
  end
102
- it "permits the addition of arbitary rack apps with arbitrary config" do
100
+ it 'permits the addition of arbitary rack apps with arbitrary config' do
103
101
  config = Jasmine::Configuration.new()
104
102
  app = double
105
- block = lambda { "foo" }
103
+ block = lambda { 'foo' }
106
104
  config.add_rack_app(app, &block)
107
105
  config.rack_apps.should == [[app, block]]
108
106
  end
109
107
  end
110
108
 
111
- describe "port" do
112
- it "returns new port and caches return value" do
109
+ describe 'port' do
110
+ it 'returns new port and caches return value' do
113
111
  config = Jasmine::Configuration.new()
114
112
  Jasmine.stub(:find_unused_port).and_return('1234')
115
113
  config.port.should == '1234'
116
114
  Jasmine.stub(:find_unused_port).and_return('4321')
117
115
  config.port.should == '1234'
118
116
  end
119
- it "returns port if configured" do
117
+ it 'returns port if configured' do
120
118
  config = Jasmine::Configuration.new()
121
119
  config.port = '5678'
122
120
  Jasmine.stub(:find_unused_port).and_return('1234')
@@ -124,40 +122,102 @@ describe Jasmine::Configuration do
124
122
  end
125
123
  end
126
124
 
127
- describe "browser" do
128
- it "should default to firefox" do
125
+ describe 'browser' do
126
+ it 'should default to firefox' do
129
127
  Jasmine::Configuration.new().browser.should == 'firefox'
130
128
  end
131
129
 
132
- it "returns browser if set" do
130
+ it 'returns browser if set' do
133
131
  config = Jasmine::Configuration.new()
134
132
  config.browser = 'foo'
135
133
  config.browser.should == 'foo'
136
134
  end
137
135
  end
138
136
 
139
- describe "result_batch_size" do
140
- it "should default to 50" do
137
+ describe 'result_batch_size' do
138
+ it 'should default to 50' do
141
139
  Jasmine::Configuration.new().result_batch_size.should == 50
142
140
  end
143
141
 
144
- it "returns result_batch_size if set" do
142
+ it 'returns result_batch_size if set' do
145
143
  config = Jasmine::Configuration.new()
146
144
  config.result_batch_size = 25
147
145
  config.result_batch_size.should == 25
148
146
  end
149
147
  end
150
148
 
151
- describe "host" do
152
- it "should default to localhost" do
149
+ describe 'host' do
150
+ it 'should default to localhost' do
153
151
  Jasmine::Configuration.new().host.should == 'http://localhost'
154
152
  end
155
153
 
156
- it "returns host if set" do
154
+ it 'returns host if set' do
157
155
  config = Jasmine::Configuration.new()
158
156
  config.host = 'foo'
159
157
  config.host.should == 'foo'
160
158
  end
161
159
  end
160
+
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
173
+ it 'returns value if set' do
174
+ config = Jasmine::Configuration.new()
175
+
176
+ config.junit_xml_path = 'turnip'
177
+ config.junit_xml_path.should == 'turnip'
178
+ end
179
+
180
+ it 'returns defaults' do
181
+ config = Jasmine::Configuration.new()
182
+
183
+ config.junit_xml_path.should == Dir.getwd
184
+ end
185
+ end
186
+
187
+ describe 'spec format' do
188
+ it 'returns value if set' do
189
+ config = Jasmine::Configuration.new()
190
+ config.spec_format = 'fish'
191
+ config.spec_format.should == 'fish'
192
+ end
193
+ end
194
+
195
+ describe 'jasmine ports' do
196
+ it 'returns value if set' do
197
+ config = Jasmine::Configuration.new()
198
+ config.jasmine_port = 'fish'
199
+ config.jasmine_port.should == 'fish'
200
+ end
201
+
202
+ it 'returns defaults' do
203
+ config = Jasmine::Configuration.new()
204
+
205
+ config.jasmine_port.should == 8888
206
+ end
207
+ end
208
+
209
+ describe 'jasmine ports' do
210
+ it 'returns value if set' do
211
+ config = Jasmine::Configuration.new()
212
+ config.formatters = ['pants']
213
+ config.formatters.should == ['pants']
214
+ end
215
+
216
+ it 'returns defaults' do
217
+ config = Jasmine::Configuration.new()
218
+
219
+ config.formatters.should == [Jasmine::Formatters::Console]
220
+ end
221
+ end
162
222
  end
163
223
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Jasmine command line tool" do
3
+ describe 'Jasmine command line tool' do
4
4
  before :each do
5
5
  temp_dir_before
6
6
  Dir::chdir @tmp
@@ -10,20 +10,72 @@ describe "Jasmine command line tool" do
10
10
  temp_dir_after
11
11
  end
12
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./
13
+ describe '.init' do
14
+ it 'should create files on init' do
15
+ output = capture_stdout { Jasmine::CommandLineTool.new.process ['init'] }
16
+ output.should =~ /Jasmine has been installed with example specs./
16
17
 
17
- my_jasmine_lib = File.expand_path(File.join(@root, "lib"))
18
- bootstrap = "$:.unshift('#{my_jasmine_lib}')"
18
+ my_jasmine_lib = File.expand_path(File.join(@root, 'lib'))
19
+ bootstrap = "$:.unshift('#{my_jasmine_lib}')"
19
20
 
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/)
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/)
24
+ end
25
+
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
54
+ 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
73
+ end
23
74
  end
24
75
 
25
- it "should include license info" do
26
- output = capture_stdout { Jasmine::CommandLineTool.new.process ["license"] }
76
+
77
+ it 'should include license info' do
78
+ output = capture_stdout { Jasmine::CommandLineTool.new.process ['license'] }
27
79
  output.should =~ /Copyright/
28
80
  end
29
81
  end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ if Jasmine::Dependencies.rails_available?
4
+ describe 'A Rails app' do
5
+
6
+ before :all do
7
+ temp_dir_before
8
+ Dir::chdir @tmp
9
+
10
+ create_rails 'rails-example'
11
+ Dir::chdir File.join(@tmp, 'rails-example')
12
+
13
+ base = File.absolute_path(File.join(__FILE__, '../..'))
14
+
15
+ open('Gemfile', 'a') { |f|
16
+ f.puts "gem 'jasmine', :path => '#{base}'"
17
+ f.puts "gem 'jasmine-core', :github => 'pivotal/jasmine'"
18
+ f.flush
19
+ }
20
+
21
+ Bundler.with_clean_env do
22
+ puts `NOKOGIRI_USE_SYSTEM_LIBRARIES=true bundle install --path vendor;`
23
+ end
24
+ end
25
+
26
+ after :all do
27
+ temp_dir_after
28
+ end
29
+
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
37
+ end
38
+
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
44
+ end
45
+
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 ')
50
+ end
51
+ end
52
+
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
58
+ end
59
+
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
73
+ end
74
+
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')
80
+
81
+ File.exists?('app/assets/javascripts/jasmine_examples/Player.js').should == true
82
+ File.exists?('app/assets/javascripts/jasmine_examples/Song.js').should == true
83
+
84
+ File.exists?('spec/javascripts/jasmine_examples/PlayerSpec.js').should == true
85
+ File.exists?('spec/javascripts/helpers/SpecHelper.js').should == true
86
+
87
+ output = `bundle exec rake jasmine:ci`
88
+ output.should include('5 specs, 0 failures')
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Formatters::BaseFormatter do
4
+ it 'raises an error on summary to teach people a lesson' do
5
+ expect {
6
+ Jasmine::Formatters::BaseFormatter.new.format
7
+ }.to(raise_error(NotImplementedError))
8
+ end
9
+ end