jasmine 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4732e45628348b1813f0ab0cb8447712b39d4735
4
+ data.tar.gz: 86dcdc538721f1516ab60f1f90479b7dedba815e
5
+ SHA512:
6
+ metadata.gz: 97a4435aa04f9b71ef50a863ba13f61a15031e0333ee6b73edc6c50b2e3490e28ce18e4da5a7df50ba4acdcac46b8fdbb609111b5db6b31af9ce89d1506893b2
7
+ data.tar.gz: 2bad0156b8d5c7e4a975aa0d8b2d01622e1e95c604a6eba7c78f86158fc2de5f4e8139bcd67ce0693a3d1744b9dec65918e3265fe69cc95a6be9104923baa827
@@ -3,6 +3,7 @@ script: "if [ $PERFORMANCE_SPECS ];then bundle exec rake performance_specs --tra
3
3
  rvm:
4
4
  - "1.9.3"
5
5
  - "2.0.0"
6
+ - "2.1.1"
6
7
  - "jruby"
7
8
  - "rbx-2"
8
9
 
@@ -43,7 +43,7 @@ For Continuous Integration environments, add this task to the project build step
43
43
 
44
44
  This uses PhantomJS to load and run the Jasmine suite.
45
45
 
46
- Please note that PhantomJS will be auto-installed by the [phantomjs-gem][phantomjs-gem] at the first `rake jasmine:ci` run. If you have a PhantomJS somewhere on your path, it won't install.
46
+ Please note that PhantomJS will be auto-installed by the [phantomjs-gem][phantomjs-gem] at the first `rake jasmine:ci` run. If you have a matching PhantomJS version somewhere on your path, it won't install. You can disable automatic installation altogether (and use the PhantomJS on your path) via the config helper.
47
47
 
48
48
  [phantomjs-gem]: https://github.com/colszowka/phantomjs-gem#phantomjs-as-a-rubygem
49
49
 
@@ -8,4 +8,8 @@
8
8
  # config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
9
9
  #end
10
10
  #
11
-
11
+ #Example: prevent PhantomJS auto install, uses PhantomJS already on your path.
12
+ #Jasmine.configure do |config|
13
+ # config.prevent_phantomjs_auto_install = true
14
+ #end
15
+ #
@@ -8,7 +8,6 @@ jasmine_files = ['base',
8
8
  'command_line_tool',
9
9
  'page',
10
10
  'path_mapper',
11
- 'asset_bundle',
12
11
  'asset_pipeline_mapper',
13
12
  'asset_expander',
14
13
  'result',
@@ -1,18 +1,66 @@
1
1
  module Jasmine
2
2
  class AssetExpander
3
- def initialize(bundled_asset_factory)
4
- @bundled_asset_factory = bundled_asset_factory
5
- end
6
-
7
3
  def expand(src_dir, src_path)
8
4
  pathname = src_path.gsub(/^\/?assets\//, '').gsub(/\.js$/, '')
9
- bundled_asset = bundled_asset_factory.new(pathname)
10
- bundled_asset.assets.map do |asset|
5
+
6
+ asset_bundle.assets(pathname).flat_map { |asset|
11
7
  "/#{asset.gsub(/^\//, '')}?body=true"
12
- end.flatten
8
+ }
13
9
  end
14
10
 
15
11
  private
16
- attr_reader :bundled_asset_factory
12
+
13
+ UnsupportedRailsVersion = Class.new(StandardError)
14
+
15
+ def asset_bundle
16
+ return Rails3AssetBundle.new if Jasmine::Dependencies.rails3?
17
+ return Rails4AssetBundle.new if Jasmine::Dependencies.rails4?
18
+ raise UnsupportedRailsVersion, "Jasmine only supports the asset pipeline for Rails 3 or 4"
19
+ end
20
+
21
+ class Rails3AssetBundle
22
+ def assets(pathname)
23
+ context.asset_paths.asset_for(pathname, nil).to_a.map do |path|
24
+ context.asset_path(path)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def context
31
+ @context ||= get_asset_context
32
+ end
33
+
34
+ def get_asset_context
35
+ context = ::Rails.application.assets.context_class
36
+ context.extend(::Sprockets::Helpers::IsolatedHelper)
37
+ context.extend(::Sprockets::Helpers::RailsHelper)
38
+ end
39
+ end
40
+
41
+ class Rails4AssetBundle
42
+ def assets(pathname)
43
+ context.get_original_assets(pathname)
44
+ end
45
+
46
+ private
47
+
48
+ def context
49
+ @context ||= ActionView::Base.new.extend(GetOriginalAssetsHelper)
50
+ end
51
+
52
+ module GetOriginalAssetsHelper
53
+ def get_original_assets(pathname)
54
+ assets_environment.find_asset(pathname).to_a.map do |processed_asset|
55
+ case processed_asset.content_type
56
+ when "text/css"
57
+ path_to_stylesheet(processed_asset.logical_path)
58
+ when "application/javascript"
59
+ path_to_javascript(processed_asset.logical_path)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
17
65
  end
18
66
  end
@@ -32,6 +32,9 @@ module Jasmine
32
32
  @config.add_rack_path(spec_path, lambda {
33
33
  sprockets_spec_env = Sprockets::Environment.new
34
34
  sprockets_spec_env.append_path @config.spec_dir
35
+ Rails.application.assets.paths.each do |path|
36
+ sprockets_spec_env.append_path(path)
37
+ end
35
38
  sprockets_spec_env
36
39
  })
37
40
  else
@@ -50,7 +53,7 @@ module Jasmine
50
53
 
51
54
  if Jasmine::Dependencies.use_asset_pipeline?
52
55
  @config.add_path_mapper(lambda { |config|
53
- asset_expander = Jasmine::AssetExpander.new(Jasmine::AssetBundle.factory)
56
+ asset_expander = Jasmine::AssetExpander.new
54
57
  Jasmine::AssetPipelineMapper.new(config, asset_expander.method(:expand))
55
58
  })
56
59
  # In order to have asset helpers like asset_path and image_path, we need to require 'action_view/base'. This
@@ -70,7 +73,7 @@ module Jasmine
70
73
  })
