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.
Files changed (91) hide show
  1. data/.gitignore +13 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +58 -0
  4. data/Gemfile +8 -0
  5. data/HOW_TO_TEST.markdown +9 -0
  6. data/MIT.LICENSE +20 -0
  7. data/README.markdown +77 -0
  8. data/RELEASE.markdown +22 -0
  9. data/RELEASE_NOTES.markdown +6 -0
  10. data/Rakefile +62 -0
  11. data/generators/jasmine/jasmine_generator.rb +24 -0
  12. data/generators/jasmine/templates/INSTALL +9 -0
  13. data/generators/jasmine/templates/jasmine-example/SpecRunner.html +54 -0
  14. data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
  15. data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
  16. data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
  17. data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
  18. data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
  19. data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
  20. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +74 -0
  21. data/jasmine.gemspec +74 -0
  22. data/lib/generators/jasmine/examples/USAGE +11 -0
  23. data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
  24. data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Player.js +22 -0
  25. data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Song.js +7 -0
  26. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
  27. data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
  28. data/lib/generators/jasmine/install/USAGE +11 -0
  29. data/lib/generators/jasmine/install/install_generator.rb +18 -0
  30. data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
  31. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +76 -0
  32. data/lib/jasmine.rb +31 -0
  33. data/lib/jasmine/application.rb +21 -0
  34. data/lib/jasmine/asset_expander.rb +19 -0
  35. data/lib/jasmine/asset_pipeline_mapper.rb +16 -0
  36. data/lib/jasmine/asset_pipeline_utility.rb +19 -0
  37. data/lib/jasmine/base.rb +54 -0
  38. data/lib/jasmine/command_line_tool.rb +70 -0
  39. data/lib/jasmine/config.rb +85 -0
  40. data/lib/jasmine/configuration.rb +83 -0
  41. data/lib/jasmine/core_configuration.rb +28 -0
  42. data/lib/jasmine/dependencies.rb +59 -0
  43. data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
  44. data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
  45. data/lib/jasmine/firebug/firebug-license.txt +30 -0
  46. data/lib/jasmine/firebug/firebug.rb +30 -0
  47. data/lib/jasmine/javascripts/boot.js +28 -0
  48. data/lib/jasmine/page.rb +11 -0
  49. data/lib/jasmine/path_expander.rb +18 -0
  50. data/lib/jasmine/path_mapper.rb +29 -0
  51. data/lib/jasmine/railtie.rb +21 -0
  52. data/lib/jasmine/results.rb +19 -0
  53. data/lib/jasmine/results_processor.rb +38 -0
  54. data/lib/jasmine/rspec_formatter.rb +92 -0
  55. data/lib/jasmine/run.html.erb +18 -0
  56. data/lib/jasmine/run_specs.rb +36 -0
  57. data/lib/jasmine/runners/http.rb +71 -0
  58. data/lib/jasmine/selenium_driver.rb +41 -0
  59. data/lib/jasmine/server.rb +20 -0
  60. data/lib/jasmine/tasks/jasmine.rake +55 -0
  61. data/lib/jasmine/tasks/jasmine_rails3.rake +1 -0
  62. data/lib/jasmine/version.rb +3 -0
  63. data/lib/jasmine/yaml_config_parser.rb +54 -0
  64. data/lib/rack/jasmine/cache_control.rb +20 -0
  65. data/lib/rack/jasmine/focused_suite.rb +17 -0
  66. data/lib/rack/jasmine/runner.rb +27 -0
  67. data/spec/application_integration_spec.rb +15 -0
  68. data/spec/application_spec.rb +44 -0
  69. data/spec/asset_expander_spec.rb +42 -0
  70. data/spec/asset_pipeline_mapper_spec.rb +19 -0
  71. data/spec/base_spec.rb +14 -0
  72. data/spec/configuration_spec.rb +163 -0
  73. data/spec/dependencies_spec.rb +315 -0
  74. data/spec/fixture/Rakefile +4 -0
  75. data/spec/jasmine_command_line_tool_rakeless_spec.rb +20 -0
  76. data/spec/jasmine_command_line_tool_spec.rb +29 -0
  77. data/spec/jasmine_pojs_spec.rb +47 -0
  78. data/spec/jasmine_rails2_spec.rb +89 -0
  79. data/spec/jasmine_rails3_spec.rb +69 -0
  80. data/spec/jasmine_self_test_spec.rb +29 -0
  81. data/spec/page_spec.rb +23 -0
  82. data/spec/path_expander_spec.rb +96 -0
  83. data/spec/path_mapper_spec.rb +33 -0
  84. data/spec/rack/jasmine/runner_spec.rb +25 -0
  85. data/spec/results_processor_spec.rb +3 -0
  86. data/spec/results_spec.rb +27 -0
  87. data/spec/rspec_formatter_spec.rb +88 -0
  88. data/spec/server_spec.rb +48 -0
  89. data/spec/spec_helper.rb +55 -0
  90. data/spec/yaml_config_parser_spec.rb +182 -0
  91. metadata +310 -0
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ if Jasmine::Dependencies.rails3?
4
+
5
+ describe "A Rails 3 app" do
6
+
7
+ before :each do
8
+ temp_dir_before
9
+ Dir::chdir @tmp
10
+
11
+ create_rails 'rails-example'
12
+ Dir::chdir 'rails-example'
13
+ open('Gemfile', 'a') { |f| f.puts "gem \"jasmine\", \"#{Jasmine::VERSION}\"" }
14
+ end
15
+
16
+ after :each do
17
+ temp_dir_after
18
+ end
19
+
20
+ context "when Jasmine has been required" do
21
+ it "should show the Jasmine generators" do
22
+ output = `rails g`
23
+ output.should include("jasmine:install")
24
+ output.should include("jasmine:examples")
25
+ end
26
+
27
+ it "should show jasmine:install help" do
28
+ output = `rails g jasmine:install --help`
29
+ output.should include("rails generate jasmine:install")
30
+ end
31
+
32
+ it "should have the jasmine rake task" do
33
+ output = `rake -T`
34
+ output.should include("jasmine ")
35
+ end
36
+
37
+ it "should have the jasmine:ci rake task" do
38
+ output = `rake -T`
39
+ output.should include("jasmine:ci")
40
+ end
41
+
42
+ context "and then installed" do
43
+ before :each do
44
+ @output = `rails g jasmine:install`
45
+ end
46
+
47
+ it "should have the Jasmine config files" do
48
+ @output.should include("create")
49
+
50
+ File.exists?("spec/javascripts/helpers/.gitkeep").should == true
51
+ File.exists?("spec/javascripts/support/jasmine.yml").should == true
52
+ end
53
+ end
54
+
55
+ context "and the jasmine examples have been installed" do
56
+ it "should find the Jasmine example files" do
57
+ output = `rails g jasmine:examples`
58
+ output.should include("create")
59
+
60
+ File.exists?("app/assets/javascripts/jasmine_examples/Player.js").should == true
61
+ File.exists?("app/assets/javascripts/jasmine_examples/Song.js").should == true
62
+
63
+ File.exists?("spec/javascripts/jasmine_examples/PlayerSpec.js").should == true
64
+ File.exists?("spec/javascripts/helpers/SpecHelper.js").should == true
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ Jasmine.configure do |config|
4
+ root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
5
+ config.src_dir = File.join(root, 'src')
6
+ config.spec_dir = Jasmine::Core.path
7
+ config.spec_files = lambda { (Jasmine::Core.html_spec_files + Jasmine::Core.core_spec_files).map {|f| File.join(config.spec_dir, f) } }
8
+ end
9
+
10
+ config = Jasmine.config
11
+
12
+ server = Jasmine::Server.new(config.port, Jasmine::Application.app(config))
13
+ driver = Jasmine::SeleniumDriver.new(config.browser, "#{config.host}:#{config.port}/")
14
+
15
+ t = Thread.new do
16
+ begin
17
+ server.start
18
+ rescue ChildProcess::TimeoutError
19
+ end
20
+ # # ignore bad exits
21
+ end
22
+ t.abort_on_exception = true
23
+ Jasmine::wait_for_listener(config.port, "jasmine server")
24
+ puts "jasmine server started."
25
+
26
+ results_processor = Jasmine::ResultsProcessor.new(config)
27
+ results = Jasmine::Runners::HTTP.new(driver, results_processor, config.result_batch_size).run
28
+ formatter = Jasmine::RspecFormatter.new
29
+ formatter.format_results(results)
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'nokogiri'
3
+ require 'ostruct'
4
+
5
+ describe Jasmine::Page do
6
+ describe "#render" do
7
+ subject { Nokogiri::HTML(page.render) }
8
+ let(:fake_config) do
9
+ OpenStruct.new(:js_files => ["file1.js", "file2.js"], :css_files => ["file1.css", "file2.css"])
10
+ end
11
+ let(:context) { fake_config }
12
+ let(:page) { Jasmine::Page.new(context) }
13
+ it "should render javascript files in the correct order" do
14
+ js_files = subject.css("script")
15
+ js_files.map { |file| file["src"] }.compact.should == ["file1.js", "file2.js"]
16
+ end
17
+
18
+ it "should render css files in the correct order" do
19
+ css_files = subject.css("link[type='text/css']")
20
+ css_files.map { |file| file["href"] }.compact.should == ["file1.css", "file2.css"]
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::PathExpander do
4
+ it "returns absolute paths" do
5
+ dir_glob = lambda do |pattern|
6
+ case pattern
7
+ when 'some_base/src1*'
8
+ ['some_base/src1.js', 'some_base/src15.js']
9
+ when 'some_base/src2*'
10
+ ['some_base/src2.js']
11
+ else
12
+ raise "Unexpected pattern received: #{pattern}"
13
+ end
14
+ end
15
+
16
+ expanded_files = Jasmine::PathExpander.expand(
17
+ 'some_base',
18
+ ['src1*', 'src2*'],
19
+ dir_glob
20
+ )
21
+
22
+ expanded_files.should == [
23
+ File.join('some_base', 'src1.js'),
24
+ File.join('some_base', 'src15.js'),
25
+ File.join('some_base', 'src2.js')
26
+ ]
27
+ end
28
+
29
+ it "uniqs files" do
30
+ dir_glob = lambda do |pattern|
31
+ case pattern
32
+ when 'some_base/src1*'
33
+ ['some_base/src1.js', 'some_base/src15.js', 'some_base/src1.js']
34
+ when 'some_base/src2*'
35
+ ['some_base/src2.js']
36
+ else
37
+ raise "Unexpected pattern received: #{pattern}"
38
+ end
39
+ end
40
+
41
+ expanded_files = Jasmine::PathExpander.expand(
42
+ 'some_base',
43
+ ['src1*', 'src2*'],
44
+ dir_glob
45
+ )
46
+
47
+ expanded_files.should == [
48
+ File.join('some_base', 'src1.js'),
49
+ File.join('some_base', 'src15.js'),
50
+ File.join('some_base', 'src2.js')
51
+ ]
52
+ end
53
+
54
+ it "supports negation of passed patterns" do
55
+ dir_glob = lambda do |pattern|
56
+ case pattern
57
+ when 'some_base/src1*'
58
+ ['some_base/src1.js', 'some_base/src15.js']
59
+ when 'some_base/src1.js'
60
+ ['some_base/src1.js']
61
+ when 'some_base/src2*'
62
+ ['some_base/src2.js']
63
+ else
64
+ raise "Unexpected pattern received: #{pattern}"
65
+ end
66
+ end
67
+
68
+ expanded_files = Jasmine::PathExpander.expand(
69
+ 'some_base',
70
+ ['src1*', '!src1.js', 'src2*'],
71
+ dir_glob
72
+ )
73
+
74
+ expanded_files.should == [
75
+ File.join('some_base', 'src15.js'),
76
+ File.join('some_base', 'src2.js')
77
+ ]
78
+ end
79
+
80
+ it "passes through files that are not found by the globber and are not negations and not globs" do
81
+ #this is designed to support asset pipeline files that aren't found.
82
+ dir_glob = lambda do |pattern|
83
+ []
84
+ end
85
+
86
+ expanded_files = Jasmine::PathExpander.expand(
87
+ 'some_base',
88
+ ['src1*', '!src1.js', 'src2.js'],
89
+ dir_glob
90
+ )
91
+
92
+ expanded_files.should == [
93
+ File.join('some_base', 'src2.js')
94
+ ]
95
+ end
96
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::PathMapper do
4
+ it "correctly remaps src files" do
5
+ config = double(:config, :src_dir => '/src_dir', :src_path => '/__src__')
6
+ mapper = Jasmine::PathMapper.new(config)
7
+ mapper.map_src_paths(['/src_dir/foo']).should == ['/__src__/foo']
8
+ mapper.map_src_paths(['foo/bar']).should == ['/__src__/foo/bar']
9
+ end
10
+ it "correctly remaps spec files" do
11
+ config = double(:config, :spec_dir => '/spec_dir', :spec_path => '/__spec__')
12
+ mapper = Jasmine::PathMapper.new(config)
13
+ mapper.map_spec_paths(['/spec_dir/foo']).should == ['/__spec__/foo']
14
+ mapper.map_spec_paths(['foo/bar']).should == ['/__spec__/foo/bar']
15
+ end
16
+ it "correctly remaps jasmine files" do
17
+ config = double(:config, :jasmine_dir => '/jasmine_dir', :jasmine_path => '/__jasmine__')
18
+ mapper = Jasmine::PathMapper.new(config)
19
+ mapper.map_jasmine_paths(['/jasmine_dir/foo']).should == ['/__jasmine__/foo']
20
+ mapper.map_jasmine_paths(['foo/bar']).should == ['/__jasmine__/foo/bar']
21
+ end
22
+ it "correctly remaps boot files" do
23
+ config = double(:config, :boot_dir => '/boot_dir', :boot_path => '/__boot__')
24
+ mapper = Jasmine::PathMapper.new(config)
25
+ mapper.map_boot_paths(['/boot_dir/foo']).should == ['/__boot__/foo']
26
+ mapper.map_boot_paths(['foo/bar']).should == ['/__boot__/foo/bar']
27
+ end
28
+ it "handles edge case where dir == path" do
29
+ config = double(:config, :src_dir => '/src_dir', :src_path => '/src_dir')
30
+ mapper = Jasmine::PathMapper.new(config)
31
+ mapper.map_src_paths(['/src_dir/foo']).should == ['/src_dir/foo']
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'rack/jasmine/runner'
3
+
4
+ describe Rack::Jasmine::Runner do
5
+ describe "#call" do
6
+ let(:content) { "some content" }
7
+ let(:page) { double(Jasmine::Page, :render => content)}
8
+ let(:runner) { Rack::Jasmine::Runner.new(page)}
9
+ subject { runner.call("PATH_INFO" => path) }
10
+ context "PATH_INFO is /" do
11
+ let(:expected_headers) { {"Content-Type" => "text/html"} }
12
+ let(:path) { "/" }
13
+ it "should return a response with the passed content" do
14
+ subject.should == [200, expected_headers, [content]]
15
+ end
16
+ end
17
+ context "PATH_INFO is not /" do
18
+ let(:path) { "/some_foo" }
19
+ let(:expected_headers) { {"Content-Type" => "text/plain", "X-Cascade" => "pass"} }
20
+ it "should return a 404" do
21
+ subject.should == [404, expected_headers, ["File not found: #{path}\n"]]
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ describe Jasmine::ResultsProcessor do
2
+
3
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Results do
4
+ it "should be able to return suites" do
5
+ suites = {:some => 'suite'}
6
+ Jasmine::Results.new({}, suites, {}).suites.should == suites
7
+ end
8
+
9
+ it "should return a result for a particular spec id" do
10
+ result1 = {:some => 'result'}
11
+ result2 = {:some => 'other result'}
12
+ raw_results = {'1' => result1, '2' => result2 }
13
+ results = Jasmine::Results.new(raw_results, {}, {})
14
+ results.for_spec_id('1').should == result1
15
+ results.for_spec_id('2').should == result2
16
+ end
17
+
18
+ it "should return an example location for a particular string" do
19
+ example_location1 = {:some => 'spec location'}
20
+ example_location2 = {:some => 'other spec location'}
21
+ example_locations = {'foo bar' => example_location1, 'baz quux' => example_location2 }
22
+ results = Jasmine::Results.new({}, {}, example_locations)
23
+ results.example_location_for('foo bar').should == example_location1
24
+ results.example_location_for('baz quux').should == example_location2
25
+ end
26
+ end
27
+
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::RspecFormatter do
4
+ describe "environment variables" do
5
+ def stub_env_hash(hash)
6
+ ENV.stub!(:[]) do |arg|
7
+ hash[arg]
8
+ end
9
+ end
10
+ describe "browser configuration" do
11
+ it "should use firefox by default" do
12
+ pending
13
+ stub_env_hash({"JASMINE_BROWSER" => nil})
14
+ config = double('config')
15
+ formatter = Jasmine::RspecFormatter.new(config)
16
+ Jasmine::SeleniumDriver.should_receive(:new).
17
+ with("firefox", anything).
18
+ and_return(mock(Jasmine::SeleniumDriver, :connect => true))
19
+ formatter.start
20
+ end
21
+
22
+ it "should use ENV['JASMINE_BROWSER'] if set" do
23
+ pending
24
+ stub_env_hash({"JASMINE_BROWSER" => "mosaic"})
25
+
26
+ Jasmine::SeleniumDriver.should_receive(:new).
27
+ with("mosaic", anything).
28
+ and_return(mock(Jasmine::SeleniumDriver, :connect => true))
29
+ formatter.start
30
+ end
31
+ end
32
+
33
+ describe "jasmine host" do
34
+ it "should use http://localhost by default" do
35
+ pending
36
+ stub_env_hash({})
37
+ config = Jasmine::Config.new
38
+ config.instance_variable_set(:@jasmine_server_port, '1234')
39
+ config.stub!(:start_jasmine_server)
40
+
41
+ Jasmine::SeleniumDriver.should_receive(:new).
42
+ with(anything, "http://localhost:1234/").
43
+ and_return(mock(Jasmine::SeleniumDriver, :connect => true))
44
+ config.start
45
+ end
46
+
47
+ it "should use ENV['JASMINE_HOST'] if set" do
48
+ pending
49
+ stub_env_hash({"JASMINE_HOST" => "http://some_host"})
50
+ config = Jasmine::Config.new
51
+ config.instance_variable_set(:@jasmine_server_port, '1234')
52
+ config.stub!(:start_jasmine_server)
53
+
54
+ Jasmine::SeleniumDriver.should_receive(:new).
55
+ with(anything, "http://some_host:1234/").
56
+ and_return(mock(Jasmine::SeleniumDriver, :connect => true))
57
+ config.start
58
+ end
59
+
60
+ it "should use ENV['JASMINE_PORT'] if set" do
61
+ pending
62
+ stub_env_hash({"JASMINE_PORT" => "4321"})
63
+ config = Jasmine::Config.new
64
+ Jasmine.stub!(:wait_for_listener)
65
+ config.stub!(:start_server)
66
+ Jasmine::SeleniumDriver.should_receive(:new).
67
+ with(anything, "http://localhost:4321/").
68
+ and_return(mock(Jasmine::SeleniumDriver, :connect => true))
69
+ config.start
70
+ end
71
+ end
72
+
73
+ describe "external selenium server" do
74
+ it "should use an external selenium server if SELENIUM_SERVER is set" do
75
+ pending
76
+ stub_env_hash({"SELENIUM_SERVER" => "http://myseleniumserver.com:4441"})
77
+ Selenium::WebDriver.should_receive(:for).with(:remote, :url => "http://myseleniumserver.com:4441", :desired_capabilities => :firefox)
78
+ Jasmine::SeleniumDriver.new('firefox', 'http://localhost:8888')
79
+ end
80
+ it "should use an local selenium server with a specific port if SELENIUM_SERVER_PORT is set" do
81
+ pending
82
+ stub_env_hash({"SELENIUM_SERVER_PORT" => "4441"})
83
+ Selenium::WebDriver.should_receive(:for).with(:remote, :url => "http://localhost:4441/wd/hub", :desired_capabilities => :firefox)
84
+ Jasmine::SeleniumDriver.new('firefox', 'http://localhost:8888')
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Server do
4
+ describe "rack ~> 1.0" do
5
+ before do
6
+ Jasmine::Dependencies.stub(:legacy_rack?).and_return(true)
7
+ end
8
+
9
+ it "should run the handler with the application" do
10
+ server = double(:server)
11
+ port = 1234
12
+ application = double(:application)
13
+ Rack::Handler.should_receive(:get).with("webrick").and_return(server)
14
+ server.should_receive(:run).with(application, hash_including(:Port => port))
15
+ Jasmine::Server.new(port, application).start
16
+ end
17
+ end
18
+
19
+ describe "rack >= 1.1" do
20
+ before do
21
+ Jasmine::Dependencies.stub(:legacy_rack?).and_return(false)
22
+ if !Rack.constants.include?(:Server)
23
+ Rack::Server = double("Rack::Server")
24
+ end
25
+ end
26
+
27
+ it "should create a Rack::Server with the correct port when passed" do
28
+ port = 1234
29
+ Rack::Server.should_receive(:new).with(hash_including(:Port => port)).and_return(double(:server).as_null_object)
30
+ Jasmine::Server.new(port, double(:app)).start
31
+ end
32
+
33
+ it "should start the server" do
34
+ server = double(:server)
35
+ Rack::Server.should_receive(:new) { server.as_null_object }
36
+ server.should_receive(:start)
37
+ Jasmine::Server.new('8888', double(:app)).start
38
+ end
39
+
40
+ it "should set the app as the instance variable on the rack server" do
41
+ app = double('application')
42
+ server = double(:server)
43
+ Rack::Server.should_receive(:new) { server.as_null_object }
44
+ Jasmine::Server.new(1234, app).start
45
+ server.instance_variable_get(:@app).should == app
46
+ end
47
+ end
48
+ end