jasmine 0.10.3.2 → 0.10.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,7 @@ which will run your Jasmine suites using selenium and rspec. This task is suitab
31
31
 
32
32
  Simple Configuration:
33
33
 
34
- Customize `spec/javascripts/support/jasmine.yaml` to enumerate the source files, stylesheets, and spec files you would like the Jasmine runner to include.
34
+ Customize `spec/javascripts/support/jasmine.yml` to enumerate the source files, stylesheets, and spec files you would like the Jasmine runner to include.
35
35
  You may use dir glob strings.
36
36
 
37
37
  It is also possible to add overrides into the `spec/javascripts/support/jasmine_config.rb` file directly if you require further customization.
@@ -21,7 +21,7 @@ namespace :jasmine do
21
21
  require jasmine_config_overrides if File.exists?(jasmine_config_overrides)
22
22
 
23
23
  puts "your tests are here:"
24
- puts " http://localhost:8888/run.html"
24
+ puts " http://localhost:8888/"
25
25
 
26
26
  Jasmine::Config.new.start_server
27
27
  end
@@ -12,7 +12,8 @@ module Jasmine
12
12
  end
13
13
 
14
14
  def start_server(port = 8888)
15
- Jasmine::Server.new(port, self).start
15
+ handler = Rack::Handler.default
16
+ handler.run Jasmine.app(self), :Port => port
16
17
  end
17
18
 
18
19
  def start
@@ -32,10 +33,9 @@ module Jasmine
32
33
 
33
34
  def start_jasmine_server
34
35
  @jasmine_server_port = Jasmine::find_unused_port
35
- server = Jasmine::Server.new(@jasmine_server_port, self)
36
36
  @jasmine_server_pid = fork do
37
37
  Process.setpgrp
38
- server.start
38
+ start_server(@jasmine_server_port)
39
39
  exit! 0
40
40
  end
41
41
  puts "jasmine server started. pid is #{@jasmine_server_pid}"
@@ -106,13 +106,6 @@ module Jasmine
106
106
  "/__root__"
107
107
  end
108
108
 
109
- def mappings
110
- {
111
- spec_path => spec_dir,
112
- root_path => project_root
113
- }
114
- end
115
-
116
109
  def js_files(spec_filter = nil)
117
110
  spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, spec_filter)
118
111
  src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) }
@@ -1,3 +1,29 @@
1
+ require 'rack'
2
+
3
+ # Backport Rack::Handler.default from Rack 1.1.0 for Rails 2.3.x compatibility.
4
+ unless Rack::Handler.respond_to?(:default)
5
+ module Rack::Handler
6
+ def self.default(options = {})
7
+ # Guess.
8
+ if ENV.include?("PHP_FCGI_CHILDREN")
9
+ # We already speak FastCGI
10
+ options.delete :File
11
+ options.delete :Port
12
+
13
+ Rack::Handler::FastCGI
14
+ elsif ENV.include?("REQUEST_METHOD")
15
+ Rack::Handler::CGI
16
+ else
17
+ begin
18
+ Rack::Handler::Mongrel
19
+ rescue LoadError => e
20
+ Rack::Handler::WEBrick
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
1
27
  module Jasmine
2
28
  class RunAdapter
3
29
  def initialize(config)
@@ -13,8 +39,7 @@ module Jasmine
13
39
 
14
40
  def call(env)
15
41
  return not_found if env["PATH_INFO"] != "/"
16
- return [200, { 'Content-Type' => 'text/html' }, ''] if (env['REQUEST_METHOD'] == 'HEAD')
17
- run if env['REQUEST_METHOD'] == 'GET'
42
+ run
18
43
  end
19
44
 
20
45
  def not_found
@@ -37,8 +62,6 @@ module Jasmine
37
62
  body
38
63
  ]
39
64
  end
40
-
41
-
42
65
  end
43
66
 
44
67
  class Redirect
@@ -74,49 +97,25 @@ module Jasmine
74
97
  run_adapter = Jasmine::RunAdapter.new(@config)
75
98
  run_adapter.run(env["PATH_INFO"])
76
99
  end
77
-
78
100
  end
79
101
 
80
- class Server
81
- attr_reader :thin
102
+ def self.app(config)
103
+ Rack::Builder.app do
104
+ use Rack::Head
82
105
 