71
74
  end
72
75
 
73
- @config.runner = lambda { |formatter, jasmine_server_url| Jasmine::Runners::PhantomJs.new(formatter, jasmine_server_url, 50) }
76
+ @config.runner = lambda { |formatter, jasmine_server_url| Jasmine::Runners::PhantomJs.new(formatter, jasmine_server_url, 50, @config.prevent_phantom_js_auto_install) }
74
77
  end
75
78
 
76
79
  def self.config
@@ -9,10 +9,12 @@ module Jasmine
9
9
  attr_accessor :spec_format
10
10
  attr_accessor :runner
11
11
  attr_accessor :rack_options
12
+ attr_accessor :prevent_phantom_js_auto_install
13
+ attr_reader :rack_apps
12
14
 
13
15
  def initialize()
14
16
  @rack_paths = {}
15
- @apps = []
17
+ @rack_apps = []
16
18
  @path_mappers = []
17
19
  @jasmine_css_files = lambda { [] }
18
20
  @css_files = lambda { [] }
@@ -50,12 +52,8 @@ module Jasmine
50
52
  @rack_paths[path] = rack_app_lambda
51
53
  end
52
54
 
53
- def rack_apps
54
- [] + @apps
55
- end
56
-
57
55
  def add_rack_app(app, *args, &block)
58
- @apps << {
56
+ @rack_apps << {
59
57
  :app => app,
60
58
  :args => args,
61
59
  :block => block
@@ -6,19 +6,11 @@ module Jasmine
6
6
  end
7
7
 
8
8
  def format(results)
9
- go(:format, results)
9
+ @formatters.each { |formatter| formatter.format(results) }
10
10
  end
11
11
 
12
12
  def done
13
- go(:done)
14
- end
15
-
16
- private
17
-
18
- def go(method, *args)
19
- (@formatters || []).each do |formatter|
20
- formatter.public_send(method, *args)
21
- end
13
+ @formatters.each(&:done)
22
14
  end
23
15
  end
24
16
  end
@@ -3,14 +3,15 @@ require 'phantomjs'
3
3
  module Jasmine
4
4
  module Runners
5
5
  class PhantomJs
6
- def initialize(formatter, jasmine_server_url, result_batch_size)
6
+ def initialize(formatter, jasmine_server_url, result_batch_size, prevent_phantom_js_auto_install)
7
7
  @formatter = formatter
8
8
  @jasmine_server_url = jasmine_server_url
9
9
  @result_batch_size = result_batch_size
10
+ @prevent_phantom_js_auto_install = prevent_phantom_js_auto_install
10
11
  end
11
12
 
12
13
  def run
13
- command = "#{Phantomjs.path} '#{File.join(File.dirname(__FILE__), 'phantom_jasmine_run.js')}' #{jasmine_server_url} #{result_batch_size}"
14
+ command = "#{phantom_js_path} '#{File.join(File.dirname(__FILE__), 'phantom_jasmine_run.js')}' #{jasmine_server_url} #{result_batch_size}"
14
15
  IO.popen(command) do |output|
15
16
  output.each do |line|
16
17
  if line =~ /^jasmine_result/
@@ -24,12 +25,16 @@ module Jasmine
24
25
  formatter.done
25
26
  end
26
27
 
28
+ def phantom_js_path
29
+ prevent_phantom_js_auto_install ? 'phantomjs' : Phantomjs.path
30
+ end
31
+
27
32
  def boot_js
28
33
  File.expand_path('phantom_boot.js', File.dirname(__FILE__))
29
34
  end
30
35
 
31
36
  private
32
- attr_reader :formatter, :jasmine_server_url, :result_batch_size
37
+ attr_reader :formatter, :jasmine_server_url, :result_batch_size, :prevent_phantom_js_auto_install
33
38
  end
34
39
  end
35
40
  end
@@ -1,3 +1,19 @@
1
+ if Rake.application.tasks.any? {|t| t.name == 'jasmine/ci' }
2
+ message = <<-EOF
3
+
4
+ WARNING
5
+ Detected that jasmine rake tasks have been loaded twice.
6
+ This will cause the 'rake jasmine:ci' and 'rake jasmine' tasks to fail.
7
+
8
+ To fix this problem, you should ensure that you only load 'jasmine/tasks/jasmine.rake'
9
+ once. This should be done for you automatically if you installed jasmine's rake tasks
10
+ with either 'jasmine init' or 'rails g jasmine:install'.
11
+
12
+
13
+ EOF
14
+ raise Exception.new(message)
15
+ end
16
+
1
17
  namespace :jasmine do
2
18
  task :configure do
3
19
  require 'jasmine/config'
@@ -1,3 +1,3 @@
1
1
  module Jasmine
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -141,6 +141,14 @@ describe Jasmine::Configuration do
141
141
  end
142
142
  end
143
143
 
144
+ describe 'prevent phantomjs auto install' do
145
+ it 'returns value if set' do
146
+ config = Jasmine::Configuration.new()
147
+ config.prevent_phantom_js_auto_install = true
148
+ config.prevent_phantom_js_auto_install.should == true
149
+ end
150
+ end
151
+
144
152
  describe 'jasmine ports' do
145
153
  it 'returns new CI port and caches return value' do
146
154
  config = Jasmine::Configuration.new()
@@ -37,6 +37,7 @@ if Jasmine::Dependencies.rails_available?
37
37
  f.puts "gem 'rubysl', :platform => :rbx"
38
38
  f.puts "gem 'racc', :platform => :rbx"
39
39
  f.puts "gem 'thin'" unless RUBY_PLATFORM == 'java'
40
+ f.puts "gem 'angularjs-rails'"
40
41
  f.flush
41
42
  }
42
43
 
@@ -117,6 +118,11 @@ if Jasmine::Dependencies.rails_available?
117
118
  f.flush
118
119
  }
119
120
 
121
+ open('spec/javascripts/helpers/angular_helper.js', 'w') { |f|
122
+ f.puts "//= require angular-mocks"
123
+ f.flush
124
+ }
125
+
120
126
  css_yaml = custom_jasmine_config('css') do |jasmine_config|
121
127
  jasmine_config['src_files'] = %w[assets/application.js http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js]
122
128
  jasmine_config['stylesheets'] = ['assets/application.css']
@@ -141,7 +147,11 @@ if Jasmine::Dependencies.rails_available?
141
147
  output.should match(%r{script src.*/assets/jasmine_examples/Player\.js})
