jasmine-headless-webkit 0.8.1 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ jhw-test
15
15
  _site/
16
16
  jhw.*.html
17
17
  coverage/
18
+ tmp/
@@ -2,6 +2,9 @@ require 'pathname'
2
2
 
3
3
  module Jasmine
4
4
  module Headless
5
+
6
+ EXCLUDED_FORMATS = %w{less sass scss erb str}
7
+
5
8
  autoload :CommandLine, 'jasmine/headless/command_line'
6
9
 
7
10
  autoload :CoffeeScriptCache, 'jasmine/headless/coffee_script_cache'
@@ -16,11 +19,14 @@ module Jasmine
16
19
  autoload :UniqueAssetList, 'jasmine/headless/unique_asset_list'
17
20
 
18
21
  autoload :TemplateWriter, 'jasmine/headless/template_writer'
22
+
23
+ autoload :FileChecker, 'jasmine/headless/file_checker'
19
24
 
20
25
  autoload :CoffeeTemplate, 'jasmine/headless/coffee_template'
21
26
  autoload :JSTemplate, 'jasmine/headless/js_template'
22
27
  autoload :JSTTemplate, 'jasmine/headless/jst_template'
23
28
  autoload :CSSTemplate, 'jasmine/headless/css_template'
29
+ autoload :NilTemplate, 'jasmine/headless/nil_template'
24
30
 
25
31
  autoload :Report, 'jasmine/headless/report'
26
32
  autoload :ReportMessage, 'jasmine/headless/report_message'
@@ -3,11 +3,17 @@ require 'rainbow'
3
3
 
4
4
  module Jasmine::Headless
5
5
  class CoffeeTemplate < Tilt::Template
6
+ include Jasmine::Headless::FileChecker
7
+
6
8
  self.default_mime_type = 'application/javascript'
7
9
 
8
10
  def prepare ; end
9
11
 
10
12
  def evaluate(scope, locals, &block)
13
+ if bad_format?(file)
14
+ alert_bad_format(file)
15
+ return ''
16
+ end
11
17
  begin
12
18
  cache = Jasmine::Headless::CoffeeScriptCache.new(file)
13
19
  source = cache.handle
@@ -2,11 +2,16 @@ require 'tilt/template'
2
2
 
3
3
  module Jasmine::Headless
4
4
  class CSSTemplate < Tilt::Template
5
+ include Jasmine::Headless::FileChecker
5
6
  self.default_mime_type = 'text/css'
6
7
 
7
8
  def prepare ; end
8
9
 
9
10
  def evaluate(scope, locals, &block)
11
+ if bad_format?(file)
12
+ alert_bad_format(file)
13
+ return ''
14
+ end
10
15
  file ? %{<link rel="stylesheet" href="#{file}" type="text/css" />} : data
11
16
  end
12
17
  end
