jasmine 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2010 Pivotal Labs
1
+ Copyright (c) 2008-2012 Pivotal Labs
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -46,7 +46,7 @@ For Continuous Integration environments, add this task to the project build step
46
46
 
47
47
  `rake jasmine:ci`
48
48
 
49
- This uses Selenium to launch a browser and run the Jasmine suite. Then it uses RSpec to extract the results from the Jasmine reporter and write them to your build log.
49
+ This uses Selenium to launch a browser and run the Jasmine suite. Then it uses RSpec to extract the results from the Jasmine reporter and write them to your build log. The browser used by selenium can be changed by setting the JASMINE_BROWSER environment variable (this might require additional webdriver dependencies).
50
50
 
51
51
  ## Configuration
52
52
 
@@ -11,7 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.summary = %q{JavaScript BDD framework}
12
12
  s.description = %q{Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax.}
13
13
  s.email = %q{jasmine-js@googlegroups.com}
14
- s.homepage = "http://pivotal.github.com/jasmine"
14
+ s.homepage = "http://pivotal.github.com/jasmine/"
15
+ s.license = "MIT"
15
16
 
16
17
  s.files = `git ls-files`.split("\n") | Dir.glob('jasmine/**/*')
17
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -66,7 +67,7 @@ Gem::Specification.new do |s|
66
67
  s.add_development_dependency 'json_pure'
67
68
  s.add_development_dependency 'nokogiri'
68
69
 
69
- s.add_dependency 'jasmine-core', ">= 1.2.0"
70
+ s.add_dependency 'jasmine-core', ">= 1.3.0"
70
71
  s.add_dependency 'rack', '~> 1.0'
71
72
  s.add_dependency 'rspec', '>= 1.3.1'
72
73
  s.add_dependency 'selenium-webdriver', '>= 0.1.3'
@@ -9,6 +9,7 @@ jasmine_files = ['base',
9
9
  'command_line_tool',
10
10
  'page',
11
11
  'asset_pipeline_mapper',
12
+ 'sprockets_mapper',
12
13
  'results_processor',
13
14
  'results',
14
15
  File.join('runners', 'http')]
@@ -11,11 +11,19 @@ module Jasmine
11
11
  class Application
12
12
  def self.app(config = Jasmine::RunnerConfig.new)
13
13
  page = Jasmine::Page.new(config)
14
+ if Jasmine::Dependencies.rails_3_asset_pipeline?
15
+ config.src_mapper = Jasmine::AssetPipelineMapper.new
16
+ end
14
17
  Rack::Builder.app do
15
18
  use Rack::Head
16
19
  use Rack::Jasmine::CacheControl
17
20
  if Jasmine::Dependencies.rails_3_asset_pipeline?
18
21
  map('/assets') do
22
+ #load the Sprockets asset helpers
23
+ Rails.application.assets.context_class.instance_eval do
24
+ include ::Sprockets::Helpers::IsolatedHelper
25
+ include ::Sprockets::Helpers::RailsHelper
26
+ end
19
27
  run Rails.application.assets
20
28
  end
21
29
  end
@@ -6,13 +6,12 @@ class Jasmine::AssetPipelineMapper
6
6
  context.extend(::Sprockets::Helpers::RailsHelper)
7
7
  end
8
8
 
9
- def initialize(src_files, context = Jasmine::AssetPipelineMapper.context)
10
- @src_files = src_files
9
+ def initialize(context = Jasmine::AssetPipelineMapper.context)
11
10
  @context = context
12
11
  end
13
12
 
