jasmine-headless-webkit 0.9.0.rc1 → 0.9.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ _site/
16
16
  jhw.*.html
17
17
  coverage/
18
18
  tmp/
19
+ cache dir/
data/Gemfile CHANGED
@@ -15,7 +15,6 @@ gem 'guard-cucumber'
15
15
  require 'rbconfig'
16
16
  case RbConfig::CONFIG['host_os']
17
17
  when /darwin/
18
- gem 'rb-fsevent'
19
18
  when /linux/
20
19
  gem 'libnotify'
21
20
  end
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ require 'jasmine/headless/task'
14
14
 
15
15
  Jasmine::Headless::Task.new
16
16
 
17
- PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3}
17
+ PLATFORMS = %w{1.9.2 1.9.3}
18
18
 
19
19
  def rvm_bundle(command = '')
20
20
  Bundler.with_clean_env do
@@ -1,7 +1,6 @@
1
1
  TEMPLATE = app
2
2
  CONFIG -= app_bundle
3
3
  QMAKE_INFO_PLIST = Info.plist
4
- QMAKESPEC = macx-g++
5
4
  QT += network webkit
6
5
 
7
6
  SOURCES = Page.cpp Runner.cpp
@@ -20,9 +20,11 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_runtime_dependency 'jasmine-core', '~> 1.1'
23
+ s.add_runtime_dependency 'jasmine-core'
24
24
  s.add_runtime_dependency 'coffee-script'
25
25
  s.add_runtime_dependency 'rainbow'
26
- s.add_runtime_dependency 'multi_json'
27
- s.add_runtime_dependency 'sprockets', '~> 2'
26
+ s.add_runtime_dependency 'multi_json', '>= 1.2.0'
27
+ s.add_runtime_dependency 'sprockets'
28
+ s.add_runtime_dependency 'sprockets-vendor_gems'
28
29
  end
30
+
@@ -54,7 +54,11 @@ module Jasmine::Headless
54
54
  end
55
55
 
56
56
  def cache_file
57
- @cache_file ||= File.expand_path(File.join(self.class.cache_dir, self.class.cache_type, file)) + '.js'
57
+ @cache_file ||= File.expand_path(relative_cache_file) + '.js'
58
+ end
59
+
60
+ def relative_cache_file
61
+ File.join(self.class.cache_dir, self.class.cache_type, file.gsub(Dir.pwd + '/', ''))
58
62
  end
59
63
 
60
64
  def fresh?
@@ -4,6 +4,7 @@ require 'multi_json'
4
4
  require 'set'
5
5
  require 'sprockets'
6
6
  require 'sprockets/engines'
7
+ require 'sprockets-vendor_gems'
7
8
 
8
9
  module Jasmine::Headless
9
10
  class FilesList
@@ -11,33 +12,12 @@ module Jasmine::Headless
11
12
 
12
13
  class << self
13
14
  def asset_paths
14
- return @asset_paths if @asset_paths
15
-
16
- require 'rubygems'
17
-
18
- raise StandardError.new("A newer version of Rubygems is required to use vendored assets. Please upgrade.") if !Gem::Specification.respond_to?(:each)
19
-
20
- @asset_paths = []
21
-
22
- Gem::Specification.each { |gemspec| @asset_paths += get_paths_from_gemspec(gemspec) }
23
-
24
- @asset_paths
25
- end
26
-
27
- def get_paths_from_gemspec(gemspec)
28
- %w{vendor lib app}.collect do |dir|
29
- path = File.join(gemspec.gem_dir, dir, "assets/javascripts")
30
-
31
- if File.directory?(path) && !@asset_paths.include?(path)
32
- path
33
- else
34
- nil
35
- end
36
- end.compact
15
+ @asset_paths ||= Sprockets.find_gem_vendor_paths(:for => 'javascripts')
37
16
  end
38
17
 
39
18
  def reset!
40
19
  @asset_paths = nil
20
+ @registered_engines = {}
41
21
 
42
22
  # register haml-sprockets and handlebars_assets if it's available...
43
23
  %w{haml-sprockets handlebars_assets}.each do |library|
@@ -56,16 +36,20 @@ module Jasmine::Headless
56
36
  end
57
37
  end
58
38
 
59
- # ...and unregister ones we don't want/need
60
- Sprockets.instance_eval do
61
- EXCLUDED_FORMATS.each do |extension|
62
- register_engine ".#{extension}", Jasmine::Headless::NilTemplate
63
- end
39
+ @sprockets_environment = nil
40
+ end
41
+
42
+ def registered_engines
43
+ @registered_engines ||= {}
44
+ end
45
+
46
+ def register_engine(file_extension, template_class)
47
+ registered_engines[file_extension] = template_class
48
+ end
64
49
 
65
- register_engine '.coffee', Jasmine::Headless::CoffeeTemplate
66
- register_engine '.js', Jasmine::Headless::JSTemplate
67
- register_engine '.css', Jasmine::Headless::CSSTemplate
68
- register_engine '.jst', Jasmine::Headless::JSTTemplate
50
+ def register_engines!
51
+ registered_engines.each do |file_extension, template_class|
52
+ Sprockets.register_engine file_extension, template_class
69
53
  end
70
54
  end
71
55
 
@@ -95,11 +79,21 @@ module Jasmine::Headless
95
79
  @required_files = UniqueAssetList.new
96
80
  @potential_files_to_filter = []
97
81
 
82
+ register_engines!
83
+
98
84
  load_initial_assets
99
85
 
100
86
  use_config if config?
101
87
  end
102
88
 
89
+ def register_engines!
90
+ begin
91
+ require spec_helper
92
+ rescue LoadError
93
+ end
94
+ self.class.register_engines!
95
+ end
96
+
103
97
  def load_initial_assets
104
98
  self.class.default_files.each do |file|
105
99
  begin
@@ -148,6 +142,19 @@ module Jasmine::Headless
148
142
  search_paths.each { |path| @sprockets_environment.append_path(path) }
149
143
 
150
144
  @sprockets_environment.unregister_postprocessor('application/javascript', Sprockets::SafetyColons)
145
+
146
+ # ...and unregister ones we don't want/need
147
+ @sprockets_environment.instance_eval do
148
+ EXCLUDED_FORMATS.each do |extension|
149
+ register_engine ".#{extension}", Jasmine::Headless::NilTemplate
150
+ end
151
+
152
+ register_engine '.coffee', Jasmine::Headless::CoffeeTemplate
153
+ register_engine '.js', Jasmine::Headless::JSTemplate
154
+ register_engine '.css', Jasmine::Headless::CSSTemplate
155
+ register_engine '.jst', Jasmine::Headless::JSTTemplate
156
+ end
157
+
151
158
  @sprockets_environment
152
159
  end
153
160
 
@@ -248,7 +255,8 @@ module Jasmine::Headless
248
255
  end
249
256
 
250
257
  def expanded_dir(path)
251
- Dir[path].find_all { |file|
258
+ file_list = Dir.glob(path).sort
259
+ file_list.find_all { |file|
252
260
  file[extension_filter] && !alert_if_bad_format?(file)
253
261
  }.collect {
254
262
  |file| File.expand_path(file)
@@ -308,5 +316,17 @@ module Jasmine::Headless
308
316
  end
309
317
  end
310
318
  end
319
+
320
+ def spec_helper
321
+ File.join(spec_dir, "helpers", "spec_helper")
322
+ end
323
+ end
324
+ end
325
+
326
+ module Jasmine::Headless
327
+ extend self
328
+
329
+ def register_engine(file_extension, template_class)
330
+ Jasmine::Headless::FilesList.register_engine(file_extension, template_class)
311
331
  end
312
332
  end
@@ -33,11 +33,11 @@ module Jasmine::Headless
33
33
  end
34
34
 
35
35
  def serialize(data)
36
- MultiJson.encode(data)
36
+ MultiJson.dump(data)
37
37
  end
38
38
 
39
39
  def unserialize(data)
40
- MultiJson.decode(data)
40
+ MultiJson.load(data)
41
41
  end
42
42
  end
43
43
  end
@@ -1,5 +1,5 @@
1
1
  module Jasmine
2
2
  module Headless
3
- VERSION = "0.9.0.rc1"
3
+ VERSION = "0.9.0.rc.2"
4
4
  end
5
5
  end
@@ -6,7 +6,7 @@
6
6
  <script type="text/javascript" src="<%= Jasmine::Headless.root.join('vendor/assets/javascripts/prolog.js') %>"></script>
7
7
  <%= files.join("\n") %>
8
8
  <script type="text/javascript">
9
- if (window.JHW) { HeadlessReporterResult.specLineNumbers = <%= MultiJson.encode(spec_lines) %>; }
9
+ if (window.JHW) { HeadlessReporterResult.specLineNumbers = <%= MultiJson.dump(spec_lines) %>; }
10
10
  </script>
11
11
  </head>
12
12
  <body>
@@ -35,14 +35,18 @@
35
35
  }
36
36
  }
