rally-jasmine 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) 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 +53 -0
  11. data/bin/jasmine +6 -0
  12. data/generators/jasmine/jasmine_generator.rb +24 -0
  13. data/generators/jasmine/templates/INSTALL +9 -0
  14. data/generators/jasmine/templates/jasmine-example/SpecRunner.html +54 -0
  15. data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
  16. data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
  17. data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
  18. data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
  19. data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
  20. data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
  21. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -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/application.rb +43 -0
  33. data/lib/jasmine/asset_pipeline_mapper.rb +19 -0
  34. data/lib/jasmine/base.rb +50 -0
  35. data/lib/jasmine/command_line_tool.rb +70 -0
  36. data/lib/jasmine/config.rb +121 -0
  37. data/lib/jasmine/dependencies.rb +59 -0
  38. data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
  39. data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
  40. data/lib/jasmine/firebug/firebug-license.txt +30 -0
  41. data/lib/jasmine/firebug/firebug.rb +30 -0
  42. data/lib/jasmine/page.rb +11 -0
  43. data/lib/jasmine/railtie.rb +21 -0
  44. data/lib/jasmine/results.rb +19 -0
  45. data/lib/jasmine/results_processor.rb +37 -0
  46. data/lib/jasmine/rspec_formatter.rb +92 -0
  47. data/lib/jasmine/run.html.erb +55 -0
  48. data/lib/jasmine/run_specs.rb +32 -0
  49. data/lib/jasmine/runner_config.rb +71 -0
  50. data/lib/jasmine/runners/http.rb +71 -0
  51. data/lib/jasmine/selenium_driver.rb +52 -0
  52. data/lib/jasmine/server.rb +20 -0
  53. data/lib/jasmine/sprockets_mapper.rb +13 -0
  54. data/lib/jasmine/tasks/jasmine.rake +56 -0
  55. data/lib/jasmine/tasks/jasmine_rails3.rake +1 -0
  56. data/lib/jasmine/version.rb +3 -0
  57. data/lib/jasmine.rb +23 -0
  58. data/lib/rack/jasmine/cache_control.rb +20 -0
  59. data/lib/rack/jasmine/focused_suite.rb +17 -0
  60. data/lib/rack/jasmine/redirect.rb +20 -0
  61. data/lib/rack/jasmine/runner.rb +27 -0
  62. data/spec/application_spec.rb +99 -0
  63. data/spec/asset_pipeline_mapper_spec.rb +18 -0
  64. data/spec/config_spec.rb +309 -0
  65. data/spec/dependencies_spec.rb +327 -0
  66. data/spec/fixture/Rakefile +4 -0
  67. data/spec/fixture/jasmine.erb.yml +4 -0
  68. data/spec/fixture/spec/example_spec.js +5 -0
  69. data/spec/fixture/src/example.js +3 -0
  70. data/spec/jasmine_command_line_tool_rakeless_spec.rb +20 -0
  71. data/spec/jasmine_command_line_tool_spec.rb +29 -0
  72. data/spec/jasmine_pojs_spec.rb +47 -0
  73. data/spec/jasmine_rails2_spec.rb +89 -0
  74. data/spec/jasmine_rails3_spec.rb +69 -0
  75. data/spec/jasmine_self_test_config.rb +19 -0
  76. data/spec/jasmine_self_test_spec.rb +22 -0
  77. data/spec/page_spec.rb +25 -0
  78. data/spec/rack/jasmine/runner_spec.rb +25 -0
  79. data/spec/results_processor_spec.rb +3 -0
  80. data/spec/results_spec.rb +27 -0
  81. data/spec/rspec_formatter_spec.rb +88 -0
  82. data/spec/runner_config_spec.rb +136 -0
  83. data/spec/server_spec.rb +48 -0
  84. data/spec/spec_helper.rb +55 -0
  85. data/spec/sprockets_mapper_spec.rb +17 -0
  86. metadata +319 -0