14
- def files
15
- @src_files.map do |src_file|
13
+ def files(src_files)
14
+ src_files.map do |src_file|
16
15
  filename = src_file.gsub(/^assets\//, '').gsub(/\.js$/, '')
17
16
  @context.asset_paths.asset_for(filename, 'js').to_a.map { |p| @context.asset_path(p).gsub(/^\//, '') + "?body=true" }
18
17
  end.flatten.uniq
@@ -1,7 +1,10 @@
1
1
  module Jasmine
2
2
  class Config
3
+ attr_accessor :src_mapper
4
+
3
5
  require 'yaml'
4
6
  require 'erb'
7
+ require 'json'
5
8
 
6
9
  def match_files(dir, patterns)
7
10
  dir = File.expand_path(dir)
@@ -75,12 +78,12 @@ module Jasmine
75
78
  end
76
79
 
77
80
  def src_files
78
- if simple_config['src_files'] && Jasmine::Dependencies.rails_3_asset_pipeline?
79
- Jasmine::AssetPipelineMapper.new(simple_config['src_files']).files
80
- elsif simple_config['src_files']
81
- match_files(src_dir, simple_config['src_files'])
81
+ return [] unless simple_config['src_files']
82
+
83
+ if self.src_mapper
84
+ self.src_mapper.files(simple_config['src_files'])
82
85
  else
83
- []
86
+ match_files(src_dir, simple_config['src_files'])
84
87
  end
85
88
  end
86
89
 
@@ -100,6 +103,14 @@ module Jasmine
100
103
  end
101
104
  end
102
105
 
106
+ def jasmine_host
107
+ ENV["JASMINE_HOST"] || 'http://localhost'
108
+ end
109
+
110
+ def port
111
+ @port ||= ENV["JASMINE_PORT"] || Jasmine.find_unused_port
112
+ end
113
+
103
114
  def jasmine_stylesheets
104
115
  ::Jasmine::Core.css_files.map {|f| "/__JASMINE_ROOT__/#{f}"}
105
116
  end
@@ -7,19 +7,19 @@ module Jasmine
7
7
  end
8
8
 
9
9
  def rails2?
10
- safe_gem_check("rails", "~> 2.3")
10
+ safe_gem_check("rails", "~> 2.3") && running_rails2?
11
11
  end
12
12
 
13
13
  def legacy_rails?
14
- safe_gem_check("rails", "< 2.3.11")
14
+ safe_gem_check("rails", "< 2.3.11") && running_legacy_rails?
15
15
  end
16
16
 
17
17
  def rails3?
18
- safe_gem_check("rails", ">= 3.0")
18
+ safe_gem_check("rails", ">= 3.0") && running_rails3?
19
19
  end
20
20
 
21
21
  def legacy_rack?
22
- !Rack.constants.include?(:Server)
22
+ !defined?(Rack::Server)
23
23
  end
24
24
 
25
25
  def rails_3_asset_pipeline?
@@ -27,6 +27,23 @@ module Jasmine
27
27
  end
28
28
 
29
29
  private
30
+
31
+ def running_legacy_rails?
32
+ running_rails? && (Gem::Version.new(Rails.version) < Gem::Version.new("2.3.11"))
33
+ end
34
+
35
+ def running_rails2?
36
+ running_rails? && Rails.version.to_i == 2
37
+ end
38
+
39
+ def running_rails3?
40
+ running_rails? && Rails.version.to_i == 3
41
+ end
42
+
43
+ def running_rails?
44
+ defined?(Rails) && Rails.respond_to?(:version)
45
+ end
46
+
30
47
  def safe_gem_check(gem_name, version_string)
31
48
  if Gem::Specification.respond_to?(:find_by_name)
32
49
  Gem::Specification.find_by_name(gem_name, version_string)
@@ -12,8 +12,7 @@ end
12
12
 
13
13
  jasmine_runner_config = Jasmine::RunnerConfig.new
14
14
  server = Jasmine::Server.new(jasmine_runner_config.port, Jasmine::Application.app(jasmine_runner_config))
15
- client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser,
16
- "#{jasmine_runner_config.jasmine_host}:#{jasmine_runner_config.port}/")
15
+ client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser, jasmine_runner_config.jasmine_server_url)
17
16
 
18
17
  t = Thread.new do
19
18
  begin
@@ -27,7 +26,7 @@ Jasmine::wait_for_listener(jasmine_runner_config.port, "jasmine server")
27
26
  puts "jasmine server started."
28
27
 
29
28
  results_processor = Jasmine::ResultsProcessor.new(jasmine_runner_config)
30
- results = Jasmine::Runners::HTTP.new(client, results_processor).run
29
+ results = Jasmine::Runners::HTTP.new(client, results_processor, jasmine_runner_config.result_batch_size).run
31
30
  formatter = Jasmine::RspecFormatter.new
32
31
  formatter.format_results(results)
33
32
 
@@ -48,13 +48,24 @@ module Jasmine
48
48
  ENV["JASMINE_BROWSER"] || 'firefox'
49
49
  end
50
50
 
51
- def jasmine_host
52
- ENV["JASMINE_HOST"] || 'http://localhost'
51
+ def port
52
+ @config.port
53
53
  end
54
54
 
55
- def port
56
- @port ||= ENV["JASMINE_PORT"] || Jasmine.find_unused_port
55
+ def jasmine_server_url
56
+ "#{@config.jasmine_host}:#{@config.port}/"
57
+ end
58
+
59
+ def src_mapper=(context)
60
+ @config.src_mapper = context
57
61
  end
58
62
 
63
+ def src_mapper
64
+ @config.src_mapper
65
+ end
66
+
67
+ def result_batch_size
68
+ ENV["JASMINE_RESULT_BATCH_SIZE"] ? ENV["JASMINE_RESULT_BATCH_SIZE"].to_i : 50
69
+ end
59
70
  end
60
71
  end
@@ -3,9 +3,10 @@ module Jasmine
3
3
  class HTTP
4
4
  attr_accessor :suites
5
5
 
6
- def initialize(client, results_processor)
6
+ def initialize(client, results_processor, result_batch_size)
7
7
  @client = client
8
8
  @results_processor = results_processor
9
+ @result_batch_size = result_batch_size
9
10
  end
10
11
 
11
12
  def run
@@ -31,7 +32,7 @@ module Jasmine
31
32
 
32
33
  def results_hash
33
34
  spec_results = {}
34
- spec_ids.each_slice(50) do |slice|
35
+ spec_ids.each_slice(@result_batch_size) do |slice|
35
36
  spec_results.merge!(eval_js("var result = jsApiReporter.resultsForSpecs(#{json_generate(slice)}); if (window.Prototype && Object.toJSON) { return Object.toJSON(result) } else { return JSON.stringify(result) }"))
36
37
  end
37
38
  spec_results
@@ -0,0 +1,13 @@
1
+ class Jasmine::SprocketsMapper
2
+ def initialize(context, mount_point = 'assets')
3
+ @context = context
4
+ @mount_point = mount_point
5
+ end
6
+
7
+ def files(src_files)
8
+ src_files.map do |src_file|
9
+ filename = src_file.gsub(/^assets\//, '').gsub(/\.js$/, '')
10
+ @context.find_asset(filename).to_a.map(&:logical_path).map(&:to_s)
11
+ end.flatten.uniq.map{|path| File.join(@mount_point, path).to_s + "?body=true"}
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Jasmine
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -11,8 +11,8 @@ describe Jasmine::AssetPipelineMapper do
11
11
  asset_context.stub(:asset_path) do |asset|
12
12
  "/some_location/#{asset}"
13
13
  end
14
- mapper = Jasmine::AssetPipelineMapper.new(src_files, asset_context)
15
- mapper.files.should == ['some_location/asset1.js?body=true', 'some_location/asset2.js?body=true', 'some_location/asset3.js?body=true']
14
+ mapper = Jasmine::AssetPipelineMapper.new(asset_context)
15
+ mapper.files(src_files).should == ['some_location/asset1.js?body=true', 'some_location/asset2.js?body=true', 'some_location/asset3.js?body=true']
16
16
  end
17
17
  end
18
18
  end
@@ -257,30 +257,53 @@ describe Jasmine::Config do
257
257
  end
258
258
  end
259
259
 
260
- describe "when the asset pipeline is active" do
261
- before do
262
- Jasmine::Dependencies.stub(:rails_3_asset_pipeline?) { true }
263
- end
264
-
260
+ describe "when the asset pipeline (or any other sprockets environment) is active" do
265
261
  let(:src_files) { ["assets/some.js", "assets/files.js"] }
262
+ let(:mapped_files) { ["some.js", "files.js"] }
263
+ let(:mapper) { double("mapper") }
266
264
 
267
265
  let(:config) do
268
266
  Jasmine::Config.new.tap do |config|
269
267
  #TODO: simple_config should be a passed in hash
270
268
  config.stub(:simple_config) { { 'src_files' => src_files} }
269
+ config.src_mapper = mapper
271
270
  end
272
271
  end
273
272
 
274
- it "should use AssetPipelineMapper to return src_files" do
275
- mapped_files = ["some.js", "files.js"]
276
- Jasmine::AssetPipelineMapper.stub_chain(:new, :files).and_return(mapped_files)
273
+ it "should use the mapper to return src_files" do
274
+ mapper.should_receive(:files).with(src_files).and_return(mapped_files)
277
275
  config.src_files.should == mapped_files
278
276
  end
277
+ end
278
+
279
+ describe "jasmine_host" do
280
+ it "should default to localhost" do
281
+ Jasmine::Config.new.jasmine_host.should == 'http://localhost'
282
+ end
283
+
284
+ it "should use ENV['JASMINE_HOST'] if it exists" do
285
+ ENV.stub(:[], "JASMINE_HOST").and_return("foo")
286
+ Jasmine::Config.new.jasmine_host.should == 'foo'
287
+ end
288
+ end
289
+
290
+ describe "port" do
291
+ it "should find an unused port" do
292
+ Jasmine.should_receive(:find_unused_port).and_return('1234')
293
+ Jasmine::Config.new.port.should == '1234'
294
+ end
295
+
296
+ it "should use ENV['JASMINE_PORT'] if it exists" do
297
+ ENV.stub(:[], "JASMINE_PORT").and_return("foo")
298
+ Jasmine::Config.new.port.should == 'foo'
299
+ end
279
300
 
280
- it "should pass the config src_files to the AssetPipelineMapper" do
281
- Jasmine::Config.stub(:simple_config)
282
- Jasmine::AssetPipelineMapper.should_receive(:new).with(src_files).and_return(double("mapper").as_null_object)
283
- config.src_files
301
+ it "should cache port" do
302
+ config = Jasmine::Config.new
303
+ Jasmine.stub(:find_unused_port).and_return('1234')
304
+ config.port.should == '1234'
305
+ Jasmine.stub(:find_unused_port).and_return('4321')
306
+ config.port.should == '1234'
284
307
  end
285
308
  end
286
309
  end
@@ -29,12 +29,21 @@ if Jasmine::Dependencies.rspec2?
29
29
 
30
30
  describe ".rails2?" do
31
31
  subject { Jasmine::Dependencies.rails2? }
32
- context "when rails 2 is present" do
32
+ context "when rails 2 is present and running" do
33
33
  before do
34
34
  Gem::Specification.should_receive(:find_by_name).with("rails", "~> 2.3").and_return(true)
35
+ Rails.stub(:respond_to?).with(:version).and_return(true)
36
+ Rails.stub(:version).and_return(running_rails_version)
35
37
  end
38
+ let(:running_rails_version) { "2.3.11" }
36
39
  it { should be_true }
37
40
  end
41
+ context "when rails 2 is present but not running" do
42
+ before do
43
+ Gem::Specification.should_receive(:find_by_name).with("rails", "~> 2.3").and_raise(Gem::LoadError)
44
+ end
45
+ it { should be_false }
46
+ end
38
47
  context "when rails 2 is not present" do
39
48
  before do
40
49
  Gem::Specification.should_receive(:find_by_name).with("rails", "~> 2.3").and_raise(Gem::LoadError)
@@ -45,12 +54,21 @@ if Jasmine::Dependencies.rspec2?
45
54
 
46
55
  describe ".legacy_rails?" do
47
56
  subject { Jasmine::Dependencies.legacy_rails? }
48
- context "when rails < 2.3.11 is present" do
57
+ context "when rails < 2.3.11 is present and running" do
49
58
  before do
50
59
  Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_return(true)
60
+ Rails.stub(:respond_to?).with(:version).and_return(true)
61
+ Rails.stub(:version).and_return(running_rails_version)
51
62
  end
63
+ let(:running_rails_version) { "2.3.8" }
52
64
  it { should be_true }
53
65
  end
66
+ context "when rails < 2.3.11 is present but not running" do
67
+ before do
68
+ Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_return(true)
69
+ end
70
+ it { should be_false }
71
+ end
54
72
  context "when rails < 2.3.11 is not present" do
55
73
  before do
56
74
  Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_raise(Gem::LoadError)
@@ -61,12 +79,21 @@ if Jasmine::Dependencies.rspec2?
61
79
 
62
80
  describe ".rails3?" do
63
81
  subject { Jasmine::Dependencies.rails3? }
64
- context "when rails 3 is present" do
82
+ context "when rails 3 is present and running" do
65
83
  before do
66
84
  Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
85
+ Rails.stub(:respond_to?).with(:version).and_return(true)
86
+ Rails.stub(:version).and_return(running_rails_version)
67
87
  end
88
+ let(:running_rails_version) { "3.2" }
68
89
  it { should be_true }
69
90
  end
91
+ context "when rails 3 is present but not running" do
92
+ before do
93
+ Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
94
+ end
95
+ it { should be_false }
96
+ end
70
97
  context "when rails 3 is not present" do
71
98
  before do
72
99
  Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_raise(Gem::LoadError)
@@ -78,9 +105,12 @@ if Jasmine::Dependencies.rspec2?
78
105
  describe ".rails_3_asset_pipeline?" do
79
106
  subject { Jasmine::Dependencies.rails_3_asset_pipeline? }
80
107
  let(:application) { double(:application) }
108
+ let(:running_rails_version) { "3.2" }
81
109
  before do
82
110
  Rails.stub(:respond_to?).with(:application).and_return(respond_to_application)
83
111
  Rails.stub(:application).and_return(application)
112
+ Rails.stub(:respond_to?).with(:version).and_return(true)
113
+ Rails.stub(:version).and_return(running_rails_version)
84
114
  end
85
115
  context "when rails 3 is present and the application pipeline is in use" do
86
116
  before do
@@ -157,10 +187,26 @@ if Jasmine::Dependencies.rspec2?
157
187
  before do
158
188
  Gem.should_receive(:available?).with("rails", "~> 2.3").and_return(rails2_present)
159
189
  end
160
- context "when rails 2 is present" do
190
+ context "when rails 2 is present and running" do
191
+ before do
192
+ Rails.stub(:respond_to?).with(:version).and_return(true)
193
+ Rails.stub(:version).and_return(running_rails_version)
194
+ end
195
+
196
+ let(:running_rails_version) { "2.3" }
161
197
  let(:rails2_present) { true }
162
198
  it { should be_true }
163
199
  end
200
+ context "when rails 2 is present but not running" do
201
+ before do
202
+ Rails.stub(:respond_to?).with(:version).and_return(true)
203
+ Rails.stub(:version).and_return(running_rails_version)
204
+ end
205
+
206
+ let(:running_rails_version) { "3.2" }
207
+ let(:rails2_present) { true }
208
+ it { should be_false }
209
+ end
164
210
  context "when rails 2 is not present" do
165
211
  let(:rails2_present) { false }
166
212
  it { should be_false }
@@ -172,10 +218,21 @@ if Jasmine::Dependencies.rspec2?
172
218
  before do
173
219
  Gem.should_receive(:available?).with("rails", "< 2.3.11").and_return(legacy_rails_present)
174
220
  end
175
- context "when rails < 2.3.11 is present" do
221
+ context "when rails < 2.3.11 is present and running" do
222
+ before do
223
+ Rails.stub(:respond_to?).with(:version).and_return(true)
224
+ Rails.stub(:version).and_return(running_rails_version)
225
+ end
226
+ let(:running_rails_version) { "2.3.8" }
176
227
  let(:legacy_rails_present) { true }
177
228
  it { should be_true }
178
229
  end
230
+
231
+ context "when rails < 2.3.11 is present but not running" do
232
+ let(:legacy_rails_present) { true }
233
+ it { should be_false }
234
+ end
235
+
179
236
  context "when rails < 2.3.11 is not present" do
180
237
  let(:legacy_rails_present) { false }
181
238
  it { should be_false }
@@ -188,6 +245,11 @@ if Jasmine::Dependencies.rspec2?
188
245
  Gem.should_receive(:available?).with("rails", ">= 3.0").and_return(rails3_present)
189
246
  end
190
247
  context "when rails 3 is present" do
248
+ before do
249
+ Rails.stub(:respond_to?).with(:version).and_return(true)
250
+ Rails.stub(:version).and_return(running_rails_version)
251
+ end
252
+ let(:running_rails_version) { "3.2" }
191
253
  let(:rails3_present) { true }
192
254
  it { should be_true }
193
255
  end
@@ -203,27 +265,45 @@ if Jasmine::Dependencies.rspec2?
203
265
  before do
204
266
  Gem.should_receive(:available?).with("rails", ">= 3.0").and_return(rails3_present)
205
267
  Rails.stub(:respond_to?).with(:application).and_return(respond_to_application)
268
+ Rails.stub(:respond_to?).with(:version).and_return(true)
206
269
  Rails.stub(:application).and_return(application)
207
270
  end
208
- context "when rails 3 is present and the application pipeline is in use" do
271
+
272
+ context "when rails 3 is present, running, and the application pipeline is in use" do
273
+ before do
274
+ Rails.stub(:respond_to?).with(:version).and_return(true)
275
+ Rails.stub(:version).and_return(running_rails_version)
276
+ end
209
277
  let(:rails3_present) { true }
278
+ let(:running_rails_version) { "3.2" }
210
279
  let(:respond_to_application) { true }
211
280
  let(:rails_application_assets) { true }
212
281
  it { should be_true }
213
282
  end
214
- context "when rails 3 is present and the application pipeline is not in use" do
283
+ context "when rails 3 is present, running, and the application pipeline is not in use" do
284
+ before do
285
+ Rails.stub(:respond_to?).with(:version).and_return(true)
286
+ Rails.stub(:version).and_return(running_rails_version)
287
+ end
215
288
  let(:rails3_present) { true }
289
+ let(:running_rails_version) { "3.2" }
216
290
  let(:respond_to_application) { true }
217
291
  let(:rails_application_assets) { false }
218
292
  it { should be_false }
219
293
  end
220
294
  context "when rails 3 is present but not loaded" do
295
+ before do
296
+ Rails.stub(:respond_to?).with(:version).and_return(false)
297
+ end
221
298
  let(:rails3_present) { true }
222
299
  let(:respond_to_application) { false }
223
300
  let(:rails_application_assets) { false }
224
301
  it { should be_false }
225
302
  end
226
303
  context "when rails 3 is not present" do
304
+ before do
305
+ Rails.stub(:respond_to?).with(:version).and_return(false)
306
+ end
227
307
  let(:rails3_present) { false }
228
308
  let(:respond_to_application) { false }
229
309
  let(:rails_application_assets) { false }
@@ -231,17 +311,5 @@ if Jasmine::Dependencies.rspec2?
231
311
  end
232
312
  end
233
313
  end
234
-
235
- describe "legacy_rack?" do
236
- it "should return false if Rack::Server exists" do
237
- Rack.stub(:constants).and_return([:Server])
238
- Jasmine::Dependencies.legacy_rack?.should be_false
239
- end
240
- it "should return true if Rack::Server does not exist" do
241
- Rack.stub(:constants).and_return([])
242
- Jasmine::Dependencies.legacy_rack?.should be_true
243
- end
244
- end
245
314
  end
246
-
247
315
  end
@@ -3,8 +3,7 @@ require 'jasmine_self_test_config'
3
3
 
4
4
  jasmine_runner_config = Jasmine::RunnerConfig.new(JasmineSelfTestConfig.new)
5
5
  server = Jasmine::Server.new(jasmine_runner_config.port, Jasmine::Application.app(jasmine_runner_config))
6
- client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser,
7
- "#{jasmine_runner_config.jasmine_host}:#{jasmine_runner_config.port}/")
6
+ client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser, jasmine_runner_config.jasmine_server_url)
8
7
 