37
37
 
38
+ var location = window.location.href;
39
+
38
40
  var getLastModified = function(callback) {
39
41
  var http = new XMLHttpRequest();
40
42
  var header;
41
43
 
42
- http.open('HEAD', window.location.href, false);
44
+ http.open('HEAD', location, true);
43
45
 
44
46
  http.onreadystatechange = function() {
45
- callback(http.getResponseHeader('Last-Modified'));
47
+ if(http.readyState === http.DONE) {
48
+ callback(http.getResponseHeader('Last-Modified'));
49
+ }
46
50
  };
47
51
  http.send();
48
52
  }
@@ -95,5 +95,28 @@ describe Jasmine::Headless::CacheableAction do
95
95
  end
96
96
  end
97
97
  end
98
+
99
+ describe '#relative_cache_file' do
100
+ context 'file is an absolute windows file' do
101
+ let(:current_path) { 'C:/path' }
102
+ let(:filename) { "file.coffee" }
103
+ let(:windows_path) { File.join(current_path, filename) }
104
+ let(:cache_dir) { 'cache dir' }
105
+ let(:cache_type) { 'cache type' }
106
+
107
+ before do
108
+ cache_object.stubs(:file).returns(windows_path)
109
+
110
+ described_class.stubs(:cache_dir).returns(cache_dir)
111
+ described_class.stubs(:cache_type).returns(cache_type)
112
+
113
+ Dir.stubs(:pwd).returns(current_path)
114
+ end
115
+
116
+ subject { cache_object.relative_cache_file }
117
+
118
+ it { should == File.join(cache_dir, cache_type, filename) }
119
+ end
120
+ end
98
121
  end
99
122
 
@@ -5,50 +5,6 @@ require 'coffee-script'
5
5
  describe Jasmine::Headless::FilesList do
6
6
  let(:files_list) { described_class.new }
7
7
 
8
- describe '.get_paths_from_gemspec' do
9
- include FakeFS::SpecHelpers
10
-
11
- let(:gem_dir) { "dir" }
12
- let(:gemspec) { stub(:gem_dir => gem_dir) }
13
-
14
- let(:paths) do
15
- %w{vendor lib app}.collect do |dir|
16
- File.join(gem_dir, dir, 'assets/javascripts')
17
- end
18
- end
19
-
20
- before do
21
- paths.each { |path| FileUtils.mkdir_p path }
22
-
23
- described_class.instance_variable_set(:@asset_paths, [])
24
- end
25
-
26
- subject { described_class.get_paths_from_gemspec(gemspec) }
27
-
28
- it { should =~ paths }
29
- end
30
-
31
- describe '.asset_paths' do
32
- include FakeFS::SpecHelpers
33
-
34
- let(:dir_one) { 'dir_one' }
35
- let(:dir_two) { 'dir_two' }
36
-
37
- let(:gem_one) { stub(:gem_dir => dir_one) }
38
- let(:gem_two) { stub(:gem_dir => dir_two) }
39
-
40
- before do
41
- described_class.instance_variable_set(:@asset_paths, nil)
42
- FileUtils.mkdir_p File.join(dir_two, 'vendor/assets/javascripts')
43
-
44
- Gem::Specification.stubs(:_all).returns([gem_one, gem_two])
45
- end
46
-
47
- it 'should return all matching gems with vendor/assets/javascripts directories' do
48
- described_class.asset_paths.should == [ File.join(dir_two, 'vendor/assets/javascripts') ]
49
- end
50
- end
51
-
52
8
  describe '#initialize' do
53
9
  before do
54
10
  described_class.any_instance.stubs(:load_initial_assets)
@@ -218,6 +174,21 @@ describe Jasmine::Headless::FilesList do
218
174
  files_list.files.any? { |file| file['.erb'] }.should be_false
