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.
- checksums.yaml +7 -0
- data/.travis.yml +3 -37
- data/Gemfile +11 -2
- data/HOW_TO_TEST.markdown +1 -1
- data/README.markdown +10 -10
- data/Rakefile +18 -29
- data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +2 -2
- data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +14 -8
- data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +3 -3
- data/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb +1 -0
- data/jasmine.gemspec +11 -41
- data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +15 -9
- data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +1 -1
- data/lib/jasmine.rb +10 -7
- data/lib/jasmine/asset_bundle.rb +69 -0
- data/lib/jasmine/asset_expander.rb +7 -7
- data/lib/jasmine/command_line_tool.rb +18 -0
- data/lib/jasmine/config.rb +23 -15
- data/lib/jasmine/configuration.rb +14 -8
- data/lib/jasmine/core_configuration.rb +7 -4
- data/lib/jasmine/dependencies.rb +14 -18
- data/lib/jasmine/formatters/base.rb +9 -0
- data/lib/jasmine/formatters/console.rb +45 -0
- data/lib/jasmine/formatters/junit_xml.rb +47 -0
- data/lib/jasmine/path_expander.rb +1 -1
- data/lib/jasmine/railtie.rb +7 -6
- data/lib/jasmine/reporters/api_reporter.rb +38 -0
- data/lib/jasmine/results.rb +28 -9
- data/lib/jasmine/results_processor.rb +1 -1
- data/lib/jasmine/run.html.erb +1 -1
- data/lib/jasmine/run_specs.rb +12 -15
- data/lib/jasmine/runners/http.rb +11 -49
- data/lib/jasmine/selenium_driver.rb +17 -14
- data/lib/jasmine/tasks/jasmine.rake +21 -30
- data/lib/jasmine/tasks/{jasmine_rails3.rake → jasmine_rails.rake} +0 -0
- data/lib/jasmine/version.rb +1 -1
- data/lib/jasmine/yaml_config_parser.rb +9 -0
- data/release_notes/v2.0.0.rc2.md +44 -0
- data/spec/application_spec.rb +33 -38
- data/spec/asset_expander_spec.rb +4 -32
- data/spec/configuration_spec.rb +95 -35
- data/spec/jasmine_command_line_tool_spec.rb +63 -11
- data/spec/jasmine_rails_spec.rb +94 -0
- data/spec/lib/jasmine/formatters/base_spec.rb +9 -0
- data/spec/lib/jasmine/formatters/console_spec.rb +92 -0
- data/spec/lib/jasmine/formatters/junit_xml_spec.rb +55 -0
- data/spec/lib/jasmine/reporters/api_reporter_spec.rb +53 -0
- data/spec/lib/jasmine/runners/http_spec.rb +21 -0
- data/spec/path_expander_spec.rb +25 -0
- data/spec/results_spec.rb +59 -17
- data/spec/spec_helper.rb +36 -18
- data/spec/support/fake_selenium_driver.rb +35 -0
- data/spec/yaml_config_parser_spec.rb +37 -0
- metadata +65 -103
- data/generators/jasmine/templates/jasmine-example/SpecRunner.html +0 -54
- data/lib/jasmine/asset_pipeline_utility.rb +0 -19
- data/lib/jasmine/javascripts/boot.js +0 -28
- data/lib/jasmine/rspec_formatter.rb +0 -92
- data/spec/dependencies_spec.rb +0 -315
- data/spec/jasmine_rails2_spec.rb +0 -89
- data/spec/jasmine_rails3_spec.rb +0 -69
- data/spec/jasmine_self_test_spec.rb +0 -29
- data/spec/rspec_formatter_spec.rb +0 -88
data/spec/asset_expander_spec.rb
CHANGED
@@ -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
|
-
|
7
|
-
|
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
|
data/spec/configuration_spec.rb
CHANGED
@@ -47,41 +47,39 @@ describe Jasmine::Configuration do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
51
|
-
it
|
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 {
|
58
|
-
config.css_files = lambda {
|
59
|
-
config.css_files.should ==
|
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
|
64
|
-
it
|
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 {
|
71
|
-
config.src_files = lambda {
|
72
|
-
config.boot_files = lambda {
|
73
|
-
config.spec_files = lambda {
|
74
|
-
config.js_files.should ==
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
84
|
-
it
|
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
|
96
|
-
it
|
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
|
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 {
|
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
|
112
|
-
it
|
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
|
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
|
128
|
-
it
|
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
|
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
|
140
|
-
it
|
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
|
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
|
152
|
-
it
|
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
|
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
|
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
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
|
18
|
+
my_jasmine_lib = File.expand_path(File.join(@root, 'lib'))
|
19
|
+
bootstrap = "$:.unshift('#{my_jasmine_lib}')"
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
26
|
-
|
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
|