9
8
  t = Thread.new do
10
9
  begin
@@ -18,6 +17,6 @@ Jasmine::wait_for_listener(jasmine_runner_config.port, "jasmine server")
18
17
  puts "jasmine server started."
19
18
 
20
19
  results_processor = Jasmine::ResultsProcessor.new(jasmine_runner_config)
21
- results = Jasmine::Runners::HTTP.new(client, results_processor).run
20
+ results = Jasmine::Runners::HTTP.new(client, results_processor, jasmine_runner_config.result_batch_size).run
22
21
  formatter = Jasmine::RspecFormatter.new
23
22
  formatter.format_results(results)
@@ -94,38 +94,43 @@ describe Jasmine::RunnerConfig do
94
94
  end
95
95
  end
96
96
 
97
- describe "jasmine_host" do
98
- it "should default to localhost" do
99
- Jasmine::RunnerConfig.new.jasmine_host.should == 'http://localhost'
97
+
98
+ describe "src_mapper" do
99
+ it "should update the src_mapper in the user_config" do
100
+ config = Jasmine::RunnerConfig.new(user_config = Jasmine::Config.new)
101
+ mapper = double("mapper")
102
+ config.src_mapper = mapper
103
+ config.src_mapper.should == mapper
104
+ user_config.src_mapper.should == mapper
100
105
  end
