jasmine 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +11 -2
- data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +2 -2
- data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +2 -1
- data/jasmine.gemspec +1 -1
- data/lib/jasmine.rb +10 -2
- data/lib/jasmine/application.rb +6 -33
- data/lib/jasmine/asset_expander.rb +19 -0
- data/lib/jasmine/asset_pipeline_mapper.rb +11 -14
- data/lib/jasmine/asset_pipeline_utility.rb +19 -0
- data/lib/jasmine/base.rb +4 -0
- data/lib/jasmine/config.rb +74 -111
- data/lib/jasmine/configuration.rb +83 -0
- data/lib/jasmine/core_configuration.rb +28 -0
- data/lib/jasmine/javascripts/boot.js +28 -0
- data/lib/jasmine/path_expander.rb +18 -0
- data/lib/jasmine/path_mapper.rb +29 -0
- data/lib/jasmine/results_processor.rb +21 -20
- data/lib/jasmine/run.html.erb +0 -37
- data/lib/jasmine/run_specs.rb +12 -8
- data/lib/jasmine/server.rb +1 -1
- data/lib/jasmine/tasks/jasmine.rake +3 -4
- data/lib/jasmine/version.rb +1 -1
- data/lib/jasmine/yaml_config_parser.rb +54 -0
- data/spec/application_integration_spec.rb +15 -0
- data/spec/application_spec.rb +37 -92
- data/spec/asset_expander_spec.rb +42 -0
- data/spec/asset_pipeline_mapper_spec.rb +12 -11
- data/spec/base_spec.rb +14 -0
- data/spec/configuration_spec.rb +163 -0
- data/spec/jasmine_self_test_spec.rb +14 -7
- data/spec/page_spec.rb +2 -4
- data/spec/path_expander_spec.rb +96 -0
- data/spec/path_mapper_spec.rb +33 -0
- data/spec/server_spec.rb +2 -2
- data/spec/yaml_config_parser_spec.rb +182 -0
- metadata +34 -23
- data/lib/jasmine/runner_config.rb +0 -71
- data/lib/jasmine/sprockets_mapper.rb +0 -13
- data/lib/rack/jasmine/redirect.rb +0 -20
- data/spec/config_spec.rb +0 -309
- data/spec/fixture/jasmine.erb.yml +0 -4
- data/spec/fixture/spec/example_spec.js +0 -5
- data/spec/fixture/src/example.js +0 -3
- data/spec/jasmine_self_test_config.rb +0 -19
- data/spec/runner_config_spec.rb +0 -136
- data/spec/sprockets_mapper_spec.rb +0 -17
data/Rakefile
CHANGED
@@ -29,10 +29,19 @@ task :default => :spec
|
|
29
29
|
|
30
30
|
namespace :jasmine do
|
31
31
|
require "jasmine-core"
|
32
|
-
require './spec/jasmine_self_test_config'
|
33
32
|
task :server do
|
34
33
|
port = ENV['JASMINE_PORT'] || 8888
|
35
|
-
|
34
|
+
Jasmine.configure do |config|
|
35
|
+
root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
36
|
+
config.src_dir = File.join(root, 'src')
|
37
|
+
config.spec_dir = Jasmine::Core.path
|
38
|
+
config.spec_files = lambda { (Jasmine::Core.html_spec_files + Jasmine::Core.core_spec_files).map {|f| File.join(config.spec_dir, f) } }
|
39
|
+
end
|
40
|
+
|
41
|
+
config = Jasmine.config
|
42
|
+
|
43
|
+
server = Jasmine::Server.new(8888, Jasmine::Application.app(config))
|
44
|
+
server.start
|
36
45
|
|
37
46
|
puts "your tests are here:"
|
38
47
|
puts " http://localhost:#{port}/"
|
@@ -43,7 +43,7 @@ stylesheets:
|
|
43
43
|
# - helpers/**/*.js
|
44
44
|
#
|
45
45
|
helpers:
|
46
|
-
- helpers/**/*.js
|
46
|
+
- 'helpers/**/*.js'
|
47
47
|
|
48
48
|
# spec_files
|
49
49
|
#
|
@@ -53,7 +53,7 @@ helpers:
|
|
53
53
|
# EXAMPLE:
|
54
54
|
#
|
55
55
|
# spec_files:
|
56
|
-
# - **/*[sS]pec.js
|
56
|
+
# - '**/*[sS]pec.js'
|
57
57
|
#
|
58
58
|
spec_files:
|
59
59
|
- '**/*[sS]pec.js'
|
@@ -37,7 +37,7 @@ stylesheets:
|
|
37
37
|
# - helpers/**/*.js
|
38
38
|
#
|
39
39
|
helpers:
|
40
|
-
|
40
|
+
- 'helpers/**/*.js'
|
41
41
|
# spec_files
|
42
42
|
#
|
43
43
|
# Return an array of filepaths relative to spec_dir to include.
|
@@ -49,6 +49,7 @@ helpers:
|
|
49
49
|
# - **/*[sS]pec.js
|
50
50
|
#
|
51
51
|
spec_files:
|
52
|
+
- '**/*[sS]pec.js'
|
52
53
|
|
53
54
|
# src_dir
|
54
55
|
#
|
data/jasmine.gemspec
CHANGED
@@ -67,7 +67,7 @@ Gem::Specification.new do |s|
|
|
67
67
|
s.add_development_dependency 'json_pure'
|
68
68
|
s.add_development_dependency 'nokogiri'
|
69
69
|
|
70
|
-
s.add_dependency 'jasmine-core', "
|
70
|
+
s.add_dependency 'jasmine-core', "~> 1.3.1"
|
71
71
|
s.add_dependency 'rack', '~> 1.0'
|
72
72
|
s.add_dependency 'rspec', '>= 1.3.1'
|
73
73
|
s.add_dependency 'selenium-webdriver', '>= 0.1.3'
|
data/lib/jasmine.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
jasmine_files = ['base',
|
2
2
|
'dependencies',
|
3
|
-
'
|
3
|
+
'core_configuration',
|
4
|
+
'configuration',
|
4
5
|
'config',
|
5
6
|
'application',
|
6
7
|
'server',
|
@@ -8,15 +9,22 @@ jasmine_files = ['base',
|
|
8
9
|
'rspec_formatter',
|
9
10
|
'command_line_tool',
|
10
11
|
'page',
|
12
|
+
'path_mapper',
|
13
|
+
'asset_pipeline_utility',
|
11
14
|
'asset_pipeline_mapper',
|
12
|
-
'
|
15
|
+
'asset_expander',
|
13
16
|
'results_processor',
|
14
17
|
'results',
|
18
|
+
'path_expander',
|
19
|
+
'yaml_config_parser',
|
15
20
|
File.join('runners', 'http')]
|
16
21
|
|
17
22
|
jasmine_files.each do |file|
|
18
23
|
require File.join('jasmine', file)
|
19
24
|
end
|
25
|
+
# jasmine_rack_files.each do |file|
|
26
|
+
# require File.join('rack', 'jasmine', file)
|
27
|
+
# end
|
20
28
|
|
21
29
|
require File.join('jasmine', "railtie") if Jasmine::Dependencies.rails3?
|
22
30
|
|
data/lib/jasmine/application.rb
CHANGED
@@ -3,46 +3,19 @@ require 'rack/utils'
|
|
3
3
|
require 'jasmine-core'
|
4
4
|
require 'rack/jasmine/runner'
|
5
5
|
require 'rack/jasmine/focused_suite'
|
6
|
-
require 'rack/jasmine/redirect'
|
7
6
|
require 'rack/jasmine/cache_control'
|
8
7
|
require 'ostruct'
|
9
8
|
|
10
9
|
module Jasmine
|
11
10
|
class Application
|
12
|
-
def self.app(config =
|
13
|
-
|
14
|
-
|
15
|
-
config.src_mapper = Jasmine::AssetPipelineMapper.new
|
11
|
+
def self.app(config, builder = Rack::Builder.new)
|
12
|
+
config.rack_apps.each do |(app, config_block)|
|
13
|
+
builder.use(app, &config_block)
|
16
14
|
end
|
17
|
-
|
18
|
-
|
19
|
-
use Rack::Jasmine::CacheControl
|
20
|
-
if Jasmine::Dependencies.rails_3_asset_pipeline?
|
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
|
27
|
-
run Rails.application.assets
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
map('/run.html') { run Rack::Jasmine::Redirect.new('/') }
|
32
|
-
map('/__suite__') { run Rack::Jasmine::FocusedSuite.new(config) }
|
33
|
-
|
34
|
-
#TODO: These path mappings should come from the config.
|
35
|
-
map('/__JASMINE_ROOT__') { run Rack::File.new(Jasmine::Core.path) }
|
36
|
-
map(config.spec_path) { run Rack::File.new(config.spec_dir) }
|
37
|
-
map(config.root_path) { run Rack::File.new(config.project_root) }
|
38
|
-
|
39
|
-
map('/') do
|
40
|
-
run Rack::Cascade.new([
|
41
|
-
Rack::URLMap.new('/' => Rack::File.new(config.src_dir)),
|
42
|
-
Rack::Jasmine::Runner.new(page)
|
43
|
-
])
|
44
|
-
end
|
15
|
+
config.rack_path_map.each do |path, handler|
|
16
|
+
builder.map(path) { run handler.call }
|
45
17
|
end
|
18
|
+
builder
|
46
19
|
end
|
47
20
|
end
|
48
21
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class AssetExpander
|
3
|
+
def initialize(bundled_asset_factory, asset_path_for)
|
4
|
+
@bundled_asset_factory = bundled_asset_factory
|
5
|
+
@asset_path_for = asset_path_for
|
6
|
+
end
|
7
|
+
|
8
|
+
def expand(src_dir, src_path)
|
9
|
+
pathname = src_path.gsub(/^\/?assets\//, '').gsub(/\.js$/, '')
|
10
|
+
bundled_asset = @bundled_asset_factory.call(pathname, 'js')
|
11
|
+
return nil unless bundled_asset
|
12
|
+
|
13
|
+
base_asset = "#{bundled_asset.pathname.to_s.gsub(/#{src_dir}/, '')}?body=true"
|
14
|
+
bundled_asset.to_a.inject([base_asset]) do |assets, asset|
|
15
|
+
assets << "/#{@asset_path_for.call(asset).gsub(/^\//, '')}?body=true"
|
16
|
+
end.flatten
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,19 +1,16 @@
|
|
1
|
-
|
1
|
+
module Jasmine
|
2
|
+
class AssetPipelineMapper
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
4
|
+
def initialize(config, asset_expander)
|
5
|
+
@config = config
|
6
|
+
@asset_expander = asset_expander
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def map_src_paths(src_paths)
|
10
|
+
src_paths.map do |src_path|
|
11
|
+
@asset_expander.call(@config.src_dir, src_path) || src_path
|
12
|
+
end.flatten.uniq
|
13
|
+
end
|
12
14
|
|
13
|
-
def files(src_files)
|
14
|
-
src_files.map do |src_file|
|
15
|
-
filename = src_file.gsub(/^assets\//, '').gsub(/\.js$/, '')
|
16
|
-
@context.asset_paths.asset_for(filename, 'js').to_a.map { |p| @context.asset_path(p).gsub(/^\//, '') + "?body=true" }
|
17
|
-
end.flatten.uniq
|
18
15
|
end
|
19
16
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class AssetPipelineUtility
|
3
|
+
def self.bundled_asset_factory(pathname, ext)
|
4
|
+
context.asset_paths.asset_for(pathname, 'js')
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.asset_path_for(filepath)
|
8
|
+
context.asset_path(filepath)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.context
|
12
|
+
return @context if @context
|
13
|
+
@context = ::Rails.application.assets.context_class
|
14
|
+
@context.extend(::Sprockets::Helpers::IsolatedHelper)
|
15
|
+
@context.extend(::Sprockets::Helpers::RailsHelper)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/jasmine/base.rb
CHANGED
data/lib/jasmine/config.rb
CHANGED
@@ -1,122 +1,85 @@
|
|
1
1
|
module Jasmine
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
require 'erb'
|
7
|
-
require 'json'
|
8
|
-
|
9
|
-
def match_files(dir, patterns)
|
10
|
-
dir = File.expand_path(dir)
|
11
|
-
negative, positive = patterns.partition {|pattern| /^!/ =~ pattern}
|
12
|
-
chosen, negated = [positive, negative].collect do |patterns|
|
13
|
-
patterns.collect do |pattern|
|
14
|
-
matches = Dir.glob(File.join(dir, pattern.gsub(/^!/,'')))
|
15
|
-
matches.empty? && !(pattern =~ /\*|^\!/) ? pattern : matches.collect {|f| f.sub("#{dir}/", "")}.sort
|
16
|
-
end.flatten.uniq
|
17
|
-
end
|
18
|
-
chosen - negated
|
19
|
-
end
|
20
|
-
|
21
|
-
def simple_config
|
22
|
-
config = File.exist?(simple_config_file) ? YAML::load(ERB.new(File.read(simple_config_file)).result(binding)) : false
|
23
|
-
config || {}
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
def spec_path
|
28
|
-
"/__spec__"
|
29
|
-
end
|
30
|
-
|
31
|
-
def root_path
|
32
|
-
"/__root__"
|
33
|
-
end
|
34
|
-
|
35
|
-
def js_files(spec_filter = nil)
|
36
|
-
spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, [spec_filter])
|
37
|
-
src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) }
|
38
|
-
end
|
39
|
-
|
40
|
-
def user_stylesheets
|
41
|
-
stylesheets.collect {|f| "/" + f }
|
42
|
-
end
|
43
|
-
|
44
|
-
def spec_files_full_paths
|
45
|
-
spec_files.collect {|spec_file| File.join(spec_dir, spec_file) }
|
46
|
-
end
|
47
|
-
|
48
|
-
def project_root
|
49
|
-
Dir.pwd
|
50
|
-
end
|
51
|
-
|
52
|
-
def simple_config_file
|
53
|
-
File.join(project_root, 'spec/javascripts/support/jasmine.yml')
|
54
|
-
end
|
55
|
-
|
56
|
-
def src_dir
|
57
|
-
if simple_config['src_dir']
|
58
|
-
File.join(project_root, simple_config['src_dir'])
|
59
|
-
else
|
60
|
-
project_root
|
61
|
-
end
|
62
|
-
end
|
2
|
+
require 'erb'
|
3
|
+
def self.configure(&block)
|
4
|
+
block.call(self.config)
|
5
|
+
end
|
63
6
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
7
|
+
def self.initialize_config
|
8
|
+
return if @config
|
9
|
+
@config = Jasmine::Configuration.new
|
10
|
+
core_config = Jasmine::CoreConfiguration.new
|
11
|
+
|
12
|
+
@config.add_path_mapper(Jasmine::PathMapper.method(:new))
|
13
|
+
|
14
|
+
@config.jasmine_path = jasmine_path = "/__jasmine__"
|
15
|
+
@config.src_path = src_path = "/"
|
16
|
+
@config.spec_path = spec_path = "/__spec__"
|
17
|
+
@config.boot_path = boot_path = "/__boot__"
|
18
|
+
|
19
|
+
@config.jasmine_dir = core_config.path
|
20
|
+
@config.boot_dir = core_config.boot_path
|
21
|
+
@config.boot_files = lambda { core_config.boot_files }
|
22
|
+
@config.jasmine_files = lambda { core_config.js_files }
|
23
|
+
@config.jasmine_css_files = lambda { core_config.css_files }
|
24
|
+
|
25
|
+
@config.add_rack_path(jasmine_path, lambda { Rack::File.new(config.jasmine_dir) })
|
26
|
+
@config.add_rack_path(boot_path, lambda { Rack::File.new(config.boot_dir) })
|
27
|
+
@config.add_rack_path(spec_path, lambda { Rack::File.new(config.spec_dir) })
|
28
|
+
@config.add_rack_path(src_path, lambda {
|
29
|
+
Rack::Cascade.new([
|
30
|
+
Rack::URLMap.new('/' => Rack::File.new(config.src_dir)),
|
31
|
+
Rack::Jasmine::Runner.new(Jasmine::Page.new(config))
|
32
|
+
])
|
33
|
+
})
|
34
|
+
|
35
|
+
@config.add_rack_app(Rack::Head)
|
36
|
+
@config.add_rack_app(Rack::Jasmine::CacheControl)
|
37
|
+
|
38
|
+
if Jasmine::Dependencies.rails_3_asset_pipeline?
|
39
|
+
@config.add_path_mapper(lambda { |config|
|
40
|
+
asset_expander = Jasmine::AssetExpander.new(
|
41
|
+
Jasmine::AssetPipelineUtility.method(:bundled_asset_factory),
|
42
|
+
Jasmine::AssetPipelineUtility.method(:asset_path_for)
|
43
|
+
)
|
44
|
+
Jasmine::AssetPipelineMapper.new(config, asset_expander.method(:expand))
|
45
|
+
})
|
46
|
+
@config.add_rack_path('/assets', lambda {
|
47
|
+
# In order to have asset helpers like asset_path and image_path, we need to require 'action_view/base'. This
|
48
|
+
# triggers run_load_hooks on action_view which, in turn, causes sprockets/railtie to load the Sprockets asset
|
49
|
+
# helpers. Alternatively, you can include the helpers yourself without loading action_view/base:
|
50
|
+
Rails.application.assets.context_class.instance_eval do
|
51
|
+
include ::Sprockets::Helpers::IsolatedHelper
|
52
|
+
include ::Sprockets::Helpers::RailsHelper
|
53
|
+
end
|
54
|
+
Rails.application.assets
|
55
|
+
})
|
70
56
|
end
|
71
57
|
|
72
|
-
|
73
|
-
if simple_config['helpers']
|
74
|
-
match_files(spec_dir, simple_config['helpers'])
|
75
|
-
else
|
76
|
-
match_files(spec_dir, ["helpers/**/*.js"])
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def src_files
|
81
|
-
return [] unless simple_config['src_files']
|
58
|
+
end
|
82
59
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
end
|
60
|
+
def self.config
|
61
|
+
initialize_config
|
62
|
+
@config
|
63
|
+
end
|
89
64
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
65
|
+
def self.load_configuration_from_yaml(path = nil)
|
66
|
+
path ||= File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine.yml')
|
67
|
+
if File.exist?(path)
|
68
|
+
yaml_loader = lambda do |filepath|
|
69
|
+
YAML::load(ERB.new(File.read(filepath)).result(binding)) if File.exist?(filepath)
|
95
70
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
71
|
+
yaml_config = Jasmine::YamlConfigParser.new(path, Dir.pwd, Jasmine::PathExpander.method(:expand), yaml_loader)
|
72
|
+
Jasmine.configure do |config|
|
73
|
+
config.jasmine_dir = yaml_config.jasmine_dir if yaml_config.jasmine_dir
|
74
|
+
config.jasmine_files = lambda { yaml_config.jasmine_files } if yaml_config.jasmine_files.any?
|
75
|
+
config.jasmine_css_files = lambda { yaml_config.jasmine_css_files } if yaml_config.jasmine_css_files.any?
|
76
|
+
config.src_files = lambda { yaml_config.src_files }
|
77
|
+
config.spec_files = lambda { yaml_config.helpers + yaml_config.spec_files }
|
78
|
+
config.css_files = lambda { yaml_config.css_files }
|
79
|
+
config.src_dir = yaml_config.src_dir
|
80
|
+
config.spec_dir = yaml_config.spec_dir
|
103
81
|
end
|
104
82
|
end
|
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
|
-
|
114
|
-
def jasmine_stylesheets
|
115
|
-
::Jasmine::Core.css_files.map {|f| "/__JASMINE_ROOT__/#{f}"}
|
116
|
-
end
|
117
|
-
|
118
|
-
def jasmine_javascripts
|
119
|
-
::Jasmine::Core.js_files.map {|f| "/__JASMINE_ROOT__/#{f}" }
|
120
|
-
end
|
121
83
|
end
|
84
|
+
|
122
85
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class Configuration
|
3
|
+
attr_writer :jasmine_css_files, :css_files
|
4
|
+
attr_writer :jasmine_files, :boot_files, :src_files, :spec_files
|
5
|
+
attr_accessor :jasmine_path, :spec_path, :boot_path, :src_path
|
6
|
+
attr_accessor :jasmine_dir, :spec_dir, :boot_dir, :src_dir
|
7
|
+
#TODO: these are largely client concerns, move them.
|
8
|
+
attr_accessor :port, :browser, :host, :result_batch_size
|
9
|
+
|
10
|
+
def initialize()
|
11
|
+
@rack_paths = {}
|
12
|
+
@apps = []
|
13
|
+
@path_mappers = []
|
14
|
+
@jasmine_css_files = lambda { [] }
|
15
|
+
@css_files = lambda { [] }
|
16
|
+
@jasmine_files = lambda { [] }
|
17
|
+
@boot_files = lambda { [] }
|
18
|
+
@src_files = lambda { [] }
|
19
|
+
@spec_files = lambda { [] }
|
20
|
+
end
|
21
|
+
|
22
|
+
def css_files
|
23
|
+
map(@jasmine_css_files, :jasmine) +
|
24
|
+
map(@css_files, :src)
|
25
|
+
end
|
26
|
+
|
27
|
+
def js_files
|
28
|
+
map(@jasmine_files, :jasmine) +
|
29
|
+
map(@src_files, :src) +
|
30
|
+
map(@spec_files, :spec) +
|
31
|
+
map(@boot_files, :boot)
|
32
|
+
end
|
33
|
+
|
34
|
+
def rack_path_map
|
35
|
+
{}.merge(@rack_paths)
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_rack_path(path, rack_app_lambda)
|
39
|
+
@rack_paths[path] = rack_app_lambda
|
40
|
+
end
|
41
|
+
|
42
|
+
def rack_apps
|
43
|
+
[] + @apps
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_rack_app(app, &block)
|
47
|
+
@apps << [app, block]
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_path_mapper(mapper)
|
51
|
+
@path_mappers << mapper.call(self)
|
52
|
+
end
|
53
|
+
|
54
|
+
def port
|
55
|
+
@port ||= Jasmine.find_unused_port
|
56
|
+
end
|
57
|
+
|
58
|
+
def browser
|
59
|
+
@browser || 'firefox'
|
60
|
+
end
|
61
|
+
|
62
|
+
def host
|
63
|
+
@host || 'http://localhost'
|
64
|
+
end
|
65
|
+
|
66
|
+
def result_batch_size
|
67
|
+
@result_batch_size || 50
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def map(paths, type)
|
73
|
+
@path_mappers.inject(paths.call) do |paths, mapper|
|
74
|
+
if mapper.respond_to?("map_#{type}_paths")
|
75
|
+
mapper.send("map_#{type}_paths", paths)
|
76
|
+
else
|
77
|
+
paths
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|