jasmine-headless-webkit 0.7.3.2 → 0.8.0.alpha.1

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 (64) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +6 -0
  3. data/Rakefile +19 -0
  4. data/bin/jasmine-headless-webkit +2 -22
  5. data/jasmine-headless-webkit.gemspec +5 -4
  6. data/lib/digest/jasmine_test.rb +20 -0
  7. data/lib/jasmine/headless/cacheable_action.rb +1 -3
  8. data/lib/jasmine/headless/coffee_template.rb +30 -0
  9. data/lib/jasmine/headless/command_line.rb +31 -0
  10. data/lib/jasmine/headless/css_template.rb +14 -0
  11. data/lib/jasmine/headless/files_list.rb +251 -0
  12. data/lib/jasmine/headless/js_template.rb +18 -0
  13. data/lib/jasmine/headless/jst_template.rb +10 -0
  14. data/lib/jasmine/headless/options.rb +6 -1
  15. data/lib/jasmine/headless/runner.rb +14 -5
  16. data/lib/jasmine/headless/task.rb +2 -21
  17. data/lib/jasmine/headless/unique_asset_list.rb +14 -0
  18. data/lib/jasmine/headless/version.rb +1 -1
  19. data/lib/jasmine/headless.rb +11 -0
  20. data/lib/jasmine-headless-webkit.rb +4 -4
  21. data/skel/template.html.erb +13 -3
  22. data/spec/integration/randomization_spec.rb +13 -0
  23. data/spec/integration/specify_runner_file_spec.rb +22 -0
  24. data/spec/integration/sprockets_spec.rb +19 -0
  25. data/spec/jasmine/console_log/console_log.yml +1 -1
  26. data/spec/jasmine/runner_out_in_jasmine_yml/jasmine.yml +11 -0
  27. data/spec/jasmine/runner_out_in_jasmine_yml/test.js +2 -0
  28. data/spec/jasmine/runner_out_in_jasmine_yml/test_spec.coffee +4 -0
  29. data/spec/jasmine/with_sprockets_includes/assets/application.js.erb +2 -0
  30. data/spec/jasmine/with_sprockets_includes/assets/things/code.js +6 -0
  31. data/spec/jasmine/with_sprockets_includes/assets/things/required.js +2 -0
  32. data/spec/jasmine/with_sprockets_includes/assets/things/subcode/more_code.js +2 -0
  33. data/spec/jasmine/with_sprockets_includes/assets/things/templates/that.jst.ejs +1 -0
  34. data/spec/jasmine/with_sprockets_includes/assets/things/templates/this.jst +2 -0
  35. data/spec/jasmine/with_sprockets_includes/spec/spec_helper.js +1 -0
  36. data/spec/jasmine/with_sprockets_includes/spec/things/code_spec.js +9 -0
  37. data/spec/jasmine/with_sprockets_includes/with_sprockets_includes.yml +12 -0
  38. data/spec/javascripts/console.log_spec.coffee +15 -0
  39. data/spec/javascripts/support/jasmine.yml +4 -1
  40. data/spec/lib/jasmine/headless/cacheable_action_spec.rb +6 -3
  41. data/spec/lib/jasmine/headless/coffee_template_spec.rb +55 -0
  42. data/spec/lib/jasmine/headless/css_template_spec.rb +25 -0
  43. data/spec/lib/jasmine/headless/files_list_spec.rb +203 -0
  44. data/spec/lib/jasmine/headless/js_template_spec.rb +31 -0
  45. data/spec/lib/jasmine/headless/jst_template_spec.rb +21 -0
  46. data/spec/lib/jasmine/headless/options_spec.rb +18 -0
  47. data/spec/lib/jasmine/headless/template_writer_spec.rb +8 -4
  48. data/spec/lib/jasmine/headless/unique_asset_list_spec.rb +22 -0
  49. data/spec/lib/jasmine/headless_spec.rb +2 -0
  50. data/spec/spec_helper.rb +59 -0
  51. data/vendor/assets/coffeescripts/headless_reporter_result.coffee +10 -7
  52. data/vendor/assets/coffeescripts/intense.coffee +1 -0
  53. data/vendor/assets/coffeescripts/jasmine-extensions.coffee +13 -0
  54. data/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee +34 -2
  55. data/vendor/assets/coffeescripts/prolog.coffee +1 -1
  56. data/vendor/assets/javascripts/headless_reporter_result.js +19 -15
  57. data/vendor/assets/javascripts/intense.js +8 -1
  58. data/vendor/assets/javascripts/jasmine-extensions.js +29 -1
  59. data/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js +53 -13
  60. data/vendor/assets/javascripts/prolog.js +6 -4
  61. metadata +83 -20
  62. data/lib/jasmine/files_list.rb +0 -176
  63. data/spec/javascripts/support/jquery-1.6.2.min.js +0 -18
  64. data/spec/lib/jasmine/files_list_spec.rb +0 -248