106
+ end
101
107
 
102
- it "should use ENV['JASMINE_HOST'] if it exists" do
103
- ENV.stub(:[], "JASMINE_HOST").and_return("foo")
104
- Jasmine::RunnerConfig.new.jasmine_host.should == 'foo'
108
+ describe "jasmine_server_url" do
109
+ it "should return the correct server url" do
110
+ host = "the host"
111
+ port = "484"
112
+ user_config = double('config', :jasmine_host => host, :port => port)
113
+ Jasmine::RunnerConfig.new(user_config).jasmine_server_url.should == "#{host}:#{port}/"
105
114
  end
106
115
  end
107
116
 
108
117
  describe "port" do
109
- it "should find an unused port" do
110
- Jasmine.should_receive(:find_unused_port).and_return('1234')
111
- Jasmine::RunnerConfig.new.port.should == '1234'
118
+ it "should return the port from the config" do
119
+ user_config = double('config', :port => 80)
120
+ Jasmine::RunnerConfig.new(user_config).port.should == 80
112
121
  end
122
+ end
123
+ describe "result batch size" do
124
+ subject { Jasmine::RunnerConfig.new.result_batch_size }
113
125
 
114
- it "should use ENV['JASMINE_PORT'] if it exists" do
115
- ENV.stub(:[], "JASMINE_PORT").and_return("foo")
116
- Jasmine::RunnerConfig.new.port.should == 'foo'
126
+ context "when not specified" do
127
+ it("should use default") { should == 50 }
117
128
  end
118
129
 
119
- it "should cache port" do
120
- config = Jasmine::RunnerConfig.new
121
- Jasmine.stub(:find_unused_port).and_return('1234')
122
- config.port.should == '1234'
123
- Jasmine.stub(:find_unused_port).and_return('4321')
124
- config.port.should == '1234'
130
+ context "when overridden" do
131
+ before { ENV.stub(:[], "JASMINE_RESULT_BATCH_SIZE").and_return("500") }
132
+ it { should be(500) }
125
133
  end
126
-
127
-
128
134
  end
129
-
130
135
  end
131
136
 
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::SprocketsMapper do
4
+ describe "mapping files" do
5
+ it "should retrieve asset paths from the the sprockets environment for passed files" do
6
+ src_files = ["assets/application.js", "assets/other_manifest.js"]
7
+ asset1 = double("asset1", :logical_path => "asset1.js")
8
+ asset2 = double("asset2", :logical_path => "asset2.js")
9
+ asset3 = double("asset3", :logical_path => "asset3.js")
10
+ asset_context = double("Sprockets::Environment")
11
+ asset_context.stub_chain(:find_asset).with("application").and_return([asset1, asset2])
12
+ asset_context.stub_chain(:find_asset).with("other_manifest").and_return([asset1, asset3])
13
+ mapper = Jasmine::SprocketsMapper.new(asset_context, 'some_location')
14
+ mapper.files(src_files).should == ['some_location/asset1.js?body=true', 'some_location/asset2.js?body=true', 'some_location/asset3.js?body=true']
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
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: 2012-08-15 00:00:00.000000000 Z
14
+ date: 2012-11-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
18
- requirement: &70248187660320 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,15 @@ dependencies:
23
23
  version: 2.5.0
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *70248187660320
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: 2.5.0
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: rails
29
- requirement: &70248187649880 !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: 3.0.0
35
40
  type: :development
