js_spec 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/README +23 -1
- data/Rakefile +5 -3
- data/bin/js_spec +1 -5
- data/bin/js_spec_server +0 -0
- data/core/JSSpecExtensions.js +70 -25
- data/core/jquery.js +2992 -0
- data/init.rb +0 -0
- data/lib/js_spec/client.rb +50 -0
- data/lib/js_spec/rack/response.rb +5 -0
- data/lib/js_spec/rails_server.rb +3 -3
- data/lib/js_spec/resources/dir.rb +43 -43
- data/lib/js_spec/resources/file.rb +16 -16
- data/lib/js_spec/resources/runners/firefox1_runner.rb +8 -0
- data/lib/js_spec/resources/runners/firefox_runner.rb +49 -72
- data/lib/js_spec/resources/runners.rb +6 -7
- data/lib/js_spec/resources/spec_dir_runner.rb +7 -7
- data/lib/js_spec/resources/spec_file_runner.rb +7 -7
- data/lib/js_spec/resources/spec_runner.rb +16 -11
- data/lib/js_spec/resources/suite.rb +14 -14
- data/lib/js_spec/resources/suite_finish.rb +12 -12
- data/lib/js_spec/server.rb +29 -17
- data/lib/js_spec/thin/backends/js_spec_server.rb +9 -0
- data/lib/js_spec/thin/js_spec_connection.rb +43 -0
- data/lib/js_spec.rb +14 -2
- data/spec/integration/integration_spec.rb +14 -0
- data/spec/integration/integration_spec_helper.rb +52 -0
- data/spec/integration_suite.rb +10 -0
- data/spec/spec_suite.rb +1 -0
- data/spec/unit/js_spec/client_spec.rb +137 -0
- data/spec/unit/{rails_server_spec.rb → js_spec/rails_server_spec.rb} +8 -7
- data/spec/unit/{resources → js_spec/resources}/dir_spec.rb +1 -1
- data/spec/unit/{resources → js_spec/resources}/file_spec.rb +9 -6
- data/spec/unit/js_spec/resources/runner_spec.rb +24 -0
- data/spec/unit/js_spec/resources/runners/firefox_runner_spec.rb +152 -0
- data/spec/unit/js_spec/resources/spec_dir_runner_spec.rb +48 -0
- data/spec/unit/{resources → js_spec/resources}/spec_file_runner_spec.rb +1 -1
- data/spec/unit/{resources → js_spec/resources}/suite_finish_spec.rb +5 -5
- data/spec/unit/{resources → js_spec/resources}/suite_spec.rb +1 -1
- data/spec/unit/{resources → js_spec/resources}/web_root_spec.rb +1 -1
- data/spec/unit/{server_spec.rb → js_spec/server_spec.rb} +29 -92
- data/spec/unit/rack/response_spec.rb +30 -0
- data/spec/unit/thin/js_spec_connection_spec.rb +50 -0
- data/spec/unit/unit_spec_helper.rb +40 -5
- metadata +107 -60
- data/spec/unit/resources/runner_spec.rb +0 -24
- data/spec/unit/resources/runners/firefox_runner_spec.rb +0 -87
- data/spec/unit/resources/spec_dir_runner_spec.rb +0 -43
@@ -1,7 +1,17 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
|
2
2
|
|
3
3
|
module JsSpec
|
4
4
|
describe Server do
|
5
|
+
attr_reader :result
|
6
|
+
|
7
|
+
before do
|
8
|
+
@result = ""
|
9
|
+
stub(EventMachine).send_data do |signature, data, data_length|
|
10
|
+
@result << data
|
11
|
+
end
|
12
|
+
stub(EventMachine).close_connection
|
13
|
+
end
|
14
|
+
|
5
15
|
describe "HTTP GET" do
|
6
16
|
specify "'/specs' returns an HTML test runner including all specs files" do
|
7
17
|
result = get("/specs").body
|
@@ -26,13 +36,13 @@ module JsSpec
|
|
26
36
|
end
|
27
37
|
|
28
38
|
specify "'/core/JSSpec.js', returns the contents of the file" do
|
29
|
-
|
30
|
-
|
39
|
+
response = get("/core/JSSpec.js")
|
40
|
+
response.body.should == ::File.read("#{Server.core_path}/JSSpec.js")
|
31
41
|
end
|
32
42
|
|
33
43
|
specify "'/stylesheets/example.css', returns the contents of the file" do
|
34
|
-
|
35
|
-
|
44
|
+
response = get("/stylesheets/example.css")
|
45
|
+
response.body.should == ::File.read("#{Server.public_path}/stylesheets/example.css")
|
36
46
|
end
|
37
47
|
|
38
48
|
specify "'/invalid/path', shows the full invalid path in the error message" do
|
@@ -49,14 +59,12 @@ module JsSpec
|
|
49
59
|
Server.instance = nil
|
50
60
|
end
|
51
61
|
|
52
|
-
it "instantiates an instance of Server and starts a Rack
|
53
|
-
host =
|
54
|
-
port =
|
62
|
+
it "instantiates an instance of Server and starts a Rack Thin handler" do
|
63
|
+
host = DEFAULT_HOST
|
64
|
+
port = DEFAULT_PORT
|
55
65
|
|
56
|
-
mock
|
57
|
-
|
58
|
-
end
|
59
|
-
mock(Rack::Handler::Mongrel).run(server_instance, {:Host => host, :Port => port})
|
66
|
+
mock(EventMachine).run.yields
|
67
|
+
mock(EventMachine).start_server(host, port, ::Thin::JsSpecConnection)
|
60
68
|
|
61
69
|
Server.run(spec_root_path, implementation_root_path, public_path)
|
62
70
|
end
|
@@ -65,21 +73,13 @@ module JsSpec
|
|
65
73
|
host = 'foobar.com'
|
66
74
|
port = 80
|
67
75
|
|
68
|
-
mock
|
69
|
-
|
70
|
-
end
|
71
|
-
mock(Rack::Handler::Mongrel).run(server_instance, {:Host => host, :Port => port})
|
76
|
+
mock(EventMachine).run.yields
|
77
|
+
mock(EventMachine).start_server(host, port, ::Thin::JsSpecConnection)
|
72
78
|
|
73
79
|
Server.run(spec_root_path, implementation_root_path, public_path, {:Host => host, :Port => port})
|
74
80
|
end
|
75
81
|
end
|
76
82
|
|
77
|
-
describe ".default_url" do
|
78
|
-
it "returns the default host and port" do
|
79
|
-
Server.default_url.should == "http://#{Server::DEFAULT_HOST}:#{Server::DEFAULT_PORT}"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
83
|
describe ".spec_root" do
|
84
84
|
it "returns the Dir " do
|
85
85
|
Server.spec_root_path.should == spec_root_path
|
@@ -101,7 +101,7 @@ module JsSpec
|
|
101
101
|
describe ".core_path" do
|
102
102
|
it "returns the expanded path to the JsSpec core directory" do
|
103
103
|
dir = ::File.dirname(__FILE__)
|
104
|
-
Server.core_path.should == ::File.expand_path("#{dir}
|
104
|
+
Server.core_path.should == ::File.expand_path("#{dir}/../../../core")
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -112,76 +112,7 @@ module JsSpec
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
describe ".request" do
|
116
|
-
it "returns request in progress for the thread" do
|
117
|
-
the_request = nil
|
118
|
-
stub.instance_of(Resources::WebRoot).locate('somedir') do
|
119
|
-
the_request = JsSpec::Server.request
|
120
|
-
Thread.current[:request].should == the_request
|
121
|
-
thread2 = Thread.new do
|
122
|
-
Thread.current[:request].should be_nil
|
123
|
-
end
|
124
|
-
thread2.join
|
125
|
-
|
126
|
-
mock_resource = Object.new
|
127
|
-
stub(mock_resource).get.returns("")
|
128
|
-
mock_resource
|
129
|
-
end
|
130
|
-
|
131
|
-
get('/somedir')
|
132
|
-
|
133
|
-
the_request.path_info.should == '/somedir'
|
134
|
-
end
|
135
|
-
|
136
|
-
it "resets to nil when the request is finished" do
|
137
|
-
get('/core')
|
138
|
-
|
139
|
-
JsSpec::Server.request.should be_nil
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe ".response" do
|
144
|
-
it "returns response in progress" do
|
145
|
-
the_response = nil
|
146
|
-
stub.instance_of(Resources::WebRoot).locate('somedir') do
|
147
|
-
the_response = JsSpec::Server.response
|
148
|
-
Thread.current[:response].should == the_response
|
149
|
-
thread2 = Thread.new do
|
150
|
-
Thread.current[:response].should be_nil
|
151
|
-
end
|
152
|
-
thread2.join
|
153
|
-
|
154
|
-
mock_resource = Object.new
|
155
|
-
stub(mock_resource).get {"The text"}
|
156
|
-
mock_resource
|
157
|
-
end
|
158
|
-
|
159
|
-
get('/somedir')
|
160
|
-
|
161
|
-
the_response.body.should == 'The text'
|
162
|
-
end
|
163
|
-
|
164
|
-
it "resets to nil when the response is finished" do
|
165
|
-
get('/core')
|
166
|
-
|
167
|
-
JsSpec::Server.response.should be_nil
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
115
|
describe "#call" do
|
172
|
-
it "when resource responds with a string, sets the string as the response.body" do
|
173
|
-
somedir_resource = Object.new
|
174
|
-
stub.instance_of(Resources::WebRoot).locate('somedir') do
|
175
|
-
somedir_resource
|
176
|
-
end
|
177
|
-
|
178
|
-
def somedir_resource.get
|
179
|
-
"Somedir String"
|
180
|
-
end
|
181
|
-
response = get('/somedir')
|
182
|
-
response.body.should == "Somedir String"
|
183
|
-
end
|
184
|
-
|
185
116
|
describe "when there is an error" do
|
186
117
|
attr_reader :top_line_of_backtrace
|
187
118
|
before do
|
@@ -213,5 +144,11 @@ module JsSpec
|
|
213
144
|
end
|
214
145
|
end
|
215
146
|
end
|
147
|
+
|
148
|
+
describe "#root_url" do
|
149
|
+
it "returns the url of the site's root" do
|
150
|
+
server.root_url.should == "http://#{server.host}:#{server.port}"
|
151
|
+
end
|
152
|
+
end
|
216
153
|
end
|
217
154
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
describe Response do
|
5
|
+
describe "#ready?" do
|
6
|
+
attr_reader :response
|
7
|
+
describe "when there is a status" do
|
8
|
+
before do
|
9
|
+
@response = Response.new
|
10
|
+
@response.status.should_not be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns true" do
|
14
|
+
response.should be_ready
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "when there is no status" do
|
19
|
+
before do
|
20
|
+
@response = Response.new
|
21
|
+
response.status = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns true" do
|
25
|
+
response.should_not be_ready
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
|
2
|
+
|
3
|
+
module Thin
|
4
|
+
describe JsSpecConnection do
|
5
|
+
describe "#process" do
|
6
|
+
attr_reader :connection, :result
|
7
|
+
before do
|
8
|
+
@connection = JsSpecConnection.new('signature')
|
9
|
+
stub(connection).socket_address {'0.0.0.0'}
|
10
|
+
|
11
|
+
@result = ""
|
12
|
+
stub(EventMachine).send_data do |signature, data, data_length|
|
13
|
+
result << data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "when the response code is not 0" do
|
18
|
+
attr_reader :somedir_resource
|
19
|
+
before do
|
20
|
+
mock(app = Object.new).call(is_a(Hash)) do
|
21
|
+
[200, {}, 'The Body']
|
22
|
+
end
|
23
|
+
connection.app = app
|
24
|
+
end
|
25
|
+
|
26
|
+
it "sends the response to the socket and closes the connection" do
|
27
|
+
mock(connection).close_connection_after_writing
|
28
|
+
connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n"
|
29
|
+
result.should include("The Body")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when the response code is 0" do
|
34
|
+
attr_reader :somedir_resource
|
35
|
+
before do
|
36
|
+
mock(app = Object.new).call(is_a(Hash)) do
|
37
|
+
[0, {}, 'The Body']
|
38
|
+
end
|
39
|
+
connection.app = app
|
40
|
+
end
|
41
|
+
|
42
|
+
it "does not send data to the socket and keeps it open" do
|
43
|
+
dont_allow(connection).close_connection_after_writing
|
44
|
+
connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n"
|
45
|
+
result.should_not include("The Body")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -22,8 +22,19 @@ module Spec
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
class Spec::Example::ExampleGroup
|
26
|
+
class << self
|
27
|
+
def thin_logging
|
28
|
+
@thin_logging = true if @thin_logging.nil?
|
29
|
+
@thin_logging
|
30
|
+
end
|
31
|
+
|
32
|
+
attr_writer :thin_logging
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
25
36
|
module Spec::Example::ExampleMethods
|
26
|
-
attr_reader :spec_root_path, :implementation_root_path, :public_path, :server
|
37
|
+
attr_reader :spec_root_path, :implementation_root_path, :public_path, :server, :connection
|
27
38
|
before(:all) do
|
28
39
|
dir = File.dirname(__FILE__)
|
29
40
|
@spec_root_path = File.expand_path("#{dir}/../example_specs")
|
@@ -33,7 +44,26 @@ module Spec::Example::ExampleMethods
|
|
33
44
|
|
34
45
|
before(:each) do
|
35
46
|
JsSpec::Server.instance = JsSpec::Server.new(spec_root_path, implementation_root_path, public_path)
|
47
|
+
stub(EventMachine).run do
|
48
|
+
raise "You need to mock calls to EventMachine.run or the process will hang"
|
49
|
+
end
|
50
|
+
stub(EventMachine).start_server do
|
51
|
+
raise "You need to mock calls to EventMachine.start_server or the process will hang"
|
52
|
+
end
|
53
|
+
stub(EventMachine).send_data do
|
54
|
+
raise "Calls to EventMachine.send_data must be mocked or stubbed"
|
55
|
+
end
|
56
|
+
@connection = Thin::JsSpecConnection.new(UUID.new)
|
57
|
+
stub(EventMachine).send_data {raise "EventMachine.send_data must be handled"}
|
58
|
+
stub(EventMachine).close_connection {raise "EventMachine.close_connection must be handled"}
|
36
59
|
@server = JsSpec::Server.instance
|
60
|
+
Thin::Logging.silent = !self.class.thin_logging
|
61
|
+
Thin::Logging.debug = self.class.thin_logging
|
62
|
+
end
|
63
|
+
|
64
|
+
after(:each) do
|
65
|
+
Thin::Logging.silent = true
|
66
|
+
Thin::Logging.debug = false
|
37
67
|
end
|
38
68
|
|
39
69
|
def get(url, params={})
|
@@ -52,11 +82,16 @@ module Spec::Example::ExampleMethods
|
|
52
82
|
request(:delete, url, params)
|
53
83
|
end
|
54
84
|
|
55
|
-
def
|
56
|
-
|
57
|
-
@request.__send__(method, url, params)
|
85
|
+
def env_for(method, url, params)
|
86
|
+
Rack::MockRequest.env_for(url, params.merge({:method => method.to_s.upcase, 'js_spec.connection' => connection}))
|
58
87
|
end
|
59
88
|
|
89
|
+
def create_request(method, url, params={})
|
90
|
+
env = env_for(method, url, params)
|
91
|
+
server.call(env)[2]
|
92
|
+
end
|
93
|
+
alias_method :request, :create_request
|
94
|
+
|
60
95
|
def core_path
|
61
96
|
JsSpec::Server.core_path
|
62
97
|
end
|
@@ -82,4 +117,4 @@ module Spec::Example::ExampleMethods
|
|
82
117
|
file && file.relative_path == expected_relative_path
|
83
118
|
end
|
84
119
|
end
|
85
|
-
end
|
120
|
+
end
|
metadata
CHANGED
@@ -1,91 +1,138 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: js_spec
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2008-01-25 00:00:00 -08:00
|
8
|
-
summary: The JSSpec client library (http://code.google.com/p/jsspec/) plus a convenient ruby server.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: brian@pivotallabs.com
|
12
|
-
homepage: http://pivotallabs.com
|
13
|
-
rubyforge_project: pivotalrb
|
14
|
-
description: The JSSpec client library (http://code.google.com/p/jsspec/) plus a convenient ruby server.
|
15
|
-
autorequire: js_spec
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.2.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Brian Takita & Nathan Sobo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-04-05 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: Selenium
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: thin
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: uuid
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
42
|
+
description: The JSSpec client library (http://code.google.com/p/jsspec/) plus a convenient ruby server.
|
43
|
+
email: brian@pivotallabs.com
|
44
|
+
executables:
|
45
|
+
- js_spec
|
46
|
+
- js_spec_server
|
47
|
+
extensions: []
|
48
|
+
|
49
|
+
extra_rdoc_files:
|
50
|
+
- README
|
51
|
+
- CHANGES
|
31
52
|
files:
|
53
|
+
- Rakefile
|
32
54
|
- CHANGES
|
33
55
|
- README
|
34
|
-
-
|
35
|
-
- lib/js_spec/
|
56
|
+
- init.rb
|
57
|
+
- lib/js_spec/thin/backends/js_spec_server.rb
|
58
|
+
- lib/js_spec/thin/js_spec_connection.rb
|
59
|
+
- lib/js_spec/rack/response.rb
|
60
|
+
- lib/js_spec/resources/spec_file_runner.rb
|
61
|
+
- lib/js_spec/resources/spec_runner.rb
|
36
62
|
- lib/js_spec/resources/dir.rb
|
63
|
+
- lib/js_spec/resources/runners/firefox1_runner.rb
|
64
|
+
- lib/js_spec/resources/runners/firefox_runner.rb
|
37
65
|
- lib/js_spec/resources/suite_finish.rb
|
38
|
-
- lib/js_spec/resources/runners.rb
|
39
|
-
- lib/js_spec/resources/spec_runner.rb
|
40
66
|
- lib/js_spec/resources/spec_dir_runner.rb
|
41
|
-
- lib/js_spec/resources/file.rb
|
42
67
|
- lib/js_spec/resources/web_root.rb
|
43
|
-
- lib/js_spec/resources/
|
44
|
-
- lib/js_spec/resources/spec_file_runner.rb
|
68
|
+
- lib/js_spec/resources/file.rb
|
45
69
|
- lib/js_spec/resources/suite.rb
|
70
|
+
- lib/js_spec/resources/runners.rb
|
71
|
+
- lib/js_spec/rails_server.rb
|
46
72
|
- lib/js_spec/server.rb
|
73
|
+
- lib/js_spec/client.rb
|
47
74
|
- lib/js_spec.rb
|
48
|
-
- core/COPYING
|
49
|
-
- core/JSSpec.css
|
50
|
-
- core/demo.html
|
51
|
-
- core/exp
|
52
75
|
- core/JSSpec.js
|
76
|
+
- core/jquery.js
|
53
77
|
- core/diff_match_patch.js
|
54
78
|
- core/JSSpecExtensions.js
|
55
|
-
-
|
79
|
+
- core/exp
|
80
|
+
- core/JSSpec.css
|
81
|
+
- core/demo.html
|
82
|
+
- core/COPYING
|
56
83
|
- bin/js_spec_server
|
57
|
-
-
|
58
|
-
- spec/
|
59
|
-
- spec/unit/resources/suite_spec.rb
|
60
|
-
- spec/unit/resources/spec_file_runner_spec.rb
|
61
|
-
- spec/unit/resources/runner_spec.rb
|
62
|
-
- spec/unit/resources/file_spec.rb
|
63
|
-
- spec/unit/resources/runners/firefox_runner_spec.rb
|
64
|
-
- spec/unit/resources/suite_finish_spec.rb
|
65
|
-
- spec/unit/resources/spec_dir_runner_spec.rb
|
66
|
-
- spec/unit/unit_spec_helper.rb
|
67
|
-
- spec/unit/rails_server_spec.rb
|
68
|
-
- spec/unit/server_spec.rb
|
69
|
-
- spec/functional/functional_spec_helper.rb
|
84
|
+
- bin/js_spec
|
85
|
+
- spec/spec_suite.rb
|
70
86
|
- spec/functional/server_spec.rb
|
87
|
+
- spec/functional/functional_spec_helper.rb
|
88
|
+
- spec/integration/integration_spec_helper.rb
|
89
|
+
- spec/integration/integration_spec.rb
|
90
|
+
- spec/integration_suite.rb
|
91
|
+
- spec/unit/thin/js_spec_connection_spec.rb
|
92
|
+
- spec/unit/rack/response_spec.rb
|
93
|
+
- spec/unit/js_spec/resources/spec_file_runner_spec.rb
|
94
|
+
- spec/unit/js_spec/resources/file_spec.rb
|
95
|
+
- spec/unit/js_spec/resources/spec_dir_runner_spec.rb
|
96
|
+
- spec/unit/js_spec/resources/suite_spec.rb
|
97
|
+
- spec/unit/js_spec/resources/dir_spec.rb
|
98
|
+
- spec/unit/js_spec/resources/suite_finish_spec.rb
|
99
|
+
- spec/unit/js_spec/resources/web_root_spec.rb
|
100
|
+
- spec/unit/js_spec/resources/runners/firefox_runner_spec.rb
|
101
|
+
- spec/unit/js_spec/resources/runner_spec.rb
|
102
|
+
- spec/unit/js_spec/server_spec.rb
|
103
|
+
- spec/unit/js_spec/client_spec.rb
|
104
|
+
- spec/unit/js_spec/rails_server_spec.rb
|
105
|
+
- spec/unit/unit_spec_helper.rb
|
71
106
|
- spec/functional_suite.rb
|
72
|
-
- spec/spec_suite.rb
|
73
107
|
- spec/unit_suite.rb
|
74
|
-
|
75
|
-
|
108
|
+
has_rdoc: true
|
109
|
+
homepage: http://pivotallabs.com
|
110
|
+
post_install_message:
|
76
111
|
rdoc_options:
|
77
112
|
- --main
|
78
113
|
- README
|
79
114
|
- --inline-source
|
80
115
|
- --line-numbers
|
81
|
-
|
82
|
-
-
|
83
|
-
|
84
|
-
|
85
|
-
-
|
86
|
-
|
87
|
-
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: "0"
|
123
|
+
version:
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: "0"
|
129
|
+
version:
|
88
130
|
requirements: []
|
89
131
|
|
90
|
-
|
132
|
+
rubyforge_project: pivotalrb
|
133
|
+
rubygems_version: 1.1.0
|
134
|
+
signing_key:
|
135
|
+
specification_version: 2
|
136
|
+
summary: The JSSpec client library (http://code.google.com/p/jsspec/) plus a convenient ruby server.
|
137
|
+
test_files: []
|
91
138
|
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsSpec
|
4
|
-
module Resources
|
5
|
-
describe Runners do
|
6
|
-
attr_reader :runner
|
7
|
-
before do
|
8
|
-
@runner = Runners.new
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "#locate" do
|
12
|
-
it "when passed 'firefox', returns a FirefoxRunner" do
|
13
|
-
runner.locate('firefox').should be_instance_of(Runners::FirefoxRunner)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "when not passed 'firefox', raises an error" do
|
17
|
-
lambda do
|
18
|
-
runner.locate('invalid')
|
19
|
-
end.should raise_error
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsSpec
|
4
|
-
module Resources
|
5
|
-
describe Runners::FirefoxRunner do
|
6
|
-
attr_reader :runner
|
7
|
-
before do
|
8
|
-
@runner = Runners::FirefoxRunner.new
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "#post" do
|
12
|
-
attr_reader :firefox_profile_path
|
13
|
-
before do
|
14
|
-
dir = ::File.dirname(__FILE__)
|
15
|
-
@firefox_profile_path = ::File.expand_path("#{dir}/../../../../resources/firefox")
|
16
|
-
::File.should be_directory(firefox_profile_path)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "returns ''" do
|
20
|
-
guid = nil
|
21
|
-
stub.proxy(UUID).new {|guid| guid = guid}
|
22
|
-
stub(runner).system {true}
|
23
|
-
stub(runner).sleep(0.5)
|
24
|
-
stub(runner).sleep {Kernel.sleep}
|
25
|
-
|
26
|
-
post_return_value = nil
|
27
|
-
Thread.start do
|
28
|
-
post_return_value = runner.post
|
29
|
-
end
|
30
|
-
wait_for do
|
31
|
-
Runners::FirefoxRunner.threads[guid]
|
32
|
-
end
|
33
|
-
Runners::FirefoxRunner.resume(guid, 'foobar')
|
34
|
-
|
35
|
-
wait_for do
|
36
|
-
post_return_value == 'foobar'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def wait_for(timeout=5)
|
41
|
-
Timeout.timeout(timeout) do
|
42
|
-
loop do
|
43
|
-
break if yield
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it "copies the firefox profile files to a tmp directory " <<
|
49
|
-
"and creates a profile " <<
|
50
|
-
"and waits for profile to be created " <<
|
51
|
-
"and starts firefox" do
|
52
|
-
stub(runner).sleep
|
53
|
-
|
54
|
-
mock(runner).system("cp -R #{firefox_profile_path} #{runner.profile_dir}").ordered {true}
|
55
|
-
mock(runner).system("firefox -profile #{runner.profile_dir} -chrome chrome://killff/content/kill.html").ordered {true}
|
56
|
-
mock(::File).exists?("#{runner.profile_dir}/parent.lock").ordered {false}
|
57
|
-
mock(runner).sleep(0.5).ordered
|
58
|
-
mock(::File).exists?("#{runner.profile_dir}/parent.lock").ordered {false}
|
59
|
-
mock(runner).system(Regexp.new("firefox -profile #{runner.profile_dir} http://localhost:8080/specs")).ordered {true}
|
60
|
-
stub(runner).callcc
|
61
|
-
runner.post
|
62
|
-
end
|
63
|
-
|
64
|
-
it "calls #copy_profile_files, #create_profile, #wait_for_full_profile_to_be_created, and #start_browser" do
|
65
|
-
stub(runner).system {true}
|
66
|
-
stub(runner).sleep
|
67
|
-
stub(runner).callcc
|
68
|
-
|
69
|
-
mock.proxy(runner).copy_profile_files.ordered
|
70
|
-
mock.proxy(runner).create_profile.ordered
|
71
|
-
mock.proxy(runner).wait_for_full_profile_to_be_created.ordered
|
72
|
-
mock.proxy(runner).start_browser(is_a(String)).ordered
|
73
|
-
|
74
|
-
runner.post
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "#start_browser" do
|
79
|
-
it "starts a firefox browser in a thread" do
|
80
|
-
mock(Thread).start.yields
|
81
|
-
mock(runner).system("firefox -profile #{runner.profile_dir} http://localhost:8080/specs?guid=foobar").ordered {true}
|
82
|
-
runner.__send__(:start_browser, "foobar")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsSpec
|
4
|
-
module Resources
|
5
|
-
describe SpecDirRunner do
|
6
|
-
attr_reader :dir, :runner
|
7
|
-
|
8
|
-
before do
|
9
|
-
@dir = Dir.new(spec_root_path, '/specs')
|
10
|
-
@runner = SpecDirRunner.new(dir)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#spec_files" do
|
14
|
-
it "returns a File for each *_spec.js file in the directory" do
|
15
|
-
spec_files = runner.spec_files
|
16
|
-
|
17
|
-
spec_files.should contain_spec_file_with_correct_paths("/failing_spec.js")
|
18
|
-
spec_files.should contain_spec_file_with_correct_paths("/foo/failing_spec.js")
|
19
|
-
spec_files.should contain_spec_file_with_correct_paths("/foo/passing_spec.js")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#get" do
|
24
|
-
attr_reader :html, :doc
|
25
|
-
before do
|
26
|
-
@html = runner.get()
|
27
|
-
@doc = Hpricot(html)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns script tags for each test javascript file" do
|
31
|
-
doc.at("script[@src='/specs/failing_spec.js']").should exist
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns the js specs template" do
|
35
|
-
doc.at("link[@href='/core/JSSpec.css']").should exist
|
36
|
-
doc.at("script[@src='/core/JSSpec.js']").should exist
|
37
|
-
doc.at("script[@src='/core/JSSpecExtensions.js']").should exist
|
38
|
-
doc.at("body").inner_html.should be_empty
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|