jasmine-multi_json 1.3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,41 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class SeleniumDriver
|
3
|
+
def initialize(browser, http_address)
|
4
|
+
require 'selenium-webdriver'
|
5
|
+
selenium_server = if ENV['SELENIUM_SERVER']
|
6
|
+
ENV['SELENIUM_SERVER']
|
7
|
+
elsif ENV['SELENIUM_SERVER_PORT']
|
8
|
+
"http://localhost:#{ENV['SELENIUM_SERVER_PORT']}/wd/hub"
|
9
|
+
end
|
10
|
+
options = if browser == "firefox" && ENV["JASMINE_FIREBUG"]
|
11
|
+
require File.join(File.dirname(__FILE__), "firebug/firebug")
|
12
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
13
|
+
profile.enable_firebug
|
14
|
+
{:profile => profile}
|
15
|
+
end || {}
|
16
|
+
@driver = if selenium_server
|
17
|
+
Selenium::WebDriver.for :remote, :url => selenium_server, :desired_capabilities => browser.to_sym
|
18
|
+
else
|
19
|
+
Selenium::WebDriver.for browser.to_sym, options
|
20
|
+
end
|
21
|
+
@http_address = http_address
|
22
|
+
end
|
23
|
+
|
24
|
+
def connect
|
25
|
+
@driver.navigate.to @http_address
|
26
|
+
end
|
27
|
+
|
28
|
+
def disconnect
|
29
|
+
@driver.quit
|
30
|
+
end
|
31
|
+
|
32
|
+
def eval_js(script)
|
33
|
+
result = @driver.execute_script(script)
|
34
|
+
MultiJson.load("{\"result\":#{result}}", :max_nesting => false)["result"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def json_generate(obj)
|
38
|
+
MultiJson.dump(obj)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class Server
|
3
|
+
def initialize(port = 8888, application = nil)
|
4
|
+
@port = port
|
5
|
+
@application = application
|
6
|
+
end
|
7
|
+
|
8
|
+
def start
|
9
|
+
if Jasmine::Dependencies.legacy_rack?
|
10
|
+
handler = Rack::Handler.get('webrick')
|
11
|
+
handler.run(@application, :Port => @port, :AccessLog => [])
|
12
|
+
else
|
13
|
+
server = Rack::Server.new(:Port => @port, :AccessLog => [])
|
14
|
+
# workaround for Rack bug, when Rack > 1.2.1 is released Rack::Server.start(:app => Jasmine.app(self)) will work
|
15
|
+
server.instance_variable_set(:@app, @application)
|
16
|
+
server.start
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
namespace :jasmine do
|
2
|
+
task :require do
|
3
|
+
require 'jasmine'
|
4
|
+
end
|
5
|
+
|
6
|
+
task :require_json do
|
7
|
+
begin
|
8
|
+
require 'multi_json'
|
9
|
+
rescue LoadError
|
10
|
+
puts "You must have a JSON library installed to run jasmine:ci. Try \"gem install multi_json\""
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Run continuous integration tests"
|
16
|
+
task :ci => ["jasmine:require_json", "jasmine:require"] do
|
17
|
+
if Jasmine::Dependencies.rspec2?
|
18
|
+
require "rspec"
|
19
|
+
require "rspec/core/rake_task"
|
20
|
+
else
|
21
|
+
require "spec"
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
end
|
24
|
+
|
25
|
+
if Jasmine::Dependencies.rspec2?
|
26
|
+
RSpec::Core::RakeTask.new(:jasmine_continuous_integration_runner) do |t|
|
27
|
+
t.rspec_opts = ["--colour", "--format", ENV['JASMINE_SPEC_FORMAT'] || "progress"]
|
28
|
+
t.verbose = true
|
29
|
+
if Jasmine::Dependencies.rails_3_asset_pipeline?
|
30
|
+
t.rspec_opts += ["-r #{File.expand_path(File.join(::Rails.root, 'config', 'environment'))}"]
|
31
|
+
end
|
32
|
+
t.pattern = [Jasmine.runner_filepath]
|
33
|
+
end
|
34
|
+
else
|
35
|
+
Spec::Rake::SpecTask.new(:jasmine_continuous_integration_runner) do |t|
|
36
|
+
t.spec_opts = ["--color", "--format", ENV['JASMINE_SPEC_FORMAT'] || "specdoc"]
|
37
|
+
t.verbose = true
|
38
|
+
t.spec_files = [Jasmine.runner_filepath]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
Rake::Task["jasmine_continuous_integration_runner"].invoke
|
42
|
+
end
|
43
|
+
|
44
|
+
task :server => "jasmine:require" do
|
45
|
+
port = ENV['JASMINE_PORT'] || 8888
|
46
|
+
puts "your tests are here:"
|
47
|
+
puts " http://localhost:#{port}/"
|
48
|
+
Jasmine.load_configuration_from_yaml
|
49
|
+
app = Jasmine::Application.app(Jasmine.config)
|
50
|
+
Jasmine::Server.new(port, app).start
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Run specs via server"
|
55
|
+
task :jasmine => ['jasmine:server']
|
@@ -0,0 +1 @@
|
|
1
|
+
task "jasmine:require" => [:environment]
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class YamlConfigParser
|
3
|
+
def initialize(path, pwd, path_expander = lambda {}, yaml_loader = lambda {})
|
4
|
+
@path = path
|
5
|
+
@path_expander = path_expander
|
6
|
+
@pwd = pwd
|
7
|
+
@yaml_loader = yaml_loader
|
8
|
+
end
|
9
|
+
|
10
|
+
def src_dir
|
11
|
+
return @pwd unless loaded_yaml['src_dir']
|
12
|
+
File.join(@pwd, loaded_yaml['src_dir'])
|
13
|
+
end
|
14
|
+
|
15
|
+
def spec_dir
|
16
|
+
return File.join(@pwd, 'spec', 'javascripts') unless loaded_yaml['spec_dir']
|
17
|
+
File.join(@pwd, loaded_yaml['spec_dir'])
|
18
|
+
end
|
19
|
+
|
20
|
+
def jasmine_dir
|
21
|
+
return nil unless loaded_yaml['jasmine_dir']
|
22
|
+
File.join(@pwd, loaded_yaml['jasmine_dir'])
|
23
|
+
end
|
24
|
+
|
25
|
+
def src_files
|
26
|
+
@path_expander.call(src_dir, loaded_yaml['src_files'] || [])
|
27
|
+
end
|
28
|
+
|
29
|
+
def jasmine_files
|
30
|
+
@path_expander.call(jasmine_dir, loaded_yaml['jasmine_files'] || [])
|
31
|
+
end
|
32
|
+
|
33
|
+
def jasmine_css_files
|
34
|
+
@path_expander.call(jasmine_dir, loaded_yaml['jasmine_css_files'] || [])
|
35
|
+
end
|
36
|
+
|
37
|
+
def spec_files
|
38
|
+
@path_expander.call(spec_dir, loaded_yaml['spec_files'] || [])
|
39
|
+
end
|
40
|
+
|
41
|
+
def helpers
|
42
|
+
@path_expander.call(spec_dir, loaded_yaml['helpers'] || [])
|
43
|
+
end
|
44
|
+
|
45
|
+
def css_files
|
46
|
+
@path_expander.call(src_dir, loaded_yaml['stylesheets'] || [])
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def loaded_yaml
|
51
|
+
@yaml_loader.call(@path)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Rack
|
2
|
+
module Jasmine
|
3
|
+
|
4
|
+
class CacheControl
|
5
|
+
def initialize(app)
|
6
|
+
@app, @content_type = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
status, headers, body = @app.call(env)
|
11
|
+
headers = Rack::Utils::HeaderHash.new(headers)
|
12
|
+
headers['Cache-Control'] ||= "max-age=0, private, must-revalidate"
|
13
|
+
headers['Pragma'] ||= "no-cache"
|
14
|
+
[status, headers, body]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rack
|
2
|
+
module Jasmine
|
3
|
+
|
4
|
+
class FocusedSuite
|
5
|
+
def initialize(runner_config)
|
6
|
+
@runner_config = runner_config
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
run_adapter = Rack::Jasmine::RunAdapter.new(@runner_config)
|
11
|
+
run_adapter.run(env["PATH_INFO"])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rack
|
2
|
+
module Jasmine
|
3
|
+
|
4
|
+
class Runner
|
5
|
+
def initialize(page)
|
6
|
+
@page = page
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
@path = env["PATH_INFO"]
|
11
|
+
return not_found if @path != "/"
|
12
|
+
[
|
13
|
+
200,
|
14
|
+
{ 'Content-Type' => 'text/html'},
|
15
|
+
[@page.render]
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
def not_found
|
20
|
+
[404, {"Content-Type" => "text/plain",
|
21
|
+
"X-Cascade" => "pass"},
|
22
|
+
["File not found: #{@path}\n"]]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Jasmine::Application" do
|
4
|
+
|
5
|
+
it "includes no-cache headers for specs" do
|
6
|
+
pending
|
7
|
+
get "/__spec__/example_spec.js"
|
8
|
+
last_response.headers.should have_key("Cache-Control")
|
9
|
+
last_response.headers["Cache-Control"].should == "max-age=0, private, must-revalidate"
|
10
|
+
last_response.headers['Pragma'].each do |key|
|
11
|
+
last_response.headers[key].should == 'no-cache'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#Rspec 1 doesn't correctly pass blocks to stubs, so skip (covered by integration tests)
|
4
|
+
#https://groups.google.com/forum/?fromgroups=#!topic/rspec/XT7paH2asCo
|
5
|
+
|
6
|
+
if Jasmine::Dependencies.rspec2?
|
7
|
+
describe "Jasmine::Application" do
|
8
|
+
it "should map paths provided by the config" do
|
9
|
+
handler1 = double(:handler1)
|
10
|
+
handler2 = double(:handler2)
|
11
|
+
app1 = double(:app1)
|
12
|
+
app2 = double(:app2)
|
13
|
+
rack_path_map = {"/foo" => lambda { handler1 }, "/bar" => lambda { handler2 }}
|
14
|
+
config = double(:config, :rack_path_map => rack_path_map, :rack_apps => [])
|
15
|
+
builder = double("Rack::Builder.new")
|
16
|
+
#Rack::Builder instance evals, so builder.run is invalid syntax,
|
17
|
+
#this is the only way to stub out the 'run' dsl it gives to the block.
|
18
|
+
Jasmine::Application.stub(:run).with(handler1).and_return(app1)
|
19
|
+
Jasmine::Application.stub(:run).with(handler2).and_return(app2)
|
20
|
+
|
21
|
+
builder.should_receive(:map).twice do |path, &app|
|
22
|
+
if path == '/foo'
|
23
|
+
app.call.should == app1
|
24
|
+
elsif path == '/bar'
|
25
|
+
app.call.should == app2
|
26
|
+
else
|
27
|
+
raise "Unexpected path passed"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Jasmine::Application.app(config, builder).should == builder
|
32
|
+
end
|
33
|
+
it "should run rack apps provided by the config" do
|
34
|
+
app1 = double(:app1)
|
35
|
+
app2 = double(:app2)
|
36
|
+
block = lambda { "foo" }
|
37
|
+
config = double(:config, :rack_path_map => [], :rack_apps => [[app1, nil], [app2, block]])
|
38
|
+
builder = double("Rack::Builder.new")
|
39
|
+
builder.should_receive(:use).with(app1)
|
40
|
+
builder.should_receive(:use).with(app2, &block)
|
41
|
+
Jasmine::Application.app(config, builder).should == builder
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jasmine::AssetExpander do
|
4
|
+
it "expands asset files" do
|
5
|
+
bundled_asset = double(:bundled_asset,
|
6
|
+
:to_a => ['asset1', 'asset2'],
|
7
|
+
:pathname => double(:pathname, :to_s => '/some_src_dir/asset_file'))
|
8
|
+
|
9
|
+
bundled_asset_getter = lambda do |filepath, ext|
|
10
|
+
if filepath == 'asset_file' && ext == 'js'
|
11
|
+
bundled_asset
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
asset_path_getter = lambda do |asset|
|
16
|
+
if asset == 'asset1'
|
17
|
+
'asset1_path'
|
18
|
+
elsif asset == 'asset2'
|
19
|
+
'asset2_path'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
expander = Jasmine::AssetExpander.new(bundled_asset_getter, asset_path_getter)
|
24
|
+
expanded_assets = expander.expand('/some_src_dir', 'asset_file')
|
25
|
+
expanded_assets.should == ['/asset_file?body=true',
|
26
|
+
'/asset1_path?body=true',
|
27
|
+
'/asset2_path?body=true']
|
28
|
+
end
|
29
|
+
|
30
|
+
it "return nil if no bundled asset is found" do
|
31
|
+
bundled_asset = nil
|
32
|
+
bundled_asset_getter = lambda do |filepath, ext|
|
33
|
+
if filepath == 'asset_file' && ext == 'js'
|
34
|
+
bundled_asset
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
expander = Jasmine::AssetExpander.new(bundled_asset_getter, lambda {})
|
39
|
+
expanded_assets = expander.expand('/some_src_dir', 'asset_file')
|
40
|
+
expanded_assets.should be_nil
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jasmine::AssetPipelineMapper do
|
4
|
+
it "expands asset paths if available" do
|
5
|
+
expander = lambda do |dir, path|
|
6
|
+
if dir == "/some_location/" && path == 'asset1'
|
7
|
+
['asset1', 'asset2']
|
8
|
+
elsif dir == "/some_location/" && path == 'asset2'
|
9
|
+
['asset1', 'asset3']
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
config = double(:config, :src_dir => "/some_location/")
|
14
|
+
|
15
|
+
mapper = Jasmine::AssetPipelineMapper.new(config, expander)
|
16
|
+
|
17
|
+
mapper.map_src_paths(['asset1', 'asset2', 'asset4']).should == ['asset1', 'asset2', 'asset3', 'asset4']
|
18
|
+
end
|
19
|
+
end
|
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jasmine do
|
4
|
+
it "should provide the root path" do
|
5
|
+
File.stub(:dirname).and_return('lib/jasmine')
|
6
|
+
File.should_receive(:expand_path) { |path| path }
|
7
|
+
Jasmine.root.should == 'lib/jasmine'
|
8
|
+
end
|
9
|
+
it "should append passed file paths" do
|
10
|
+
File.stub(:dirname).and_return('lib/jasmine')
|
11
|
+
File.should_receive(:expand_path) { |path| path }
|
12
|
+
Jasmine.root('subdir1', 'subdir2').should == File.join('lib/jasmine', 'subdir1', 'subdir2')
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jasmine::Configuration do
|
4
|
+
let(:test_mapper1) do
|
5
|
+
Class.new do
|
6
|
+
def initialize(config)
|
7
|
+
@config = config
|
8
|
+
end
|
9
|
+
def map_src_paths(paths)
|
10
|
+
paths.map { |f| "mapped_src/#{f}" }
|
11
|
+
end
|
12
|
+
def map_jasmine_paths(paths)
|
13
|
+
paths.map { |f| "mapped_jasmine/#{f}" }
|
14
|
+
end
|
15
|
+
def map_spec_paths(paths)
|
16
|
+
paths.map { |f| "mapped_spec/#{f}" }
|
17
|
+
end
|
18
|
+
def map_boot_paths(paths)
|
19
|
+
paths.map { |f| "mapped_boot/#{f}" }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
let(:test_mapper2) do
|
24
|
+
Class.new do
|
25
|
+
def initialize(config)
|
26
|
+
@config = config
|
27
|
+
end
|
28
|
+
def map_src_paths(paths)
|
29
|
+
paths.map { |f| "#{f}/src" }
|
30
|
+
end
|
31
|
+
def map_jasmine_paths(paths)
|
32
|
+
paths.map { |f| "#{f}/jasmine" }
|
33
|
+
end
|
34
|
+
def map_spec_paths(paths)
|
35
|
+
paths.map { |f| "#{f}/spec" }
|
36
|
+
end
|
37
|
+
def map_boot_paths(paths)
|
38
|
+
paths.map { |f| "#{f}/boot" }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
let(:test_mapper3) do
|
43
|
+
Class.new do
|
44
|
+
def initialize(config)
|
45
|
+
@config = config
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "returning css files" do
|
51
|
+
it "returns mapped jasmine_css_files + css_files" do
|
52
|
+
config = Jasmine::Configuration.new()
|
53
|
+
config.add_path_mapper(lambda { |c| test_mapper1.new(c) })
|
54
|
+
config.add_path_mapper(lambda { |c| test_mapper2.new(c) })
|
55
|
+
config.add_path_mapper(lambda { |c| test_mapper3.new(c) })
|
56
|
+
config.css_files.should == []
|
57
|
+
config.jasmine_css_files = lambda { ["jasmine_css"] }
|
58
|
+
config.css_files = lambda { ["css"] }
|
59
|
+
config.css_files.should == ['mapped_jasmine/jasmine_css/jasmine', 'mapped_src/css/src']
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "returning javascript files" do
|
64
|
+
it "returns the jasmine core files, then srcs, then specs, then boot" do
|
65
|
+
config = Jasmine::Configuration.new()
|
66
|
+
config.add_path_mapper(lambda { |c| test_mapper1.new(c) })
|
67
|
+
config.add_path_mapper(lambda { |c| test_mapper2.new(c) })
|
68
|
+
config.add_path_mapper(lambda { |c| test_mapper3.new(c) })
|
69
|
+
config.js_files.should == []
|
70
|
+
config.jasmine_files = lambda { ['jasmine'] }
|
71
|
+
config.src_files = lambda { ['src'] }
|
72
|
+
config.boot_files = lambda { ['boot'] }
|
73
|
+
config.spec_files = lambda { ['spec'] }
|
74
|
+
config.js_files.should == [
|
75
|
+
'mapped_jasmine/jasmine/jasmine',
|
76
|
+
'mapped_src/src/src',
|
77
|
+
'mapped_spec/spec/spec',
|
78
|
+
'mapped_boot/boot/boot',
|
79
|
+
]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "returning rack map" do
|
84
|
+
it "permits arbitrary rack app path mapping" do
|
85
|
+
config = Jasmine::Configuration.new()
|
86
|
+
result = double
|
87
|
+
config.add_rack_path('some/path', lambda { result })
|
88
|
+
map = config.rack_path_map
|
89
|
+
map['some/path'].should be
|
90
|
+
map['some/path'].call.should == result
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "rack apps" do
|
96
|
+
it "permits the addition of arbitary rack apps" do
|
97
|
+
config = Jasmine::Configuration.new()
|
98
|
+
app = double
|
99
|
+
config.add_rack_app(app)
|
100
|
+
config.rack_apps.should == [[app, nil]]
|
101
|
+
end
|
102
|
+
it "permits the addition of arbitary rack apps with arbitrary config" do
|
103
|
+
config = Jasmine::Configuration.new()
|
104
|
+
app = double
|
105
|
+
block = lambda { "foo" }
|
106
|
+
config.add_rack_app(app, &block)
|
107
|
+
config.rack_apps.should == [[app, block]]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "port" do
|
112
|
+
it "returns new port and caches return value" do
|
113
|
+
config = Jasmine::Configuration.new()
|
114
|
+
Jasmine.stub(:find_unused_port).and_return('1234')
|
115
|
+
config.port.should == '1234'
|
116
|
+
Jasmine.stub(:find_unused_port).and_return('4321')
|
117
|
+
config.port.should == '1234'
|
118
|
+
end
|
119
|
+
it "returns port if configured" do
|
120
|
+
config = Jasmine::Configuration.new()
|
121
|
+
config.port = '5678'
|
122
|
+
Jasmine.stub(:find_unused_port).and_return('1234')
|
123
|
+
config.port.should == '5678'
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "browser" do
|
128
|
+
it "should default to firefox" do
|
129
|
+
Jasmine::Configuration.new().browser.should == 'firefox'
|
130
|
+
end
|
131
|
+
|
132
|
+
it "returns browser if set" do
|
133
|
+
config = Jasmine::Configuration.new()
|
134
|
+
config.browser = 'foo'
|
135
|
+
config.browser.should == 'foo'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "result_batch_size" do
|
140
|
+
it "should default to 50" do
|
141
|
+
Jasmine::Configuration.new().result_batch_size.should == 50
|
142
|
+
end
|
143
|
+
|
144
|
+
it "returns result_batch_size if set" do
|
145
|
+
config = Jasmine::Configuration.new()
|
146
|
+
config.result_batch_size = 25
|
147
|
+
config.result_batch_size.should == 25
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "host" do
|
152
|
+
it "should default to localhost" do
|
153
|
+
Jasmine::Configuration.new().host.should == 'http://localhost'
|
154
|
+
end
|
155
|
+
|
156
|
+
it "returns host if set" do
|
157
|
+
config = Jasmine::Configuration.new()
|
158
|
+
config.host = 'foo'
|
159
|
+
config.host.should == 'foo'
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|