36
41
  prerelease: false
37
- version_requirements: *70248187649880
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: rack
40
- requirement: &70248187648920 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
41
51
  none: false
42
52
  requirements:
43
53
  - - ! '>='
@@ -45,10 +55,15 @@ dependencies:
45
55
  version: 1.2.1
46
56
  type: :development
47
57
  prerelease: false
48
- version_requirements: *70248187648920
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: 1.2.1
49
64
  - !ruby/object:Gem::Dependency
50
65
  name: rack-test
51
- requirement: &70248187648060 !ruby/object:Gem::Requirement
66
+ requirement: !ruby/object:Gem::Requirement
52
67
  none: false
53
68
  requirements:
54
69
  - - ! '>='
@@ -56,10 +71,15 @@ dependencies:
56
71
  version: '0'
57
72
  type: :development
58
73
  prerelease: false
59
- version_requirements: *70248187648060
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
60
80
  - !ruby/object:Gem::Dependency
61
81
  name: json_pure
62
- requirement: &70248187645900 !ruby/object:Gem::Requirement
82
+ requirement: !ruby/object:Gem::Requirement
63
83
  none: false
64
84
  requirements:
65
85
  - - ! '>='
@@ -67,10 +87,15 @@ dependencies:
67
87
  version: '0'
68
88
  type: :development