142
148
  output.should match(%r{script src=['"]http://ajax\.googleapis\.com/ajax/libs/jquery/1\.11\.0/jquery\.min\.js})
143
149
  output.should match(%r{script src.*/assets/jasmine_examples/Song\.js})
150
+ output.should match(%r{script src.*angular_helper\.js})
144
151
  output.should match(%r{<link rel=.stylesheet.*?href=./assets/foo\.css\?.*?>})
152
+
153
+ output = Net::HTTP.get(URI.parse('http://localhost:8888/__spec__/helpers/angular_helper.js'))
154
+ output.should match(/angular\.mock/)
145
155
  ensure
146
156
  Process.kill(:SIGINT, pid)
147
157
  begin
@@ -6,9 +6,17 @@ describe Jasmine::Formatters::Multi do
6
6
  formatter2 = double(:formatter2)
7
7
  multi = Jasmine::Formatters::Multi.new([formatter1, formatter2])
8
8
 
9
- formatter1.should_receive(:format)
10
- formatter2.should_receive(:format)
11
- multi.format(nil)
9
+ results1 = double(:results1)
10
+
11
+ formatter1.should_receive(:format).with(results1)
12
+ formatter2.should_receive(:format).with(results1)
13
+ multi.format(results1)
14
+
15
+ results2 = double(:results1)
16
+
17
+ formatter1.should_receive(:format).with(results2)
18
+ formatter2.should_receive(:format).with(results2)
19
+ multi.format(results2)
12
20
 
13
21
  formatter1.should_receive(:done)
14
22
  formatter2.should_receive(:done)
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
5
- prerelease:
4
+ version: 2.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Rajan Agaskar
@@ -11,92 +10,81 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2014-04-17 00:00:00.000000000 Z
13
+ date: 2014-05-23 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rails
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - '>='
22
20
  - !ruby/object:Gem::Version
23
21
  version: '4'
24
22
  type: :development
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
- - - ! '>='
26
+ - - '>='
30
27
  - !ruby/object:Gem::Version
31
28
  version: '4'
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: rack-test
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
- - - ! '>='
33
+ - - '>='
38
34
  - !ruby/object:Gem::Version
39
35
  version: '0'
40
36
  type: :development
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
- - - ! '>='
40
+ - - '>='
46
41
  - !ruby/object:Gem::Version
47
42
  version: '0'
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: multi_json
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
- - - ! '>='
47
+ - - '>='
54
48
  - !ruby/object:Gem::Version
55
49
  version: '0'
56
50
  type: :development
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
- - - ! '>='
54
+ - - '>='
62
55
  - !ruby/object:Gem::Version
63
56
  version: '0'
64
57
  - !ruby/object:Gem::Dependency
65
58
  name: rspec
66
59
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
60
  requirements:
69
- - - ! '>='
61
+ - - '>='
70
62
  - !ruby/object:Gem::Version
71
63
  version: 2.5.0
72
64
  type: :development
73
65
  prerelease: false
74
66
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
67
  requirements:
77
- - - ! '>='
68
+ - - '>='
78
69
  - !ruby/object:Gem::Version
79
70
  version: 2.5.0
80
71
  - !ruby/object:Gem::Dependency
81
72
  name: nokogiri
82
73
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
74
  requirements:
85
- - - ! '>='
75
+ - - '>='
86
76
  - !ruby/object:Gem::Version
87
77
  version: '0'
88
78
  type: :development
89
79
  prerelease: false
90
80
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
81
  requirements:
93
- - - ! '>='
82
+ - - '>='
94
83
  - !ruby/object:Gem::Version
95
84
  version: '0'
96
85
  - !ruby/object:Gem::Dependency
97
86
  name: jasmine-core
98
87
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
88
  requirements:
101
89
  - - ~>
102
90
  - !ruby/object:Gem::Version
@@ -104,7 +92,6 @@ dependencies:
104
92
  type: :runtime
105
93
  prerelease: false
106
94
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
95
  requirements:
109
96
  - - ~>
110
97
  - !ruby/object:Gem::Version
@@ -112,49 +99,43 @@ dependencies:
112
99
  - !ruby/object:Gem::Dependency
113
100
  name: rack
114
101
  requirement: !ruby/object:Gem::Requirement
115
- none: false
116
102
  requirements:
117
- - - ! '>='
103
+ - - '>='
118
104
  - !ruby/object:Gem::Version
119
105
  version: 1.2.1
120
106
  type: :runtime
121
107
  prerelease: false
122
108
  version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
109
  requirements:
125
- - - ! '>='
110
+ - - '>='
126
111
  - !ruby/object:Gem::Version
127
112
  version: 1.2.1
128
113
  - !ruby/object:Gem::Dependency
129
114
  name: rake
130
115
  requirement: !ruby/object:Gem::Requirement
131
- none: false
132
116
  requirements:
133
- - - ! '>='
117
+ - - '>='
134
118
  - !ruby/object:Gem::Version
135
119
  version: '0'
136
120
  type: :runtime
137
121
  prerelease: false
138
122
  version_requirements: !ruby/object:Gem::Requirement
139
- none: false
140
123
  requirements:
141
- - - ! '>='
124
+ - - '>='
142
125
  - !ruby/object:Gem::Version
143
126
  version: '0'
144
127
  - !ruby/object:Gem::Dependency
145
128
  name: phantomjs
146
129
  requirement: !ruby/object:Gem::Requirement
147
- none: false
148
130
  requirements:
149
- - - ! '>='
131
+ - - '>='
150
132
  - !ruby/object:Gem::Version
151
133
  version: '0'
152
134
  type: :runtime
153
135
  prerelease: false
154
136
  version_requirements: !ruby/object:Gem::Requirement
155
- none: false
156
137
  requirements:
157
- - - ! '>='
138
+ - - '>='
158
139
  - !ruby/object:Gem::Version
159
140
  version: '0'
160
141
  description: Test your JavaScript without any framework dependencies, in any environment,
@@ -189,7 +170,6 @@ files:
189
170
  - lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb
190
171
  - lib/jasmine.rb
191
172
  - lib/jasmine/application.rb
192
- - lib/jasmine/asset_bundle.rb
193
173
  - lib/jasmine/asset_expander.rb
194
174
  - lib/jasmine/asset_pipeline_mapper.rb
195
175
  - lib/jasmine/base.rb
@@ -251,34 +231,27 @@ files:
251
231
  homepage: http://pivotal.github.com/jasmine/
252
232
  licenses:
253
233
  - MIT
234
+ metadata: {}
254
235
  post_install_message:
255
236
  rdoc_options:
256
237
  - --charset=UTF-8
257
238
  require_paths:
258
239
  - lib
259
240
  required_ruby_version: !ruby/object:Gem::Requirement
260
- none: false
261
241
  requirements:
262
- - - ! '>='
242
+ - - '>='
263
243
  - !ruby/object:Gem::Version
264
244
  version: '0'
265
- segments:
266
- - 0
267
- hash: 1868816023203409385
268
245
  required_rubygems_version: !ruby/object:Gem::Requirement
269
- none: false
270
246
  requirements:
271
- - - ! '>='
247
+ - - '>='
272
248
  - !ruby/object:Gem::Version
273
249
  version: '0'
274
- segments:
275
- - 0
276
- hash: 1868816023203409385
277
250
  requirements: []
278
251
  rubyforge_project:
279
- rubygems_version: 1.8.23
252
+ rubygems_version: 2.2.2
280
253
  signing_key:
281
- specification_version: 3
254
+ specification_version: 4
282
255
  summary: JavaScript BDD framework
283
256
  test_files:
284
257
  - spec/application_integration_spec.rb
@@ -1,68 +0,0 @@
1
- module Jasmine
2
-
3
- class AssetBundle
4
- def self.factory
5
- if Jasmine::Dependencies.rails3?
6
- return Rails3AssetBundle
7
- end
8
- if Jasmine::Dependencies.rails4?
9
- return Rails4AssetBundle
10
- end
11
- end
12
-
13
- class RailsAssetBundle
14
- def initialize(pathname)
15
- @pathname = pathname
16
- end
17
-
18
- private
19
-
20
- attr_reader :pathname
21
- end
22
-
23
- class Rails3AssetBundle < RailsAssetBundle
24
-
25
- def assets
26
- context = get_asset_context
27
- context.asset_paths.asset_for(pathname, nil).to_a.map do |path|
28
- context.asset_path(path)
29
- end
30
- end
31
-
32
- private
33
- def get_asset_context
34
- context = ::Rails.application.assets.context_class
35
- context.extend(::Sprockets::Helpers::IsolatedHelper)
36
- context.extend(::Sprockets::Helpers::RailsHelper)
37
- end
38
- end
39
-
40
- class Rails4AssetBundle < RailsAssetBundle
41
-
42
- def assets
43
- context.get_original_assets(pathname)
44
- end
45
-
46
- private
47
- def context
48
- return @context if @context
49
- @context = ActionView::Base.new
50
- @context.instance_eval do
51
- def get_original_assets(pathname)
52
- assets_environment.find_asset(pathname).to_a.map do |processed_asset|
53
- case processed_asset.content_type
54
- when "text/css"
55
- path_to_stylesheet(processed_asset.logical_path)
56
- when "application/javascript"
57
- path_to_javascript(processed_asset.logical_path)
58
- end
59
- end
60
- end
61
- end
62
- @context
63
-
64
- end
65
- end
66
- end
67
-
68
- end