jasmine-multi_json 1.3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +13 -0
- data/.rspec +1 -0
- data/.travis.yml +58 -0
- data/Gemfile +8 -0
- data/HOW_TO_TEST.markdown +9 -0
- data/MIT.LICENSE +20 -0
- data/README.markdown +77 -0
- data/RELEASE.markdown +22 -0
- data/RELEASE_NOTES.markdown +6 -0
- data/Rakefile +62 -0
- data/generators/jasmine/jasmine_generator.rb +24 -0
- data/generators/jasmine/templates/INSTALL +9 -0
- data/generators/jasmine/templates/jasmine-example/SpecRunner.html +54 -0
- data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
- data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
- data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
- data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
- data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +74 -0
- data/jasmine.gemspec +74 -0
- data/lib/generators/jasmine/examples/USAGE +11 -0
- data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
- data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Player.js +22 -0
- data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Song.js +7 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
- data/lib/generators/jasmine/install/USAGE +11 -0
- data/lib/generators/jasmine/install/install_generator.rb +18 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +76 -0
- data/lib/jasmine.rb +31 -0
- data/lib/jasmine/application.rb +21 -0
- data/lib/jasmine/asset_expander.rb +19 -0
- data/lib/jasmine/asset_pipeline_mapper.rb +16 -0
- data/lib/jasmine/asset_pipeline_utility.rb +19 -0
- data/lib/jasmine/base.rb +54 -0
- data/lib/jasmine/command_line_tool.rb +70 -0
- data/lib/jasmine/config.rb +85 -0
- data/lib/jasmine/configuration.rb +83 -0
- data/lib/jasmine/core_configuration.rb +28 -0
- data/lib/jasmine/dependencies.rb +59 -0
- data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
- data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
- data/lib/jasmine/firebug/firebug-license.txt +30 -0
- data/lib/jasmine/firebug/firebug.rb +30 -0
- data/lib/jasmine/javascripts/boot.js +28 -0
- data/lib/jasmine/page.rb +11 -0
- data/lib/jasmine/path_expander.rb +18 -0
- data/lib/jasmine/path_mapper.rb +29 -0
- data/lib/jasmine/railtie.rb +21 -0
- data/lib/jasmine/results.rb +19 -0
- data/lib/jasmine/results_processor.rb +38 -0
- data/lib/jasmine/rspec_formatter.rb +92 -0
- data/lib/jasmine/run.html.erb +18 -0
- data/lib/jasmine/run_specs.rb +36 -0
- data/lib/jasmine/runners/http.rb +71 -0
- data/lib/jasmine/selenium_driver.rb +41 -0
- data/lib/jasmine/server.rb +20 -0
- data/lib/jasmine/tasks/jasmine.rake +55 -0
- data/lib/jasmine/tasks/jasmine_rails3.rake +1 -0
- data/lib/jasmine/version.rb +3 -0
- data/lib/jasmine/yaml_config_parser.rb +54 -0
- data/lib/rack/jasmine/cache_control.rb +20 -0
- data/lib/rack/jasmine/focused_suite.rb +17 -0
- data/lib/rack/jasmine/runner.rb +27 -0
- data/spec/application_integration_spec.rb +15 -0
- data/spec/application_spec.rb +44 -0
- data/spec/asset_expander_spec.rb +42 -0
- data/spec/asset_pipeline_mapper_spec.rb +19 -0
- data/spec/base_spec.rb +14 -0
- data/spec/configuration_spec.rb +163 -0
- data/spec/dependencies_spec.rb +315 -0
- data/spec/fixture/Rakefile +4 -0
- data/spec/jasmine_command_line_tool_rakeless_spec.rb +20 -0
- data/spec/jasmine_command_line_tool_spec.rb +29 -0
- data/spec/jasmine_pojs_spec.rb +47 -0
- data/spec/jasmine_rails2_spec.rb +89 -0
- data/spec/jasmine_rails3_spec.rb +69 -0
- data/spec/jasmine_self_test_spec.rb +29 -0
- data/spec/page_spec.rb +23 -0
- data/spec/path_expander_spec.rb +96 -0
- data/spec/path_mapper_spec.rb +33 -0
- data/spec/rack/jasmine/runner_spec.rb +25 -0
- data/spec/results_processor_spec.rb +3 -0
- data/spec/results_spec.rb +27 -0
- data/spec/rspec_formatter_spec.rb +88 -0
- data/spec/server_spec.rb +48 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/yaml_config_parser_spec.rb +182 -0
- metadata +310 -0
data/lib/jasmine.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
jasmine_files = ['base',
|
|
2
|
+
'dependencies',
|
|
3
|
+
'core_configuration',
|
|
4
|
+
'configuration',
|
|
5
|
+
'config',
|
|
6
|
+
'application',
|
|
7
|
+
'server',
|
|
8
|
+
'selenium_driver',
|
|
9
|
+
'rspec_formatter',
|
|
10
|
+
'command_line_tool',
|
|
11
|
+
'page',
|
|
12
|
+
'path_mapper',
|
|
13
|
+
'asset_pipeline_utility',
|
|
14
|
+
'asset_pipeline_mapper',
|
|
15
|
+
'asset_expander',
|
|
16
|
+
'results_processor',
|
|
17
|
+
'results',
|
|
18
|
+
'path_expander',
|
|
19
|
+
'yaml_config_parser',
|
|
20
|
+
File.join('runners', 'http')]
|
|
21
|
+
|
|
22
|
+
jasmine_files.each do |file|
|
|
23
|
+
require File.join('jasmine', file)
|
|
24
|
+
end
|
|
25
|
+
# jasmine_rack_files.each do |file|
|
|
26
|
+
# require File.join('rack', 'jasmine', file)
|
|
27
|
+
# end
|
|
28
|
+
|
|
29
|
+
require File.join('jasmine', "railtie") if Jasmine::Dependencies.rails3?
|
|
30
|
+
|
|
31
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'rack'
|
|
2
|
+
require 'rack/utils'
|
|
3
|
+
require 'jasmine-core'
|
|
4
|
+
require 'rack/jasmine/runner'
|
|
5
|
+
require 'rack/jasmine/focused_suite'
|
|
6
|
+
require 'rack/jasmine/cache_control'
|
|
7
|
+
require 'ostruct'
|
|
8
|
+
|
|
9
|
+
module Jasmine
|
|
10
|
+
class Application
|
|
11
|
+
def self.app(config, builder = Rack::Builder.new)
|
|
12
|
+
config.rack_apps.each do |(app, config_block)|
|
|
13
|
+
builder.use(app, &config_block)
|
|
14
|
+
end
|
|
15
|
+
config.rack_path_map.each do |path, handler|
|
|
16
|
+
builder.map(path) { run handler.call }
|
|
17
|
+
end
|
|
18
|
+
builder
|
|
19
|
+
end
|
|
20
|
+
end
|
|
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
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Jasmine
|
|
2
|
+
class AssetPipelineMapper
|
|
3
|
+
|
|
4
|
+
def initialize(config, asset_expander)
|
|
5
|
+
@config = config
|
|
6
|
+
@asset_expander = asset_expander
|
|
7
|
+
end
|
|
8
|
+
|
|
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
|
|
14
|
+
|
|
15
|
+
end
|
|
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
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'socket'
|
|
2
|
+
require 'erb'
|
|
3
|
+
|
|
4
|
+
module Jasmine
|
|
5
|
+
# this seemingly-over-complex method is necessary to get an open port on at least some of our Macs
|
|
6
|
+
def self.open_socket_on_unused_port
|
|
7
|
+
infos = Socket::getaddrinfo("localhost", nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM, 0, Socket::AI_PASSIVE)
|
|
8
|
+
families = Hash[*infos.collect { |af, *_| af }.uniq.zip([]).flatten]
|
|
9
|
+
|
|
10
|
+
return TCPServer.open('0.0.0.0', 0) if families.has_key?('AF_INET')
|
|
11
|
+
return TCPServer.open('::', 0) if families.has_key?('AF_INET6')
|
|
12
|
+
return TCPServer.open(0)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.find_unused_port
|
|
16
|
+
socket = open_socket_on_unused_port
|
|
17
|
+
port = socket.addr[1]
|
|
18
|
+
socket.close
|
|
19
|
+
port
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.server_is_listening_on(hostname, port)
|
|
23
|
+
require 'socket'
|
|
24
|
+
begin
|
|
25
|
+
socket = TCPSocket.open(hostname, port)
|
|
26
|
+
rescue Errno::ECONNREFUSED
|
|
27
|
+
return false
|
|
28
|
+
end
|
|
29
|
+
socket.close
|
|
30
|
+
true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.wait_for_listener(port, name = "required process", seconds_to_wait = 20)
|
|
34
|
+
time_out_at = Time.now + seconds_to_wait
|
|
35
|
+
until server_is_listening_on "localhost", port
|
|
36
|
+
sleep 0.1
|
|
37
|
+
puts "Waiting for #{name} on #{port}..."
|
|
38
|
+
raise "#{name} didn't show up on port #{port} after #{seconds_to_wait} seconds." if Time.now > time_out_at
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.runner_filepath
|
|
43
|
+
File.expand_path(File.join(File.dirname(__FILE__), "run_specs.rb"))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.runner_template
|
|
47
|
+
File.read(File.join(File.dirname(__FILE__), "run.html.erb"))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.root(*paths)
|
|
51
|
+
File.expand_path(File.join(File.dirname(__FILE__), *paths))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module Jasmine
|
|
2
|
+
class CommandLineTool
|
|
3
|
+
def cwd
|
|
4
|
+
File.expand_path(File.join(File.dirname(__FILE__), '../..'))
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def expand(*paths)
|
|
8
|
+
File.expand_path(File.join(*paths))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def template_path(filepath)
|
|
12
|
+
expand(cwd, File.join("generators", "jasmine" ,"templates", filepath))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def dest_path(filepath)
|
|
16
|
+
expand(Dir.pwd, filepath)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def copy_unless_exists(relative_path, dest_path = nil)
|
|
20
|
+
unless File.exist?(dest_path(relative_path))
|
|
21
|
+
FileUtils.copy(template_path(relative_path), dest_path(dest_path || relative_path))
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def process(argv)
|
|
26
|
+
if argv[0] == 'init'
|
|
27
|
+
require 'fileutils'
|
|
28
|
+
|
|
29
|
+
FileUtils.makedirs('public/javascripts')
|
|
30
|
+
FileUtils.makedirs('spec/javascripts')
|
|
31
|
+
FileUtils.makedirs('spec/javascripts/support')
|
|
32
|
+
FileUtils.makedirs('spec/javascripts/helpers')
|
|
33
|
+
|
|
34
|
+
copy_unless_exists('jasmine-example/src/Player.js', 'public/javascripts/Player.js')
|
|
35
|
+
copy_unless_exists('jasmine-example/src/Song.js', 'public/javascripts/Song.js')
|
|
36
|
+
copy_unless_exists('jasmine-example/spec/PlayerSpec.js', 'spec/javascripts/PlayerSpec.js')
|
|
37
|
+
copy_unless_exists('jasmine-example/spec/SpecHelper.js', 'spec/javascripts/helpers/SpecHelper.js')
|
|
38
|
+
|
|
39
|
+
rails_tasks_dir = dest_path('lib/tasks')
|
|
40
|
+
if File.exist?(rails_tasks_dir)
|
|
41
|
+
copy_unless_exists('lib/tasks/jasmine.rake')
|
|
42
|
+
copy_unless_exists('spec/javascripts/support/jasmine-rails.yml', 'spec/javascripts/support/jasmine.yml')
|
|
43
|
+
else
|
|
44
|
+
copy_unless_exists('spec/javascripts/support/jasmine.yml')
|
|
45
|
+
require 'rake'
|
|
46
|
+
write_mode = 'w'
|
|
47
|
+
if File.exist?(dest_path('Rakefile'))
|
|
48
|
+
load dest_path('Rakefile')
|
|
49
|
+
write_mode = 'a'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
unless Rake::Task.task_defined?('jasmine')
|
|
53
|
+
File.open(dest_path('Rakefile'), write_mode) do |f|
|
|
54
|
+
f.write("\n" + File.read(template_path('lib/tasks/jasmine.rake')))
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
File.open(template_path('INSTALL'), 'r').each_line do |line|
|
|
59
|
+
puts line
|
|
60
|
+
end
|
|
61
|
+
elsif argv[0] == "license"
|
|
62
|
+
puts File.new(expand(cwd, "MIT.LICENSE")).read
|
|
63
|
+
else
|
|
64
|
+
puts "unknown command #{argv}"
|
|
65
|
+
puts "Usage: jasmine init"
|
|
66
|
+
puts " license"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module Jasmine
|
|
2
|
+
require 'erb'
|
|
3
|
+
def self.configure(&block)
|
|
4
|
+
block.call(self.config)
|
|
5
|
+
end
|
|
6
|
+
|
|
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
|
+
})
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.config
|
|
61
|
+
initialize_config
|
|
62
|
+
@config
|
|
63
|
+
end
|
|
64
|
+
|
|
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)
|
|
70
|
+
end
|
|
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
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
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
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Jasmine
|
|
2
|
+
class CoreConfiguration
|
|
3
|
+
def initialize(core = Jasmine::Core)
|
|
4
|
+
@core = core
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def path
|
|
8
|
+
@core.path
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
#TODO: maybe this doesn't belong in CoreConfig
|
|
12
|
+
def boot_path
|
|
13
|
+
Jasmine.root('javascripts')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def boot_files
|
|
17
|
+
Dir.glob(File.join(boot_path, "**"))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def js_files
|
|
21
|
+
@core.js_files
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def css_files
|
|
25
|
+
@core.css_files
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Jasmine
|
|
2
|
+
module Dependencies
|
|
3
|
+
|
|
4
|
+
class << self
|
|
5
|
+
def rspec2?
|
|
6
|
+
safe_gem_check("rspec", ">= 2.0")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def rails2?
|
|
10
|
+
safe_gem_check("rails", "~> 2.3") && running_rails2?
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def legacy_rails?
|
|
14
|
+
safe_gem_check("rails", "< 2.3.11") && running_legacy_rails?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def rails3?
|
|
18
|
+
safe_gem_check("rails", ">= 3.0") && running_rails3?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def legacy_rack?
|
|
22
|
+
!defined?(Rack::Server)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def rails_3_asset_pipeline?
|
|
26
|
+
rails3? && Rails.respond_to?(:application) && Rails.application.respond_to?(:assets) && Rails.application.assets
|
|
27
|
+
end
|
|
28
|
+
|
|
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
|
+
|
|
47
|
+
def safe_gem_check(gem_name, version_string)
|
|
48
|
+
if Gem::Specification.respond_to?(:find_by_name)
|
|
49
|
+
Gem::Specification.find_by_name(gem_name, version_string)
|
|
50
|
+
elsif Gem.respond_to?(:available?)
|
|
51
|
+
Gem.available?(gem_name, version_string)
|
|
52
|
+
end
|
|
53
|
+
rescue Gem::LoadError
|
|
54
|
+
false
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|