69
89
  prerelease: false
70
- version_requirements: *70248187645900
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
71
96
  - !ruby/object:Gem::Dependency
72
97
  name: nokogiri
73
- requirement: &70248187644700 !ruby/object:Gem::Requirement
98
+ requirement: !ruby/object:Gem::Requirement
74
99
  none: false
75
100
  requirements:
76
101
  - - ! '>='
@@ -78,21 +103,31 @@ dependencies:
78
103
  version: '0'
79
104
  type: :development
80
105
  prerelease: false
81
- version_requirements: *70248187644700
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
82
112
  - !ruby/object:Gem::Dependency
83
113
  name: jasmine-core
84
- requirement: &70248187643700 !ruby/object:Gem::Requirement
114
+ requirement: !ruby/object:Gem::Requirement
85
115
  none: false
86
116
  requirements:
87
117
  - - ! '>='
88
118
  - !ruby/object:Gem::Version
89
- version: 1.2.0
119
+ version: 1.3.0
90
120
  type: :runtime
91
121
  prerelease: false
92
- version_requirements: *70248187643700
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: 1.3.0
93
128
  - !ruby/object:Gem::Dependency
94
129
  name: rack
95
- requirement: &70248187625440 !ruby/object:Gem::Requirement
130
+ requirement: !ruby/object:Gem::Requirement
96
131
  none: false