@@ -15,15 +15,25 @@
15
15
  log: function(msg) { JHW.stdout.puts(msg) }
16
16
  }
17
17
 
18
- window._onload = window.onload
18
+ window._onload = window.onload;
19
19
 
20
20
  window.onload = function() {
21
- if (window._onload) { window._onload() }
21
+ if (window._onload && (window._onload != window.onload)) {
22
+ window._onload();
23
+ }
22
24
 
23
25
  if (window.JHW) {
24
26
  jasmine.getEnv().addReporter(new jasmine.HeadlessConsoleReporter());
25
27
  } else {
26
- jasmine.getEnv().addReporter(new jasmine.HtmlReporter());
28
+ types = [ 'HtmlReporter', 'TrivialReporter' ];
29
+
30
+ for (var i = 0, j = types.length; i < j; ++i) {
31
+ var type = jasmine[types[i]]
32
+ if (type) {
33
+ jasmine.getEnv().addReporter(new type());
34
+ break;
35
+ }
36
+ }
27
37
  }
28
38
 
29
39
  jasmine.getEnv().execute();
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'randomize run order' do
4
+ let(:seed) { 100 }
5
+
6
+ it 'should randomize the run order' do
7
+ output = %x{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --seed #{seed}}
8
+ $?.exitstatus.should == 0
9
+
10
+ output.should include("--seed #{seed}")
11
+ end
12
+ end
13
+
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'specify runner in jasmine.yml' do
4
+ before do
5
+ File.unlink "spec/temp_out.html" if File.file?('spec/temp_out.html')
6
+ end
7
+
8
+ it 'should randomize the run order' do
9
+ output = %x{bin/jasmine-headless-webkit -j spec/jasmine/runner_out_in_jasmine_yml/jasmine.yml}
10
+ $?.exitstatus.should == 2
11
+
12
+ output.should include("made it")
13
+ output.should include("1 test")
14
+
15
+ "spec/temp_out.html".should be_a_file
16
+ end
17
+
18
+ after do
19
+ File.unlink "spec/temp_out.html" if File.file?('spec/temp_out.html')
20
+ end
21
+ end
22
+
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'sprockets' do
4
+ it 'should pull in the code via sprockets' do
5
+ files = %x{bin/jasmine-headless-webkit -l -j spec/jasmine/with_sprockets_includes/with_sprockets_includes.yml}
6
+ $?.exitstatus.should == 0
7
+
8
+ files.lines.to_a.should contain_in_order_in_file_list(
9
+ 'vendor/assets/javascripts/jquery.js',
10
+ 'templates/that.jst.ejs',
11
+ 'templates/this.jst',
12
+ 'assets/things/required.js',
13
+ 'assets/things/code.js',
14
+ 'assets/things/subcode/more_code.js',
15
+ 'spec_helper.js',
16
+ 'spec/things/code_spec.js'
17
+ )
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
-
2
1
  src_files:
2
+ - spec/javascripts/support/jquery-1.6.2.min.js
3
3
  - spec/jasmine/console_log/console_log.js
4
4
 
5
5
  spec_files:
@@ -0,0 +1,11 @@
1
+ src_dir: spec/jasmine/runner_out_in_jasmine_yml
2
+ spec_dir: spec/jasmine/runner_out_in_jasmine_yml
3
+
4
+ src_files:
5
+ - "*.js"
6
+
7
+ spec_files:
8
+ - "*_spec.coffee"
9
+
10
+ runner_output: 'spec/temp_out.html'
11
+
@@ -0,0 +1,2 @@
1
+ console.log("made it")
2
+
@@ -0,0 +1,4 @@
1
+ describe 'this', ->
2
+ it 'should be true', ->
3
+ expect(true).toEqual(true)
4
+
@@ -0,0 +1,2 @@
1
+ //= require 'jquery'
2
+ //= require_tree '.'
@@ -0,0 +1,6 @@
1
+ //= require 'jquery'
2
+ //= require_tree './templates'
3
+ //= require 'things/required'
4
+
5
+ window.a = '1';
6
+
@@ -0,0 +1,2 @@
1
+ //= require 'jquery'
2
+
@@ -0,0 +1,2 @@
1
+ //= require 'things/required'
2
+
@@ -0,0 +1 @@
1
+ //= require 'jquery'
@@ -0,0 +1,9 @@
1
+ //= require 'things/code'
2
+
3
+ describe('code', function() {
4
+ it('should equal 1', function() {
5
+ expect(window.a).toEqual(1)
6
+ expect(jQuery).not.toBeUndefined()
7
+ });
8
+ });
9
+
@@ -0,0 +1,12 @@
1
+ src_dir: spec/jasmine/with_sprockets_includes/assets
2
+ spec_dir: spec/jasmine/with_sprockets_includes/spec
3
+
4
+ spec_files:
5
+ - "**/*_spec.js"
6
+
7
+ src_files:
8
+ - "**/*"
9
+
10
+ helpers:
11
+ - "spec_helper.js"
12
+
@@ -0,0 +1,15 @@
1
+ #= require jquery
2
+
3
+ describe 'console.log', ->
4
+ it 'should not eat my precious jqueries', ->
5
+ _log = JHW.log
6
+
7
+ JHW.log = ->
8
+
9
+ d = $('<div><div id="inner">b</div></div>');
10
+ expect(d.find('#inner').length).toBe(1);
11
+ console.log(d.find('#inner'));
12
+ expect(d.find('#inner').length).toBe(1);
13
+
14
+ JHW.log = _log
15
+
@@ -1,4 +1,7 @@
1
- src_files: [ 'vendor/assets/coffeescripts/*.coffee' ]
1
+ src_files:
2
+ - 'spec/javascripts/support/jquery-1.6.2.min.js'
3
+ - 'vendor/assets/coffeescripts/*.coffee'
4
+
2
5
  spec_files: [ 'spec/javascripts/*_spec.coffee' ]
3
6
  src_dir: .
4
7
  spec_dir: .
@@ -3,12 +3,15 @@ require 'spec_helper'
3
3
  describe Jasmine::Headless::CacheableAction do
4
4
  include FakeFS::SpecHelpers
5
5
 
6
- let(:file) { 'file.whatever' }
6
+ let(:file) { 'dir/file.whatever' }
7
7
  let(:data) { 'data' }
8
8
  let(:compiled) { 'compiled' }
9
9
 
10
10
  before do
11
+ FileUtils.mkdir_p File.dirname(file)
12
+
11
13
  File.open(file, 'wb') { |fh| fh.print(data) }
14
+
12
15
  described_class.cache_dir = cache_dir
13
16
  described_class.cache_type = cache_type
14
17
  end
@@ -19,7 +22,7 @@ describe Jasmine::Headless::CacheableAction do
19
22
 
20
23
  let(:cache_type) { 'action' }
21
24
  let(:cache_dir) { 'cache' }
22
- let(:cache_file) { File.join(cache_dir, cache_type, Digest::SHA1.hexdigest(file)) + '.js' }
25
+ let(:cache_file) { File.join(cache_dir, cache_type, file) + '.js' }
23
26
  let(:cache_file_data) { YAML.load(File.read(cache_file)) }
24
27
 
25
28
  let(:cache_object) { described_class.new(file) }
@@ -45,7 +48,7 @@ describe Jasmine::Headless::CacheableAction do
45
48
  FileUtils.mkdir_p(cache_dir)
46
49
 
47
50
  File.stubs(:mtime).with(file).returns(Time.at(10))
48
- File.stubs(:mtime).with(cache_file).returns(Time.at(cache_file_mtime))
51
+ File.stubs(:mtime).with(File.expand_path(cache_file)).returns(Time.at(cache_file_mtime))
49
52
  end
50
53
 
51
54
  context 'cache empty' do
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::CoffeeTemplate do
4
+ let(:data) { 'data' }
5
+ let(:path) { 'path.coffee' }
6
+
7
+ let(:template) { described_class.new(path) { data } }
8
+
9
+ subject { template.render }
10
+
11
+ let(:handle_expectation) { Jasmine::Headless::CoffeeScriptCache.any_instance.stubs(:handle) }
12
+
13
+ context 'compilation error' do
14
+ let(:error) { CoffeeScript::CompilationError.new("fail") }
15
+
16
+ before do
17
+ handle_expectation.raises(error)
18
+ end
19
+
20
+ it 'should pass along the error' do
21
+ expect { subject }.to raise_error(CoffeeScript::CompilationError)
22
+ end
23
+ end
24
+
25
+ context 'compiles fine' do
26
+ let(:source) { 'source' }
27
+
28
+ before do
29
+ Jasmine::Headless::CoffeeScriptCache.any_instance.stubs(:cached?).returns(cache_return)
30
+ handle_expectation.returns(source)
31
+ end
32
+
33
+ context 'cached' do
34
+ let(:file_path) { 'dir/file.js' }
35
+ let(:cache_return) { true }
36
+
37
+ before do
38
+ Jasmine::Headless::CoffeeScriptCache.any_instance.stubs(:cache_file).returns(file_path)
39
+ end
40
+
41
+ it 'should return the cached file' do
42
+ subject.should include(%{<script type="text/javascript" src="#{file_path}"></script>})
43
+ end
44
+ end
45
+
46
+ context 'not cached' do
47
+ let(:cache_return) { false }
48
+
49
+ it 'should return the generated js' do
50
+ subject.should include(%{<script type="text/javascript">#{source}</script>})
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::CSSTemplate do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:template) { described_class.new(file) { data } }
7
+ let(:file) { 'file' }
8
+ let(:data) { 'data' }
9
+
10
+ subject { template.render }
11
+
12
+ before do
13
+ File.open(file, 'wb') if file
14
+ end
15
+
16
+ context "no file'" do
17
+ let(:file) { nil }
18
+
19
+ it { should == data }
20
+ end
21
+
22
+ context 'file' do
23
+ it { should == %{<link rel="stylesheet" href="#{file}" type="text/css" />} }
24
+ end
25
+ end
@@ -0,0 +1,203 @@
1
+ require 'spec_helper'
2
+ require 'fakefs/spec_helpers'
3
+ require 'coffee-script'
4
+
5
+ describe Jasmine::Headless::FilesList do
6
+ let(:files_list) { described_class.new }
7
+
8
+ describe '#initialize' do
9
+ it "should have default files" do
10
+ files_list.files.should == [
11
+ File.join(Jasmine::Core.path, "jasmine.js"),
12
+ File.join(Jasmine::Core.path, "jasmine-html.js"),
13
+ File.join(Jasmine::Core.path, "jasmine.css"),
14
+ File.expand_path('vendor/assets/javascripts/jasmine-extensions.js'),
15
+ File.expand_path('vendor/assets/javascripts/intense.js'),
16
+ File.expand_path('vendor/assets/javascripts/headless_reporter_result.js'),
17
+ File.expand_path('vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js'),
18
+ File.expand_path('vendor/assets/javascripts/jsDump.js'),
19
+ File.expand_path('vendor/assets/javascripts/beautify-html.js'),
20
+ ]
21
+ end
22
+ end
23
+
24
+ def self.no_default_files!
25
+ before do
26
+ described_class.stubs(:default_files).returns([])
27
+ end
28
+ end
29
+
30
+ it 'should have tests for #use_config!'
31
+ it 'should have tests for #add_files'
32
+
33
+ describe '#spec_file_line_numbers' do
34
+ include FakeFS::SpecHelpers
35
+
36
+ no_default_files!
37
+
38
+ before do
39
+ files_list.stubs(:spec_files).returns(['test.coffee', 'test2.coffee'])
40
+
41
+ File.open('test.coffee', 'w') { |fh| fh.print "describe('cat')\ndescribe('cat')" }
42
+ File.open('test2.coffee', 'w') { |fh| fh.print "no matches" }
43
+ end
44
+
45
+ it 'should generate filenames and line number info' do
46
+ files_list.spec_file_line_numbers.should == {
47
+ 'test.coffee' => { 'cat' => [ 1, 2 ] }
48
+ }
49
+ end
50
+ end
51
+
52
+ describe '#search_paths' do
53
+ no_default_files!
54
+
55
+ let(:files_list) { described_class.new(:config => config) }
56
+
57
+ let(:config) { {
58
+ 'src_dir' => src_dir,
59
+ 'spec_dir' => spec_dir
60
+ } }
61
+
62
+ let(:src_dir) { 'src dir' }
63
+ let(:spec_dir) { 'spec dir' }
64
+ let(:path) { 'path' }
65
+
66
+ before do
67
+ Jasmine::Headless::FilesList.stubs(:vendor_asset_paths).returns([])
68
+ end
69
+
70
+ context 'no vendored gem paths' do
71
+ it 'should take the src dir and spec dirs' do
72
+ files_list.search_paths.should == [ Jasmine::Core.path, File.expand_path(src_dir), File.expand_path(spec_dir) ]
73
+ end
74
+ end
75
+
76
+ context 'vendored gem paths' do
77
+ before do
78
+ Jasmine::Headless::FilesList.stubs(:vendor_asset_paths).returns([ path ])
79
+ end
80
+
81
+ it 'should add the vendor gem paths to the list' do
82
+ files_list.search_paths.should == [ Jasmine::Core.path, path, File.expand_path(src_dir), File.expand_path(spec_dir) ]
83
+ end
84
+ end
85
+
86
+ context 'src_dir is an array' do
87
+ let(:dir_1) { 'dir 1' }
88
+ let(:dir_2) { 'dir 2' }
89
+
90
+ let(:src_dir) { [ dir_1, dir_2 ] }
91
+
92
+ it 'should take the src dir and spec dirs' do
93
+ files_list.search_paths.should == [ Jasmine::Core.path, File.expand_path(dir_1), File.expand_path(dir_2), File.expand_path(spec_dir) ]
94
+ end
95
+ end
96
+ end
97
+
98
+ describe '.vendor_asset_paths' do
99
+ include FakeFS::SpecHelpers
100
+
101
+ let(:dir_one) { 'dir_one' }
102
+ let(:dir_two) { 'dir_two' }
103
+
104
+ let(:gem_one) { stub(:gem_dir => dir_one) }
105
+ let(:gem_two) { stub(:gem_dir => dir_two) }
106
+
107
+ before do
108
+ described_class.instance_variable_set(:@vendor_asset_paths, nil)
109
+
110
+ FileUtils.mkdir_p File.join(dir_two, 'vendor/assets/javascripts')
111
+
112
+ Gem::Specification.stubs(:_all).returns([gem_one, gem_two])
113
+ end
114
+
115
+ it 'should return all matching gems with vendor/assets/javascripts directories' do
116
+ described_class.vendor_asset_paths.should == [ File.join(dir_two, 'vendor/assets/javascripts') ]
117
+ end
118
+ end
119
+
120
+ describe '#files' do
121
+ let(:path_one) { 'one' }
122
+ let(:path_two) { 'two' }
123
+ let(:path_three) { 'three' }
124
+
125
+ let(:file_one) { stub(:to_a => [ asset_one, asset_two ] ) }
126
+ let(:file_two) { stub(:to_a => [ asset_two, asset_three ] ) }
127
+
128
+ let(:asset_one) { stub(:pathname => Pathname(path_one), :to_ary => nil) }
129
+ let(:asset_two) { stub(:pathname => Pathname(path_two), :to_ary => nil) }
130
+ let(:asset_three) { stub(:pathname => Pathname(path_three), :to_ary => nil) }
131
+
132
+ before do
133
+ files_list.stubs(:required_files).returns(Jasmine::Headless::UniqueAssetList.new([ file_one, file_two ]))
134
+ end
135
+
136
+ subject { files_list.files }
137
+
138
+ it { should == [ path_one, path_two, path_three ] }
139
+ end
140
+
141
+ describe '#filtered_files' do
142
+ let(:spec_dir) { 'spec' }
143
+
144
+ let(:file_one) { "#{spec_dir}/one" }
145
+ let(:file_two) { "#{spec_dir}/two" }
146
+ let(:file_three) { "#{spec_dir}/three" }
147
+ let(:file_four) { 'other/four' }
148
+
149
+ before do
150
+ files_list.stubs(:files).returns([
151
+ file_one,
152
+ file_two,
153
+ file_three,
154
+ file_four
155
+ ])
156
+
157
+ files_list.stubs(:potential_files_to_filter).returns([ file_one, file_two, file_three ])
158
+ end
159
+
160
+ subject { files_list.filtered_files }
161
+
162
+ context 'empty filter' do
163
+ before do
164
+ files_list.stubs(:spec_filter).returns([])
165
+ end
166
+
167
+ it { should == [ file_one, file_two, file_three, file_four ] }
168
+ end
169
+
170
+ context 'with filter' do
171
+ before do
172
+ files_list.stubs(:spec_filter).returns([ "#{spec_dir}/one", '**/tw*' ])
173
+ end
174
+
175
+ it { should == [ file_one, file_two, file_four ] }
176
+ end
177
+ end
178
+
179
+ describe '#add_files' do
180
+ let(:files_list) { described_class.new(:seed => 100) }
181
+
182
+ no_default_files!
183
+
184
+ let(:dir) { 'tmp' }
185
+
186
+ before do
187
+ FileUtils.mkdir_p dir
188
+
189
+ 10.times do |index|
190
+ File.open(File.join(dir, "file-#{index}.js"), 'wb')
191
+ end
192
+ end
193
+
194
+ it 'should load spec files in a random order' do
195
+ files_list.send(:add_files, [ '*' ], 'spec_files', [ dir ])
196
+
197
+ files_list.files.collect { |name| name[%r{\d+}] }.should == %w{6 7 1 0 5 3 4 8 2 9}
198
+
199
+ FileUtils.rm_rf dir
200
+ end
201
+ end
202
+ end
203
+
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::JSTemplate do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:template) { described_class.new(file) { data } }
7
+ let(:file) { 'file' }
8
+ let(:data) { 'data' }
9
+
10
+ subject { template.render }
11
+
12
+ before do
13
+ File.open(file, 'wb') if file
14
+ end
15
+
16
+ context "no file'" do
17
+ let(:file) { nil }
18
+
19
+ it { should == data }
20
+ end
21
+
22
+ context 'file' do
23
+ it { should == %{<script type="text/javascript" src="#{file}"></script>} }
24
+ end
25
+
26
+ context 'script as first thing' do
27
+ let(:data) { '<script type="text/javascript"' }
28
+
29
+ it { should == data }
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::JSTTemplate do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:template) { described_class.new(file) }
7
+ let(:file) { 'file' }
8
+ let(:data) { 'data' }
9
+
10
+ let(:context) { stub(:logical_path => 'path') }
11
+
12
+ before do
13
+ File.open(file, 'wb') { |fh| fh.print data }
14
+ end
15
+
16
+ subject { template.render(context) }
17
+
18
+ it { should include(%{<script type="text/javascript">}) }
19
+ it { should include(data) }
20
+ end
21
+
@@ -92,6 +92,24 @@ describe Jasmine::Headless::Options do
92
92
  end
93
93
  end
94
94
 
95
+ context 'specify no seed' do
96
+ it 'should have a seed' do
97
+ options[:seed].should_not be_nil
98
+ end
99
+ end
100
+
101
+ context 'specify random order seed' do
102
+ let(:seed) { 12345 }
103
+
104
+ before do
105
+ ARGV.replace([ "--seed", seed ])
106
+ end
107
+
108
+ it 'should specify the seed' do
109
+ options[:seed].should == seed
110
+ end
111
+ end
112
+
95
113
  after do
96
114
  ARGV.replace(@argv)
97
115
  end
@@ -47,17 +47,21 @@ describe Jasmine::Headless::TemplateWriter do
47
47
  include FakeFS::SpecHelpers
48
48
 
49
49
  before do
50
+ Jasmine::Headless::FilesList.stubs(:default_files).returns([])
51
+
50
52
  File.stubs(:read).returns(nil)
51
53
 
52
54
  runner.stubs(:keep_runner).returns(true)
53
55
  runner.stubs(:runner_filename).returns(false)
56
+
57
+ Sprockets::Environment.any_instance.stubs(:find_asset).returns(stub(:body => ''))
54
58
  end
55
59
 
56
- let(:files_list) { Jasmine::FilesList.new }
60
+ let(:files_list) { Jasmine::Headless::FilesList.new }
57
61
 
58
62
  before do
59
- files_list.files << 'file.js'
60
- files_list.filtered_files << 'file.js'
63
+ files_list.stubs(:files).returns([ 'file.js' ])
64
+ files_list.stubs(:filtered_files).returns([ 'file.js' ])
61
65
  end
62
66
 
63
67
  context 'no filter' do
@@ -70,7 +74,7 @@ describe Jasmine::Headless::TemplateWriter do
70
74
 
71
75
  context 'filtered files' do
72
76
  before do
73
- files_list.files << 'file2.js'
77
+ files_list.stubs(:files).returns([ 'file.js', 'file2.js' ])
74
78
  end
75
79
 
76
80
  it 'should write two files' do
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::UniqueAssetList do
4
+ let(:list) { described_class.new }
5
+
6
+ let(:first) { stub(:logical_path => 'one') }
7
+ let(:second) { stub(:logical_path => 'two') }
8
+ let(:third) { stub(:logical_path => 'two') }
9
+
10
+ it 'should raise an exception on a non-asset' do
11
+ expect { list << "whatever" }.to raise_error(StandardError)
12
+ end
13
+
14
+ it 'should not add the same asset with the same logical path twice' do
15
+ list << first
16
+ list << second
17
+ list << third
18
+
19
+ list.to_a.should == [ first, second ]
20
+ end
21
+ end
22
+
@@ -0,0 +1,2 @@
1
+ require 'spec_helper'
2
+