83
- def initialize(port, config)
84
- @port = port
85
- @config = config
86
-
87
- require 'thin'
88
- thin_config = {
89
- '/__suite__/' => Jasmine::FocusedSuite.new(@config),
90
- '/run.html' => Jasmine::Redirect.new('/'),
91
- '/' => Jasmine::RunAdapter.new(@config)
92
- }
93
-
94
- @config.mappings.each do |from, to|
95
- thin_config[from] = Rack::File.new(to)
96
- end
106
+ map('/run.html') { run Jasmine::Redirect.new('/') }
107
+ map('/__suite__') { run Jasmine::FocusedSuite.new(config) }
97
108
 
98
- thin_config["/__JASMINE_ROOT__"] = Rack::File.new(Jasmine.root)
109
+ map('/__JASMINE_ROOT__') { run Rack::File.new(Jasmine.root) }
110
+ map(config.spec_path) { run Rack::File.new(config.spec_dir) }
111
+ map(config.root_path) { run Rack::File.new(config.project_root) }
99
112
 
100
- app = Rack::Cascade.new([
101
- Rack::URLMap.new({'/' => Rack::File.new(@config.src_dir)}),
102
- Rack::URLMap.new(thin_config)
103
- # JsAlert.new
104
- ])
105
- # Thin::Logging.trace = true
106
- @thin = Thin::Server.new('0.0.0.0', @port, app)
107
- end
108
-
109
- def start
110
- begin
111
- thin.start
112
- rescue RuntimeError => e
113
- raise e unless e.message == 'no acceptor'
114
- raise RuntimeError.new("A server is already running on port #{@port}")
113
+ map('/') do
114
+ run Rack::Cascade.new([
115
+ Rack::URLMap.new('/' => Rack::File.new(config.src_dir)),
116
+ Jasmine::RunAdapter.new(config)
117
+ ])
115
118
  end
116
119
  end
117
-
118
- def stop
119
- thin.stop
120
- end
121
120
  end
122
121
  end
@@ -23,13 +23,6 @@ describe Jasmine::Config do
23
23
  @config.simple_config_file.should == (File.join('some_project_root', 'spec/javascripts/support/jasmine.yml'))
24
24
  end
25
25
 
26
-
27
- it "should provide dir mappings" do
28
- @config.mappings.should == {
29
- '/__root__' => @config.project_root,
30
- '/__spec__' => @config.spec_dir
31
- }
32
- end
33
26
  end
34
27
 
35
28
 
@@ -52,10 +45,6 @@ describe Jasmine::Config do
52
45
  @config.js_files("ExampleSpec.js").should ==
53
46
  ['/__spec__/helpers/SpecHelper.js',
54
47
  '/__spec__/ExampleSpec.js']
55
- @config.mappings.should == {
56
- '/__root__' => @config.project_root,
57
- '/__spec__' => @config.spec_dir
58
- }
59
48
  @config.spec_files_full_paths.should == [
60
49
  File.join(@template_dir, 'spec/javascripts/ExampleSpec.js'),
61
50
  ]
@@ -122,8 +111,8 @@ describe Jasmine::Config do
122
111
  end
123
112
 
124
113
  it "spec_files_full_paths" do
125
- @config.spec_files_full_paths.should == ["/Users/ragaskar/workspace/jasmine-ruby/generators/jasmine/templates/spec/javascripts/file1.ext",
126
- "/Users/ragaskar/workspace/jasmine-ruby/generators/jasmine/templates/spec/javascripts/file2.ext"]
114
+ @config.spec_files_full_paths.should == [File.expand_path("../../generators/jasmine/templates/spec/javascripts/file1.ext", __FILE__),
115
+ File.expand_path("../../generators/jasmine/templates/spec/javascripts/file2.ext", __FILE__)]
127
116
  end
128
117
 
129
118
  end
@@ -1,86 +1,82 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
+ require 'rack/test'
2
3
 
3
- def read(body)
4
- return body if body.is_a?(String)
5
- out = ""
6
- body.each {|data| out += data }
7
- out
8
- end
4
+ describe "Jasmine.app" do
5
+ include Rack::Test::Methods
9
6
 
10
- describe Jasmine::Server do
11
- before(:each) do
7
+ def app
12
8
  config = Jasmine::Config.new
9
+ config.stub!(:project_root).and_return(Jasmine.root)
13
10
  config.stub!(:spec_dir).and_return(File.join(Jasmine.root, "spec"))
14
11
  config.stub!(:src_dir).and_return(File.join(Jasmine.root, "src"))
15
12
  config.stub!(:src_files).and_return(["file1.js"])
16
13
  config.stub!(:spec_files).and_return(["file2.js"])
17
-
18
- @server = Jasmine::Server.new(0, config)
19
- @thin_app = @server.thin.app
20
- end
21
-
22
- after(:each) do
23
- @server.thin.stop if @server && @server.thin.running?
14
+ Jasmine.app(config)
24
15
  end
25
16
 
26
17
  it "should serve static files from spec dir under __spec__" do
27
- code, headers, body = @thin_app.call("PATH_INFO" => "/__spec__/suites/EnvSpec.js", "SCRIPT_NAME" => "xxx")
28
- code.should == 200
29
- headers["Content-Type"].should == "application/javascript"
30
- read(body).should == File.read(File.join(Jasmine.root, "spec/suites/EnvSpec.js"))
18
+ get "/__spec__/suites/EnvSpec.js"
19
+ last_response.status.should == 200
20
+ last_response.content_type.should == "application/javascript"
21
+ last_response.body.should == File.read(File.join(Jasmine.root, "spec/suites/EnvSpec.js"))
31
22
  end
32
23
 
33
- it "should serve static files from root dir under /" do
34
- code, headers, body = @thin_app.call("PATH_INFO" => "/base.js", "SCRIPT_NAME" => "xxx")
35
- code.should == 200
36
- headers["Content-Type"].should == "application/javascript"
37
- read(body).should == File.read(File.join(Jasmine.root, "src/base.js"))
24
+ it "should serve static files from root dir under __root__" do
25
+ get "/__root__/src/base.js"
26
+ last_response.status.should == 200
27
+ last_response.content_type.should == "application/javascript"
28
+ last_response.body.should == File.read(File.join(Jasmine.root, "src/base.js"))
29
+ end
30
+
31
+ it "should serve static files from src dir under /" do
32
+ get "/base.js"
33
+ last_response.status.should == 200
34
+ last_response.content_type.should == "application/javascript"
35
+ last_response.body.should == File.read(File.join(Jasmine.root, "src/base.js"))
38
36
  end
39
37
 
40
38
  it "should serve Jasmine static files under /__JASMINE_ROOT__/" do
41
- code, headers, body = @thin_app.call("PATH_INFO" => "/__JASMINE_ROOT__/lib/jasmine.css", "SCRIPT_NAME" => "xxx")
42
- code.should == 200
43
- headers["Content-Type"].should == "text/css"
44
- read(body).should == File.read(File.join(Jasmine.root, "lib/jasmine.css"))
39
+ get "/__JASMINE_ROOT__/lib/jasmine.css"
40
+ last_response.status.should == 200
41
+ last_response.content_type.should == "text/css"
42
+ last_response.body.should == File.read(File.join(Jasmine.root, "lib/jasmine.css"))
45
43
  end
46
44
 
47
45
  it "should serve focused suites when prefixing spec files with /__suite__/" do
48
46
  Dir.stub!(:glob).and_return do |glob_string|
49
47
  [glob_string]
50
48
  end
51
- code, headers, body = @thin_app.call("PATH_INFO" => "/__suite__/file2.js", "SCRIPT_NAME" => "xxx")
52
- code.should == 200
53
- headers["Content-Type"].should == "text/html"
54
- read(body).should include("\"/__spec__/file2.js")
49
+ get "/__suite__/file2.js"
50
+ last_response.status.should == 200
51
+ last_response.content_type.should == "text/html"
52
+ last_response.body.should include("\"/__spec__/file2.js")
55
53
  end
56
54
 
57
55
  it "should redirect /run.html to /" do
58
- code, headers, body = @thin_app.call("PATH_INFO" => "/run.html", "SCRIPT_NAME" => "xxx")
59
- code.should == 302
60
- headers["Location"].should == "/"
56
+ get "/run.html"
57
+ last_response.status.should == 302
58
+ last_response.location.should == "/"
61
59
  end
62
60
 
63
61
  it "should 404 non-existent files" do
64
- code, headers, body = @thin_app.call("PATH_INFO" => "/some-non-existent-file", "SCRIPT_NAME" => "xxx")
65
- code.should == 404
66
-
62
+ get "/some-non-existent-file"
63
+ last_response.should be_not_found
67
64
  end