219
175
  end
220
176
  end
177
+
178
+ describe "#register_engine!" do
179
+
180
+ before(:each) do
181
+ Jasmine::Headless::FilesList.reset!
182
+ end
183
+
184
+ it "should register code added via configure blocks" do
185
+ template_class = mock()
186
+ described_class.register_engine ".foo", template_class
187
+ Sprockets.expects(:register_engine).with(".foo", template_class)
188
+ described_class.new
189
+ end
190
+
191
+ end
221
192
  end
222
193
  end
223
194
 
@@ -11,16 +11,16 @@ window.Intense = {
11
11
  methods:
12
12
  foreground: (color) ->
13
13
  if Intense.useColors
14
- "\033[3#{Intense.colors[color]}m#{this}\033[0m"
14
+ '\x1b' + "[3#{Intense.colors[color]}m#{this}" + '\x1b' + "[0m"
15
15
  else
16
16
  this
17
17
  bright: ->
18
18
  if Intense.useColors
19
- "\033[1m#{this}\033[0m"
19
+ '\x1b' + "[1m#{this}" + '\x1b' + "[0m"
20
20
  else
21
21
  this
22
22
  useColors: true
23
- moveBack: (count = 1) -> "\033[#{count}D"
23
+ moveBack: (count = 1) -> '\x1b' + "[#{count}D"
24
24
  }
25
25
 
26
26
  for method, code of Intense.methods
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.9.0.rc1
4
+ version: 0.9.0.rc.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -11,22 +11,27 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-01-27 00:00:00.000000000Z
14
+ date: 2012-04-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: jasmine-core
18
- requirement: &2173103220 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
- - - ~>
21
+ - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
- version: '1.1'
23
+ version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2173103220
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: coffee-script
29
- requirement: &2173102780 !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
30
35
  none: false
31
36
  requirements:
32
37
  - - ! '>='
@@ -34,10 +39,15 @@ dependencies:
34
39
  version: '0'
35
40
  type: :runtime
36
41
  prerelease: false
37
- version_requirements: *2173102780
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: rainbow
40
- requirement: &2173102280 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
41
51
  none: false
42
52
  requirements:
43
53
  - - ! '>='
@@ -45,29 +55,60 @@ dependencies:
45
55
  version: '0'
46
56
  type: :runtime
47
57
  prerelease: false
48
- version_requirements: *2173102280
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
49
64
  - !ruby/object:Gem::Dependency
50
65
  name: multi_json
51
- requirement: &2173101720 !ruby/object:Gem::Requirement
66
+ requirement: !ruby/object:Gem::Requirement
52
67
  none: false
53
68
  requirements:
54
69
  - - ! '>='
55
70
  - !ruby/object:Gem::Version
56
- version: '0'
71
+ version: 1.2.0
57
72
  type: :runtime
58
73
  prerelease: false
59
- version_requirements: *2173101720
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: 1.2.0
60
80
  - !ruby/object:Gem::Dependency
61
81
  name: sprockets
62
- requirement: &2173101000 !ruby/object:Gem::Requirement
82
+ requirement: !ruby/object:Gem::Requirement
63
83
  none: false
64
84
  requirements:
65
- - - ~>
85
+ - - ! '>='
66
86
  - !ruby/object:Gem::Version
67
- version: '2'
87
+ version: '0'
68
88
  type: :runtime
69
89
  prerelease: false
70
- version_requirements: *2173101000
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: sprockets-vendor_gems
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
71
112
  description: Run Jasmine specs headlessly
72
113
  email:
73
114
  - john@coswellproductions.com
@@ -305,7 +346,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
305
346
  version: '0'
306
347
  segments:
307
348
  - 0
308
- hash: -1533041134193199304
349
+ hash: 4192446100369998967
309
350
  required_rubygems_version: !ruby/object:Gem::Requirement
310
351
  none: false
311
352
  requirements:
@@ -314,7 +355,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
355
  version: 1.3.1
315
356
  requirements: []
316
357
  rubyforge_project: jasmine-headless-webkit
317
- rubygems_version: 1.8.11
358
+ rubygems_version: 1.8.23
318
359
  signing_key:
319
360
  specification_version: 3
320
361
  summary: Run Jasmine specs headlessly in a WebKit browser