jasmine 0.10.2.0 → 0.10.2.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.
- data/lib/jasmine/config.rb +4 -0
- data/lib/jasmine/server.rb +8 -19
- data/spec/config_spec.rb +14 -2
- data/spec/server_spec.rb +26 -11
- metadata +2 -2
data/lib/jasmine/config.rb
CHANGED
@@ -113,6 +113,10 @@ module Jasmine
|
|
113
113
|
src_files.collect {|f| "/" + f } + spec_files.collect {|f| File.join(spec_path, f) }
|
114
114
|
end
|
115
115
|
|
116
|
+
def focused_files(spec_filter)
|
117
|
+
src_files.collect {|f| "/" + f } + match_files(spec_dir, spec_filter).collect {|f| File.join(spec_path, f) }
|
118
|
+
end
|
119
|
+
|
116
120
|
def css_files
|
117
121
|
stylesheets.collect {|f| "/" + f }
|
118
122
|
end
|
data/lib/jasmine/server.rb
CHANGED
@@ -13,24 +13,23 @@ module Jasmine
|
|
13
13
|
|
14
14
|
def call(env)
|
15
15
|
return not_found if env["PATH_INFO"] != "/"
|
16
|
-
return [200,{ 'Content-Type' => 'text/html' }, ''] if (env['REQUEST_METHOD'] == 'HEAD')
|
16
|
+
return [200, { 'Content-Type' => 'text/html' }, ''] if (env['REQUEST_METHOD'] == 'HEAD')
|
17
17
|
run if env['REQUEST_METHOD'] == 'GET'
|
18
18
|
end
|
19
19
|
|
20
20
|
def not_found
|
21
21
|
body = "File not found: #{@path_info}\n"
|
22
22
|
[404, {"Content-Type" => "text/plain",
|
23
|
-
|
24
|
-
|
23
|
+
"Content-Length" => body.size.to_s,
|
24
|
+
"X-Cascade" => "pass"},
|
25
25
|
[body]]
|
26
26
|
end
|
27
27
|
|
28
28
|
#noinspection RubyUnusedLocalVariable
|
29
|
-
def run
|
29
|
+
def run(focused_suite = nil)
|
30
30
|
jasmine_files = @jasmine_files
|
31
31
|
css_files = @jasmine_stylesheets + (@config.css_files || [])
|
32
|
-
js_files = @config.js_files
|
33
|
-
|
32
|
+
js_files = focused_suite.nil? ? @config.js_files : @config.focused_files(focused_suite)
|
34
33
|
body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html.erb"))).result(binding)
|
35
34
|
[
|
36
35
|
200,
|
@@ -72,18 +71,8 @@ module Jasmine
|
|
72
71
|
end
|
73
72
|
|
74
73
|
def call(env)
|
75
|
-
|
76
|
-
|
77
|
-
if !matching_specs.empty?
|
78
|
-
run_adapter = Jasmine::RunAdapter.new(matching_specs, @options)
|
79
|
-
run_adapter.run
|
80
|
-
else
|
81
|
-
[
|
82
|
-
200,
|
83
|
-
{ 'Content-Type' => 'application/javascript' },
|
84
|
-
"document.write('<p>Couldn\\'t find any specs matching #{env["PATH_INFO"]}!</p>');"
|
85
|
-
]
|
86
|
-
end
|
74
|
+
run_adapter = Jasmine::RunAdapter.new(@config)
|
75
|
+
run_adapter.run(env["PATH_INFO"])
|
87
76
|
end
|
88
77
|
|
89
78
|
end
|
@@ -97,7 +86,7 @@ module Jasmine
|
|
97
86
|
|
98
87
|
require 'thin'
|
99
88
|
thin_config = {
|
100
|
-
'/__suite__' => Jasmine::FocusedSuite.new(@config),
|
89
|
+
'/__suite__/' => Jasmine::FocusedSuite.new(@config),
|
101
90
|
'/run.html' => Jasmine::Redirect.new('/'),
|
102
91
|
'/' => Jasmine::RunAdapter.new(@config)
|
103
92
|
}
|
data/spec/config_spec.rb
CHANGED
@@ -44,6 +44,7 @@ describe Jasmine::Config do
|
|
44
44
|
@config.src_files.should == []
|
45
45
|
@config.stylesheets.should == []
|
46
46
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
47
|
+
@config.focused_files("javascripts/ExampleSpec.js").should == ['/__spec__/javascripts/ExampleSpec.js']
|
47
48
|
@config.mappings.should == {
|
48
49
|
'/__root__' => @config.project_root,
|
49
50
|
'/__spec__' => @config.spec_dir
|
@@ -56,6 +57,7 @@ describe Jasmine::Config do
|
|
56
57
|
@config.src_files.should == []
|
57
58
|
@config.stylesheets.should == []
|
58
59
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
60
|
+
@config.focused_files("javascripts/ExampleSpec.js").should == ['/__spec__/javascripts/ExampleSpec.js']
|
59
61
|
@config.mappings.should == {
|
60
62
|
'/__root__' => @config.project_root,
|
61
63
|
'/__spec__' => @config.spec_dir
|
@@ -66,9 +68,10 @@ describe Jasmine::Config do
|
|
66
68
|
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
|
67
69
|
@config.src_files.should == []
|
68
70
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
71
|
+
@config.focused_files("javascripts/ExampleSpec.js").should == ['/__spec__/javascripts/ExampleSpec.js']
|
69
72
|
@config.mappings.should == {
|
70
|
-
|
71
|
-
|
73
|
+
'/__root__' => @config.project_root,
|
74
|
+
'/__spec__' => @config.spec_dir
|
72
75
|
}
|
73
76
|
end
|
74
77
|
|
@@ -106,6 +109,15 @@ describe Jasmine::Config do
|
|
106
109
|
'/__spec__/javascripts/ExampleSpec.js',
|
107
110
|
'/__spec__/javascripts/SpecHelper.js',
|
108
111
|
]
|
112
|
+
@config.focused_files("javascripts/ExampleSpec.js").should == [
|
113
|
+
'/javascripts/prototype.js',
|
114
|
+
'/javascripts/effects.js',
|
115
|
+
'/javascripts/controls.js',
|
116
|
+
'/javascripts/dragdrop.js',
|
117
|
+
'/javascripts/application.js',
|
118
|
+
'/__spec__/javascripts/ExampleSpec.js'
|
119
|
+
]
|
120
|
+
|
109
121
|
end
|
110
122
|
|
111
123
|
it "should provide a list of all spec files with full paths" do
|
data/spec/server_spec.rb
CHANGED
@@ -10,12 +10,10 @@ end
|
|
10
10
|
describe Jasmine::Server do
|
11
11
|
before(:each) do
|
12
12
|
config = Jasmine::Config.new
|
13
|
-
config.stub!(:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
config.stub!(:js_files).and_return(["/src/file1.js", "/spec/file2.js"])
|
13
|
+
config.stub!(:spec_dir).and_return(File.join(Jasmine.root, "spec"))
|
14
|
+
config.stub!(:src_dir).and_return(File.join(Jasmine.root, "src"))
|
15
|
+
config.stub!(:src_files).and_return(["file1.js"])
|
16
|
+
config.stub!(:spec_files).and_return(["file2.js"])
|
19
17
|
|
20
18
|
@server = Jasmine::Server.new(0, config)
|
21
19
|
@thin_app = @server.thin.app
|
@@ -25,11 +23,18 @@ describe Jasmine::Server do
|
|
25
23
|
@server.thin.stop if @server && @server.thin.running?
|
26
24
|
end
|
27
25
|
|
28
|
-
it "should serve static files" do
|
29
|
-
code, headers, body = @thin_app.call("PATH_INFO" => "/
|
26
|
+
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")
|
30
28
|
code.should == 200
|
31
29
|
headers["Content-Type"].should == "application/javascript"
|
32
30
|
read(body).should == File.read(File.join(Jasmine.root, "spec/suites/EnvSpec.js"))
|
31
|
+
end
|
32
|
+
|
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"))
|
33
38
|
end
|
34
39
|
|
35
40
|
it "should serve Jasmine static files under /__JASMINE_ROOT__/" do
|
@@ -39,6 +44,16 @@ describe Jasmine::Server do
|
|
39
44
|
read(body).should == File.read(File.join(Jasmine.root, "lib/jasmine.css"))
|
40
45
|
end
|
41
46
|
|
47
|
+
it "should serve focused suites when prefixing spec files with /__suite__/" do
|
48
|
+
Dir.stub!(:glob).and_return do |glob_string|
|
49
|
+
glob_string
|
50
|
+
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")
|
55
|
+
end
|
56
|
+
|
42
57
|
it "should redirect /run.html to /" do
|
43
58
|
code, headers, body = @thin_app.call("PATH_INFO" => "/run.html", "SCRIPT_NAME" => "xxx")
|
44
59
|
code.should == 302
|
@@ -56,9 +71,9 @@ describe Jasmine::Server do
|
|
56
71
|
code, headers, body = @thin_app.call("PATH_INFO" => "/", "SCRIPT_NAME" => "xxx", "REQUEST_METHOD" => 'GET')
|
57
72
|
code.should == 200
|
58
73
|
body = read(body)
|
59
|
-
body.should include("\"/
|
60
|
-
body.should include("\"/
|
61
|
-
body.should satisfy {|s| s.index("/
|
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") }
|
62
77
|
end
|
63
78
|
|
64
79
|
it "should return an empty 200 for HEAD requests to /" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.2.
|
4
|
+
version: 0.10.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajan Agaskar
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-03-
|
13
|
+
date: 2010-03-19 00:00:00 -07:00
|
14
14
|
default_executable: jasmine
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|