@@ -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,136 @@
1
+ require 'spec_helper'
2
+ require 'selenium-webdriver'
3
+
4
+ describe Jasmine::RunnerConfig do
5
+ describe "css_files" do
6
+ it "should return the jasmine stylesheets and any user defined stylesheets" do
7
+ jasmine_stylesheets = ['some/css/file']
8
+ user_stylesheets = ['some/user/file']
9
+ user_config = double("config", :jasmine_stylesheets => jasmine_stylesheets, :user_stylesheets => user_stylesheets)
10
+ Jasmine::RunnerConfig.new(user_config).css_files.should == jasmine_stylesheets + user_stylesheets
11
+ end
12
+ end
13
+
14
+ describe "jasmine_files" do
15
+ it "should return the jasmine files from the config" do
16
+ jasmine_files = ['some/file']
17
+ user_config = double('config', :jasmine_javascripts => jasmine_files)
18
+ Jasmine::RunnerConfig.new(user_config).jasmine_files.should == jasmine_files
19
+ end
20
+ end
21
+
22
+ describe "js_files" do
23
+ it "should return the user js files from the config" do
24
+ js_files = ['some/file']
25
+ user_config = double('config', :js_files => js_files)
26
+ Jasmine::RunnerConfig.new(user_config).js_files.should == js_files
27
+ end
28
+ end
29
+
30
+ describe "spec_files" do
31
+ it "should return the user spec_files from the config" do
32
+ spec_files = ['some/file']
33
+ user_config = double('config', :spec_files => spec_files)
34
+ Jasmine::RunnerConfig.new(user_config).spec_files.should == spec_files
35
+ end
36
+ end
37
+
38
+ describe "spec_files_full_paths" do
39
+ it "should return the user spec_files_full_paths from the config" do
40
+ spec_files_full_paths = ['some/file_path']
41
+ user_config = double('config', :spec_files_full_paths => spec_files_full_paths)
42
+ Jasmine::RunnerConfig.new(user_config).spec_files_full_paths.should == spec_files_full_paths
43
+ end
44
+ end
45
+
46
+ describe "spec_path" do
47
+ it "should return the user spec_path from the config" do
48
+ spec_path = ['some/path']
49
+ user_config = double('config', :spec_path => spec_path)
50
+ Jasmine::RunnerConfig.new(user_config).spec_path.should == spec_path
51
+ end
52
+ end
53
+
54
+ describe "spec_dir" do
55
+ it "should return the user spec_dir from the config" do
56
+ spec_dir = ['some/dir']
57
+ user_config = double('config', :spec_dir => spec_dir)
58
+ Jasmine::RunnerConfig.new(user_config).spec_dir.should == spec_dir
59
+ end
60
+ end
61
+
62
+ describe "src_dir" do
63
+ it "should return the user src_dir from the config" do
64
+ src_dir = ['some/dir']
65
+ user_config = double('config', :src_dir => src_dir)
66
+ Jasmine::RunnerConfig.new(user_config).src_dir.should == src_dir
67
+ end
68
+ end
69
+
70
+ describe "project_root" do
71
+ it "should return the user project_root from the config" do
72
+ project_root = ['some/dir']
73
+ user_config = double('config', :project_root => project_root)
74
+ Jasmine::RunnerConfig.new(user_config).project_root.should == project_root
75
+ end
76
+ end
77
+
78
+ describe "root_path" do
79
+ it "should return the user root_path from the config" do
80
+ root_path = ['some/path']
81
+ user_config = double('config', :root_path => root_path)
82
+ Jasmine::RunnerConfig.new(user_config).root_path.should == root_path
83
+ end
84
+ end
85
+
86
+ describe "browser" do
87
+ it "should default to firefox" do
88
+ Jasmine::RunnerConfig.new.browser.should == 'firefox'
89
+ end
90
+
91
+ it "should use ENV['JASMINE_BROWSER'] if it exists" do
92
+ ENV.stub(:[], "JASMINE_BROWSER").and_return("foo")
93
+ Jasmine::RunnerConfig.new.browser.should == 'foo'
94
+ end
95
+ end
96
+
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
105
+ end
106
+ end
107
+
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}/"
114
+ end
115
+ end
116
+
117
+ describe "port" do
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
121
+ end
122
+ end
123
+ describe "result batch size" do
124
+ subject { Jasmine::RunnerConfig.new.result_batch_size }
125
+
126
+ context "when not specified" do
127
+ it("should use default") { should == 50 }
128
+ end
129
+
130
+ context "when overridden" do
131
+ before { ENV.stub(:[], "JASMINE_RESULT_BATCH_SIZE").and_return("500") }
132
+ it { should be(500) }
133
+ end
134
+ end
135
+ end
136
+
@@ -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).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.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
@@ -0,0 +1,55 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ require 'stringio'
4
+ require 'tmpdir'
5
+
6
+ envs = [:default, :development]
7
+ envs << :debug if ENV["DEBUG"]
8
+ Bundler.setup(*envs)
9
+
10
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "../lib")))
11
+ require "jasmine"
12
+
13
+ if Jasmine::Dependencies.rspec2?
14
+ require 'rspec'
15
+ else
16
+ require 'spec'
17
+ end
18
+
19
+
20
+ def create_rails(name)
21
+ if Jasmine::Dependencies.rails3?
22
+ `rails new #{name}`
23
+ else
24
+ `rails #{name}`
25
+ end
26
+ end
27
+
28
+ def create_temp_dir
29
+ tmp = File.join(Dir.tmpdir, "jasmine-gem-test_#{Time.now.to_f}")
30
+ FileUtils.rm_r(tmp, :force => true)
31
+ FileUtils.mkdir(tmp)
32
+ tmp
33
+ end
34
+
35
+ def temp_dir_before
36
+ @root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
37
+ @old_dir = Dir::pwd
38
+ @tmp = create_temp_dir
39
+ end
40
+
41
+ def temp_dir_after
42
+ Dir::chdir @old_dir
43
+ FileUtils.rm_r @tmp
44
+ end
45
+
46
+ module Kernel
47
+ def capture_stdout
48
+ out = StringIO.new
49
+ $stdout = out
50
+ yield
51
+ return out.string
52
+ ensure
53
+ $stdout = STDOUT
54
+ end
55
+ end
@@ -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