97
132
  requirements:
98
133
  - - ~>
@@ -100,10 +135,15 @@ dependencies:
100
135
  version: '1.0'
101
136
  type: :runtime
102
137
  prerelease: false
103
- version_requirements: *70248187625440
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ~>
142
+ - !ruby/object:Gem::Version
143
+ version: '1.0'
104
144
  - !ruby/object:Gem::Dependency
105
145
  name: rspec
106
- requirement: &70248187624740 !ruby/object:Gem::Requirement
146
+ requirement: !ruby/object:Gem::Requirement
107
147
  none: false
108
148
  requirements:
109
149
  - - ! '>='
@@ -111,10 +151,15 @@ dependencies:
111
151
  version: 1.3.1
112
152
  type: :runtime
113
153
  prerelease: false
114
- version_requirements: *70248187624740
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: 1.3.1
115
160
  - !ruby/object:Gem::Dependency
116
161
  name: selenium-webdriver
117
- requirement: &70248187624080 !ruby/object:Gem::Requirement
162
+ requirement: !ruby/object:Gem::Requirement
118
163
  none: false
119
164
  requirements:
120
165
  - - ! '>='
@@ -122,7 +167,12 @@ dependencies:
122
167
  version: 0.1.3
123
168
  type: :runtime
124
169
  prerelease: false
125
- version_requirements: *70248187624080
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: 0.1.3
126
176
  description: Test your JavaScript without any framework dependencies, in any environment,
127
177
  and with a nice descriptive syntax.
128
178
  email: jasmine-js@googlegroups.com
@@ -185,6 +235,7 @@ files:
185
235
  - lib/jasmine/runners/http.rb
186
236
  - lib/jasmine/selenium_driver.rb
187
237
  - lib/jasmine/server.rb
238
+ - lib/jasmine/sprockets_mapper.rb
188
239
  - lib/jasmine/tasks/jasmine.rake
189
240
  - lib/jasmine/tasks/jasmine_rails3.rake
190
241
  - lib/jasmine/version.rb
@@ -215,8 +266,10 @@ files:
215
266
  - spec/runner_config_spec.rb
216
267
  - spec/server_spec.rb
217
268
  - spec/spec_helper.rb
218
- homepage: http://pivotal.github.com/jasmine
219
- licenses: []
269
+ - spec/sprockets_mapper_spec.rb
270
+ homepage: http://pivotal.github.com/jasmine/
271
+ licenses:
272
+ - MIT
220
273
  post_install_message:
221
274
  rdoc_options:
222
275
  - --charset=UTF-8
@@ -236,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
289
  version: '0'
237
290
  requirements: []
238
291
  rubyforge_project:
239
- rubygems_version: 1.8.15
292
+ rubygems_version: 1.8.24
240
293
  signing_key:
241
294
  specification_version: 3
242
295
  summary: JavaScript BDD framework
@@ -264,3 +317,4 @@ test_files:
264
317
  - spec/runner_config_spec.rb
265
318
  - spec/server_spec.rb
266
319
  - spec/spec_helper.rb
320
+ - spec/sprockets_mapper_spec.rb