@@ -0,0 +1,21 @@
1
+ module Jasmine::Headless::FileChecker
2
+ def bad_format?(file)
3
+ return if file.nil?
4
+
5
+ ::Jasmine::Headless::EXCLUDED_FORMATS.any? do |format|
6
+ file[%r{\.#{format}(\.|$)}]
7
+ end
8
+ end
9
+
10
+ def alert_bad_format(file)
11
+ puts "[%s] %s: %s" % [ 'Skipping File'.color(:red), file.color(:yellow), "unsupported format".color(:white) ]
12
+ end
13
+
14
+ def alert_if_bad_format?(file)
15
+ if result = bad_format?(file)
16
+ alert_bad_format(file)
17
+ end
18
+
19
+ result
20
+ end
21
+ end
@@ -7,6 +7,8 @@ require 'sprockets/engines'
7
7
 
8
8
  module Jasmine::Headless
9
9
  class FilesList
10
+ include FileChecker
11
+
10
12
  class << self
11
13
  def vendor_asset_paths
12
14
  return @vendor_asset_paths if @vendor_asset_paths
@@ -39,8 +41,8 @@ module Jasmine::Headless
39
41
 
40
42
  # ...and unregister ones we don't want/need
41
43
  Sprockets.instance_eval do
42
- %w{less sass scss erb str}.each do |extension|
43
- @engines.delete(".#{extension}")
44
+ EXCLUDED_FORMATS.each do |extension|
45
+ register_engine ".#{extension}", Jasmine::Headless::NilTemplate
44
46
  end
45
47
 
46
48
  register_engine '.coffee', Jasmine::Headless::CoffeeTemplate
@@ -53,6 +55,12 @@ module Jasmine::Headless
53
55
  def default_files
54
56
  %w{jasmine.js jasmine-html jasmine.css jasmine-extensions intense headless_reporter_result jasmine.HeadlessConsoleReporter jsDump beautify-html}
55
57
  end
58
+
59
+ def extension_filter
60
+ extensions = (%w{.js .css} + Sprockets.engine_extensions)
61
+
62
+ %r{(#{extensions.join('|')})$}
63
+ end
56
64
  end
57
65
 
58
66
  PLEASE_WAIT_IM_WORKING_TIME = 2
@@ -118,7 +126,10 @@ module Jasmine::Headless
118
126
  if is_outside_scope = !spec_filter.empty?
119
127
  is_outside_scope = spec_dir.any? do |dir|
120
128
  spec_file_searches.any? do |search|
121
- !spec_files.any? { |file| File.fnmatch?(File.join(dir, search), file) }
129
+ !spec_files.any? do |file|
130
+ target = File.join(dir, search)
131
+ File.fnmatch?(target, file) || File.fnmatch?(target.gsub(%{^**/}, ''), file)
132
+ end
122
133
  end
123
134
  end
124
135
  end
@@ -208,11 +219,17 @@ module Jasmine::Headless
208
219
  end
209
220
 
210
221
  def expanded_dir(path)
211
- Dir[path].find_all { |file| file[extension_filter] }.collect { |file| File.expand_path(file) }.find_all { |path| File.file?(path) }
222
+ Dir[path].find_all { |file|
223
+ file[extension_filter] && !alert_if_bad_format?(file)
224
+ }.collect {
225
+ |file| File.expand_path(file)
226
+ }.find_all {
227
+ |path| File.file?(path)
228
+ }
212
229
  end
213
230
 
214
231
  def extension_filter
215
- %r{(#{(%w{.js .css} + Sprockets.engine_extensions).join('|')})$}
232
+ self.class.extension_filter
216
233
  end
217
234
 
218
235
  def add_path(path, type)
@@ -2,11 +2,16 @@ require 'tilt/template'
2
2
 
3
3
  module Jasmine::Headless
4
4
  class JSTemplate < Tilt::Template
5
+ include Jasmine::Headless::FileChecker
5
6
  self.default_mime_type = 'application/javascript'
6
7
 
7
8
  def prepare ; end
8
9
 
9
10
  def evaluate(scope, locals, &block)
11
+ if bad_format?(file)
12
+ alert_bad_format(file)
13
+ return ''
14
+ end
10
15
  if data[%r{^<script type="text/javascript"}]
11
16
  data
12
17
  else
@@ -2,7 +2,12 @@ require 'sprockets/jst_processor'
2
2
 
3
3
  module Jasmine::Headless
4
4
  class JSTTemplate < Sprockets::JstProcessor
5
+ include Jasmine::Headless::FileChecker
5
6
  def evaluate(*args)
7
+ if bad_format?(file)
8
+ alert_bad_format(file)
9
+ return ''
10
+ end
6
11
  %{<script type="text/javascript">#{super}</script>}
7
12
  end
8
13
  end
@@ -0,0 +1,14 @@
1
+ require 'tilt/template'
2
+ require 'rainbow'
3
+
4
+ module Jasmine::Headless
5
+ class NilTemplate < Tilt::Template
6
+
7
+ def prepare ; end
8
+
9
+ def evaluate(scope, locals, &block)
10
+ return ''
11
+ end
12
+ end
13
+ end
14
+
@@ -78,8 +78,14 @@ module Jasmine
78
78
  )
79
79
 
80
80
  @_targets = template_writer.write!(files_list)
81
+
81
82
  run_targets = @_targets.dup
82
- run_targets.pop if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
83
+
84
+ if run_targets.length == 2
85
+ if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
86
+ run_targets.pop
87
+ end
88
+ end
83
89
 
84
90
  system jasmine_command(run_targets)
85
91
 
@@ -1,5 +1,5 @@
1
1
  module Jasmine
2
2
  module Headless
3
- VERSION = "0.8.1"
3
+ VERSION = "0.8.3"
4
4
  end
5
5
  end
@@ -4,16 +4,20 @@ describe 'sprockets' do
4
4
  it 'should pull in the code via sprockets' do
5
5
  files = %x{bin/jasmine-headless-webkit -l -j spec/jasmine/with_sprockets_includes/with_sprockets_includes.yml}
6
6
  $?.exitstatus.should == 0
7
-
8
7
  files.lines.to_a.should contain_in_order_in_file_list(
8
+ 'assets/application.js.erb: unsupported format',
9
9
  'vendor/assets/javascripts/jquery.js',
10
10
  'templates/that.jst.ejs',
11
11
  'templates/this.jst',
12
+ 'things/jquery.string.js',
12
13
  'assets/things/required.js',
13
14
  'assets/things/code.js',
14
15
  'assets/things/subcode/more_code.js',
15
16
  'spec_helper.js',
16
17
  'spec/things/code_spec.js'
17
18
  )
19
+
20
+ files.lines.to_a.any? { |line| line['assets/jquery.string.js: unsupported format'] }.should be_false
18
21
  end
19
22
  end
23
+
@@ -1,2 +1,3 @@
1
1
  //= require 'jquery'
2
+ //= require 'things/jquery.string'
2
3
 
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::FileChecker do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:test_class) do
7
+ object = Object.new
8
+ object.class.send(:include, Jasmine::Headless::FileChecker)
9
+ object
10
+ end
11
+
12
+ context "bad_format?" do
13
+ it "should return false wth correct format" do
14
+ test_class.bad_format?('foobar.js').should be_false
15
+ end
16
+
17
+ it "should return false wth wrong format" do
18
+ test_class.bad_format?('foobar.js.erb').should be_true
19
+ end
20
+
21
+ it "should check for the whole extension" do
22
+ test_class.bad_format?('foobar.string.js').should be_false
23
+ end
24
+ end
25
+ end
@@ -204,15 +204,23 @@ describe Jasmine::Headless::FilesList do
204
204
  10.times do |index|
205
205
  File.open(File.join(dir, "file-#{index}.js"), 'wb')
206
206
  end
207
+
208
+ File.open(File.join(dir, 'file.js.erb'), 'wb')
207
209
  end
208
210
 
209
- it 'should load spec files in a random order' do
211
+ before do
210
212
  files_list.send(:add_files, [ '*' ], 'spec_files', [ dir ])
213
+ end
211
214
 
215
+ it 'should load spec files in a random order' do
212
216
  files_list.files.collect { |name| name[%r{\d+}] }.should == %w{6 7 1 0 5 3 4 8 2 9}
213
217
 
214
218
  FileUtils.rm_rf dir
215
219
  end
220
+
221
+ it 'should not load an excluded format' do
222
+ files_list.files.any? { |file| file['.erb'] }.should be_false
223
+ end
216
224
  end
217
225
  end
218
226
 
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::NilTemplate do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:template) { described_class.new(file) { data } }
7
+ let(:file) { 'file' }
8
+ let(: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 == '' }
24
+ end
25
+
26
+ context 'script as first thing' do
27
+ let(:data) { '' }
28
+
29
+ it { should == data }
30
+ end
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine-headless-webkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-12-01 00:00:00.000000000Z
14
+ date: 2011-12-06 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: jasmine-core
18
- requirement: &2155294260 !ruby/object:Gem::Requirement
18
+ requirement: &2165681500 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '1.1'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2155294260
26
+ version_requirements: *2165681500
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: coffee-script
29
- requirement: &2155293840 !ruby/object:Gem::Requirement
29
+ requirement: &2165681040 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *2155293840
37
+ version_requirements: *2165681040
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rainbow
40
- requirement: &2155293380 !ruby/object:Gem::Requirement
40
+ requirement: &2165680320 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *2155293380
48
+ version_requirements: *2165680320
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: multi_json
51
- requirement: &2155292960 !ruby/object:Gem::Requirement
51
+ requirement: &2165679860 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0'
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *2155292960
59
+ version_requirements: *2165679860
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: sprockets
62
- requirement: &2155292460 !ruby/object:Gem::Requirement
62
+ requirement: &2165678120 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,7 +67,7 @@ dependencies:
67
67
  version: '2'
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *2155292460
70
+ version_requirements: *2165678120
71
71
  description: Run Jasmine specs headlessly
72
72
  email:
73
73
  - john@coswellproductions.com
@@ -110,9 +110,11 @@ files:
110
110
  - lib/jasmine/headless/command_line.rb
111
111
  - lib/jasmine/headless/css_template.rb
112
112
  - lib/jasmine/headless/errors.rb
113
+ - lib/jasmine/headless/file_checker.rb
113
114
  - lib/jasmine/headless/files_list.rb
114
115
  - lib/jasmine/headless/js_template.rb
115
116
  - lib/jasmine/headless/jst_template.rb
117
+ - lib/jasmine/headless/nil_template.rb
116
118
  - lib/jasmine/headless/options.rb
117
119
  - lib/jasmine/headless/railtie.rb
118
120
  - lib/jasmine/headless/report.rb
@@ -179,6 +181,7 @@ files:
179
181
  - spec/jasmine/success_with_error/success_with_error_spec.js
180
182
  - spec/jasmine/with_sprockets_includes/assets/application.js.erb
181
183
  - spec/jasmine/with_sprockets_includes/assets/things/code.js
184
+ - spec/jasmine/with_sprockets_includes/assets/things/jquery.string.js
182
185
  - spec/jasmine/with_sprockets_includes/assets/things/required.js
183
186
  - spec/jasmine/with_sprockets_includes/assets/things/subcode/more_code.js
184
187
  - spec/jasmine/with_sprockets_includes/assets/things/templates/that.jst.ejs
@@ -194,9 +197,11 @@ files:
194
197
  - spec/lib/jasmine/headless/coffee_script_cache_spec.rb
195
198
  - spec/lib/jasmine/headless/coffee_template_spec.rb
196
199
  - spec/lib/jasmine/headless/css_template_spec.rb
200
+ - spec/lib/jasmine/headless/file_checker_spec.rb
197
201
  - spec/lib/jasmine/headless/files_list_spec.rb
198
202
  - spec/lib/jasmine/headless/js_template_spec.rb
199
203
  - spec/lib/jasmine/headless/jst_template_spec.rb
204
+ - spec/lib/jasmine/headless/nil_template_spec.rb
200
205
  - spec/lib/jasmine/headless/options_spec.rb
201
206
  - spec/lib/jasmine/headless/report_message/spec_spec.rb
202
207
  - spec/lib/jasmine/headless/report_spec.rb
@@ -232,12 +237,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
237
  - - ! '>='
233
238
  - !ruby/object:Gem::Version
234
239
  version: '0'
240
+ segments:
241
+ - 0
242
+ hash: 3207600471375665921
235
243
  required_rubygems_version: !ruby/object:Gem::Requirement
236
244
  none: false
237
245
  requirements:
238
246
  - - ! '>='
239
247
  - !ruby/object:Gem::Version
240
248
  version: '0'
249
+ segments:
250
+ - 0
251
+ hash: 3207600471375665921
241
252
  requirements: []
242
253
  rubyforge_project: jasmine-headless-webkit
243
254
  rubygems_version: 1.8.11
@@ -289,6 +300,7 @@ test_files:
289
300
  - spec/jasmine/success_with_error/success_with_error_spec.js
290
301
  - spec/jasmine/with_sprockets_includes/assets/application.js.erb
291
302
  - spec/jasmine/with_sprockets_includes/assets/things/code.js
303
+ - spec/jasmine/with_sprockets_includes/assets/things/jquery.string.js
292
304
  - spec/jasmine/with_sprockets_includes/assets/things/required.js
293
305
  - spec/jasmine/with_sprockets_includes/assets/things/subcode/more_code.js
294
306
  - spec/jasmine/with_sprockets_includes/assets/things/templates/that.jst.ejs
@@ -304,9 +316,11 @@ test_files:
304
316
  - spec/lib/jasmine/headless/coffee_script_cache_spec.rb
305
317
  - spec/lib/jasmine/headless/coffee_template_spec.rb
306
318
  - spec/lib/jasmine/headless/css_template_spec.rb
319
+ - spec/lib/jasmine/headless/file_checker_spec.rb
307
320
  - spec/lib/jasmine/headless/files_list_spec.rb
308
321
  - spec/lib/jasmine/headless/js_template_spec.rb
309
322
  - spec/lib/jasmine/headless/jst_template_spec.rb
323
+ - spec/lib/jasmine/headless/nil_template_spec.rb
310
324
  - spec/lib/jasmine/headless/options_spec.rb
311
325
  - spec/lib/jasmine/headless/report_message/spec_spec.rb
312
326
  - spec/lib/jasmine/headless/report_spec.rb
@@ -318,4 +332,3 @@ test_files:
318
332
  - spec/lib/jasmine/headless_spec.rb
319
333
  - spec/lib/qt/qmake_spec.rb
320
334
  - spec/spec_helper.rb
321
- has_rdoc: