jasmine 0.10.3.2 → 0.10.3.3
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/README.markdown +1 -1
- data/generators/jasmine/templates/lib/tasks/jasmine.rake +1 -1
- data/lib/jasmine/config.rb +3 -10
- data/lib/jasmine/server.rb +40 -41
- data/spec/config_spec.rb +2 -13
- data/spec/server_spec.rb +44 -48
- data/spec/spec_helper.rb +4 -2
- metadata +17 -45
data/README.markdown
CHANGED
@@ -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.
|
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.
|
data/lib/jasmine/config.rb
CHANGED
@@ -12,7 +12,8 @@ module Jasmine
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def start_server(port = 8888)
|
15
|
-
|
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
|
-
|
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) }
|
data/lib/jasmine/server.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
81
|
-
|
102
|
+
def self.app(config)
|
103
|
+
Rack::Builder.app do
|
104
|
+
use Rack::Head
|
82
105
|
|
83
|
-
|
84
|
-
|
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
|
-
|
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
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
data/spec/config_spec.rb
CHANGED
@@ -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 == ["
|
126
|
-
"
|
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
|
data/spec/server_spec.rb
CHANGED
@@ -1,86 +1,82 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
|
+
require 'rack/test'
|
2
3
|
|
3
|
-
|
4
|
-
|
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
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
65
|
-
|
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
|
-
|
72
|
-
|
73
|
-
body
|
74
|
-
body.should include("\"/
|
75
|
-
body.should
|
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
|
-
|
81
|
-
|
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
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 10
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.10.3.
|
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-
|
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
|
-
|
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
|
-
|
35
|
-
|
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
|
-
|
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
|
-
|
63
|
-
|
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
|
-
|
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
|
-
|
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:
|