68
65
 
69
66
  describe "/ page" do
70
67
  it "should load each js file in order" do
71
- code, headers, body = @thin_app.call("PATH_INFO" => "/", "SCRIPT_NAME" => "xxx", "REQUEST_METHOD" => 'GET')
72
- code.should == 200
73
- body = read(body)
74
- body.should include("\"/file1.js")
75
- body.should include("\"/__spec__/file2.js")
76
- body.should satisfy {|s| s.index("/file1.js") < s.index("/__spec__/file2.js") }
68
+ get "/"
69
+ last_response.status.should == 200
70
+ last_response.body.should include("\"/file1.js")
71
+ last_response.body.should include("\"/__spec__/file2.js")
72
+ last_response.body.should satisfy {|s| s.index("/file1.js") < s.index("/__spec__/file2.js") }
77
73
  end
78
74
 
79
75
  it "should return an empty 200 for HEAD requests to /" do
80
- code, headers, body = @thin_app.call("PATH_INFO" => "/", "SCRIPT_NAME" => "xxx", "REQUEST_METHOD" => 'HEAD')
81
- code.should == 200
82
- headers.should == { 'Content-Type' => 'text/html' }
83
- body.should == ''
76
+ head "/"
77
+ last_response.status.should == 200
78
+ last_response.headers.should == { 'Content-Type' => 'text/html' }
79
+ last_response.body.should == ''
84
80
  end
85
81
  end
86
82
  end
@@ -1,5 +1,7 @@
1
- require File.expand_path('../../.bundle/environment', __FILE__)
2
- Bundler.require(:default, :test)
1
+ require "rubygems"
2
+ require "bundler"
3
+
4
+ Bundler.setup(:default, :test)
3
5
 
4
6
  require 'spec'
5
7
 
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 10
8
8
  - 3
9
- - 2
10
- version: 0.10.3.2
9
+ - 3
10
+ version: 0.10.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rajan Agaskar
@@ -16,13 +16,11 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-04-20 00:00:00 -07:00
19
+ date: 2010-04-21 00:00:00 -07:00
20
20
  default_executable: jasmine
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- name: rspec
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
@@ -31,26 +29,12 @@ dependencies:
31
29
  - 1
32
30
  - 5
33
31
  version: 1.1.5
34
- type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: json
32
+ name: rspec
33
+ requirement: *id001
38
34
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- segments:
44
- - 1
45
- - 1
46
- - 9
47
- version: 1.1.9
48
35
  type: :runtime
49
- version_requirements: *id002
50
36
  - !ruby/object:Gem::Dependency
51
- name: rack
52
- prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
54
38
  requirements:
55
39
  - - ">="
56
40
  - !ruby/object:Gem::Version
@@ -59,26 +43,12 @@ dependencies:
59
43
  - 0
60
44
  - 0
61
45
  version: 1.0.0
62
- type: :runtime
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: thin
46
+ name: rack
47
+ requirement: *id002
66
48
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- segments:
72
- - 1
73
- - 2
74
- - 4
75
- version: 1.2.4
76
49
  type: :runtime
77
- version_requirements: *id004
78
50
  - !ruby/object:Gem::Dependency
79
- name: selenium-rc
80
- prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
82
52
  requirements:
83
53
  - - ">="
84
54
  - !ruby/object:Gem::Version
@@ -87,12 +57,12 @@ dependencies:
87
57
  - 1
88
58
  - 0
89
59
  version: 2.1.0
60
+ name: selenium-rc
61
+ requirement: *id003
62
+ prerelease: false
90
63
  type: :runtime
91
- version_requirements: *id005
92
64
  - !ruby/object:Gem::Dependency
93
- name: selenium-client
94
- prerelease: false
95
- requirement: &id006 !ruby/object:Gem::Requirement
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
96
66
  requirements:
97
67
  - - ">="
98
68
  - !ruby/object:Gem::Version
@@ -101,8 +71,10 @@ dependencies:
101
71
  - 2
102
72
  - 17
103
73
  version: 1.2.17
74
+ name: selenium-client
75
+ requirement: *id004
76
+ prerelease: false
104
77
  type: :runtime
105
- version_requirements: *id006
106
78
  description: Javascript BDD test framework
107
79
  email: ragaskar@gmail.com
108
80
  executables: