js_spec 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +12 -0
- data/README +2 -1
- data/Rakefile +2 -3
- data/core/JSSpecExtensions.js +18 -16
- data/lib/js_spec/resources/{spec_runner.rb → spec.rb} +4 -8
- data/lib/js_spec/resources.rb +1 -10
- data/lib/js_spec.rb +19 -20
- data/spec/integration/integration_spec.rb +14 -3
- data/spec/integration/integration_spec_helper.rb +1 -2
- data/spec/unit/js_test_core/resources/spec_dir_spec.rb +35 -0
- data/spec/unit/js_test_core/resources/spec_file_spec.rb +33 -0
- data/spec/unit/unit_spec_helper.rb +9 -9
- metadata +7 -46
- data/core/jquery.js +0 -2992
- data/lib/js_spec/client.rb +0 -50
- data/lib/js_spec/guid.rb +0 -153
- data/lib/js_spec/rack/commonlogger.rb +0 -5
- data/lib/js_spec/rack.rb +0 -2
- data/lib/js_spec/rails_server.rb +0 -22
- data/lib/js_spec/resources/dir.rb +0 -60
- data/lib/js_spec/resources/file.rb +0 -32
- data/lib/js_spec/resources/runners/firefox_runner.rb +0 -71
- data/lib/js_spec/resources/runners.rb +0 -15
- data/lib/js_spec/resources/spec_dir_runner.rb +0 -15
- data/lib/js_spec/resources/spec_file_runner.rb +0 -15
- data/lib/js_spec/resources/suite.rb +0 -24
- data/lib/js_spec/resources/suite_finish.rb +0 -20
- data/lib/js_spec/resources/web_root.rb +0 -34
- data/lib/js_spec/server.rb +0 -98
- data/lib/js_spec/thin/backends/js_spec_server.rb +0 -9
- data/lib/js_spec/thin/js_spec_connection.rb +0 -42
- data/lib/js_spec/thin.rb +0 -3
- data/spec/unit/js_spec/client_spec.rb +0 -137
- data/spec/unit/js_spec/rails_server_spec.rb +0 -45
- data/spec/unit/js_spec/resources/dir_spec.rb +0 -84
- data/spec/unit/js_spec/resources/file_spec.rb +0 -87
- data/spec/unit/js_spec/resources/runner_spec.rb +0 -24
- data/spec/unit/js_spec/resources/runners/firefox_runner_spec.rb +0 -152
- data/spec/unit/js_spec/resources/spec_dir_runner_spec.rb +0 -48
- data/spec/unit/js_spec/resources/spec_file_runner_spec.rb +0 -20
- data/spec/unit/js_spec/resources/suite_finish_spec.rb +0 -42
- data/spec/unit/js_spec/resources/suite_spec.rb +0 -44
- data/spec/unit/js_spec/resources/web_root_spec.rb +0 -55
- data/spec/unit/js_spec/server_spec.rb +0 -154
- data/spec/unit/thin/js_spec_connection_spec.rb +0 -64
@@ -1,137 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsSpec
|
4
|
-
describe Client do
|
5
|
-
describe '.run' do
|
6
|
-
describe 'when successful' do
|
7
|
-
before do
|
8
|
-
request = Object.new
|
9
|
-
mock(request).post("/runners/firefox", "selenium_host=localhost&selenium_port=4444")
|
10
|
-
response = Object.new
|
11
|
-
mock(response).body {""}
|
12
|
-
mock(Net::HTTP).start(DEFAULT_HOST, DEFAULT_PORT).yields(request) {response}
|
13
|
-
stub(Client).puts
|
14
|
-
end
|
15
|
-
|
16
|
-
it "returns true" do
|
17
|
-
Client.run.should be_true
|
18
|
-
end
|
19
|
-
|
20
|
-
it "prints 'SUCCESS'" do
|
21
|
-
mock(Client).puts("SUCCESS")
|
22
|
-
Client.run
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'when unsuccessful' do
|
27
|
-
before do
|
28
|
-
request = Object.new
|
29
|
-
mock(request).post("/runners/firefox", "selenium_host=localhost&selenium_port=4444")
|
30
|
-
response = Object.new
|
31
|
-
mock(response).body {"the failure message"}
|
32
|
-
mock(Net::HTTP).start(DEFAULT_HOST, DEFAULT_PORT).yields(request) {response}
|
33
|
-
stub(Client).puts
|
34
|
-
end
|
35
|
-
|
36
|
-
it "returns false" do
|
37
|
-
Client.run.should be_false
|
38
|
-
end
|
39
|
-
|
40
|
-
it "prints 'FAILURE' and the error message(s)" do
|
41
|
-
mock(Client).puts("FAILURE")
|
42
|
-
mock(Client).puts("the failure message")
|
43
|
-
Client.run
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "arguments" do
|
48
|
-
attr_reader :request, :response
|
49
|
-
before do
|
50
|
-
@request = Object.new
|
51
|
-
@response = Object.new
|
52
|
-
mock(response).body {""}
|
53
|
-
mock(Net::HTTP).start(DEFAULT_HOST, DEFAULT_PORT).yields(request) {response}
|
54
|
-
stub(Client).puts
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "when passed a custom spec_url" do
|
58
|
-
it "passes the spec_url as a post parameter" do
|
59
|
-
spec_url = 'http://foobar.com/foo'
|
60
|
-
mock(request).post(
|
61
|
-
"/runners/firefox",
|
62
|
-
"selenium_host=localhost&selenium_port=4444&spec_url=#{CGI.escape(spec_url)}"
|
63
|
-
)
|
64
|
-
Client.run(:spec_url => spec_url)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "when passed a custom selenium host" do
|
69
|
-
it "passes the selenium_host as a post parameter" do
|
70
|
-
selenium_host = 'test-runner'
|
71
|
-
mock(request).post(
|
72
|
-
"/runners/firefox",
|
73
|
-
"selenium_host=test-runner&selenium_port=4444"
|
74
|
-
)
|
75
|
-
Client.run(:selenium_host => selenium_host)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "when passed a custom selenium port" do
|
80
|
-
it "passes the selenium_port as a post parameter" do
|
81
|
-
selenium_port = 5000
|
82
|
-
mock(request).post(
|
83
|
-
"/runners/firefox",
|
84
|
-
"selenium_host=localhost&selenium_port=5000"
|
85
|
-
)
|
86
|
-
Client.run(:selenium_port => selenium_port)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
describe ".run_argv" do
|
94
|
-
attr_reader :request, :response
|
95
|
-
before do
|
96
|
-
@request = Object.new
|
97
|
-
@response = Object.new
|
98
|
-
mock(response).body {""}
|
99
|
-
mock(Net::HTTP).start(DEFAULT_HOST, DEFAULT_PORT).yields(request) {response}
|
100
|
-
stub(Client).puts
|
101
|
-
end
|
102
|
-
|
103
|
-
describe "when passed a custom spec_url" do
|
104
|
-
it "passes the spec_url as a post parameter" do
|
105
|
-
spec_url = 'http://foobar.com/foo'
|
106
|
-
mock(request).post(
|
107
|
-
"/runners/firefox",
|
108
|
-
"selenium_host=localhost&selenium_port=4444&spec_url=#{CGI.escape(spec_url)}"
|
109
|
-
)
|
110
|
-
Client.run_argv(['--spec_url', spec_url])
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "when passed a custom selenium host" do
|
115
|
-
it "passes the selenium_host as a post parameter" do
|
116
|
-
selenium_host = 'test-runner'
|
117
|
-
mock(request).post(
|
118
|
-
"/runners/firefox",
|
119
|
-
"selenium_host=test-runner&selenium_port=4444"
|
120
|
-
)
|
121
|
-
Client.run_argv(['--selenium_host', selenium_host])
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe "when passed a custom selenium port" do
|
126
|
-
it "passes the selenium_port as a post parameter" do
|
127
|
-
selenium_port = 5000
|
128
|
-
mock(request).post(
|
129
|
-
"/runners/firefox",
|
130
|
-
"selenium_host=localhost&selenium_port=5000"
|
131
|
-
)
|
132
|
-
Client.run_argv(['--selenium_port', selenium_port.to_s])
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsSpec
|
4
|
-
describe RailsServer do
|
5
|
-
it "subclasses Server" do
|
6
|
-
RailsServer.superclass.should == Server
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".run" do
|
10
|
-
attr_reader :rails_root
|
11
|
-
before do
|
12
|
-
@rails_root = "/rails/root"
|
13
|
-
Server.instance = nil
|
14
|
-
end
|
15
|
-
|
16
|
-
it "initializes the RailsServer and runs the Thin Handler and sets Server.instance to the RailsServer instance" do
|
17
|
-
host = DEFAULT_HOST
|
18
|
-
port = DEFAULT_PORT
|
19
|
-
server_instance = nil
|
20
|
-
mock.proxy(RailsServer).new(
|
21
|
-
rails_root,
|
22
|
-
host,
|
23
|
-
port
|
24
|
-
) do |new_instance|
|
25
|
-
server_instance = new_instance
|
26
|
-
end
|
27
|
-
|
28
|
-
mock(EventMachine).run.yields
|
29
|
-
mock(EventMachine).start_server(host, port, ::Thin::JsSpecConnection)
|
30
|
-
RailsServer.run(rails_root)
|
31
|
-
Server.instance.should == server_instance
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#initialize" do
|
36
|
-
it "sets the server paths based on the passed in rails root" do
|
37
|
-
rails_root = "/rails/root"
|
38
|
-
server = RailsServer.new(rails_root)
|
39
|
-
server.spec_root_path.should == "#{rails_root}/spec/javascripts"
|
40
|
-
server.implementation_root_path.should == "#{rails_root}/public/javascripts"
|
41
|
-
server.public_path.should == "#{rails_root}/public"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsSpec
|
4
|
-
module Resources
|
5
|
-
describe Dir do
|
6
|
-
attr_reader :dir, :absolute_path, :relative_path
|
7
|
-
|
8
|
-
describe "in core dir" do
|
9
|
-
before do
|
10
|
-
@absolute_path = core_path
|
11
|
-
@relative_path = "/core"
|
12
|
-
@dir = Resources::Dir.new(absolute_path, relative_path)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#locate when passed a name of a real file" do
|
16
|
-
it "returns a Resources::File representing it" do
|
17
|
-
file = dir.locate("JSSpec.css")
|
18
|
-
file.relative_path.should == "/core/JSSpec.css"
|
19
|
-
file.absolute_path.should == "#{core_path}/JSSpec.css"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "in specs dir" do
|
25
|
-
before do
|
26
|
-
@absolute_path = spec_root_path
|
27
|
-
@relative_path = "/specs"
|
28
|
-
@dir = Resources::Dir.new(absolute_path, relative_path)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "has an absolute path" do
|
32
|
-
dir.absolute_path.should == absolute_path
|
33
|
-
end
|
34
|
-
|
35
|
-
it "has a relative path" do
|
36
|
-
dir.relative_path.should == relative_path
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#locate when passed the name with an extension" do
|
40
|
-
it "when file exists, returns a Resources::File representing it" do
|
41
|
-
file = dir.locate("failing_spec.js")
|
42
|
-
file.relative_path.should == "/specs/failing_spec.js"
|
43
|
-
file.absolute_path.should == "#{spec_root_path}/failing_spec.js"
|
44
|
-
end
|
45
|
-
|
46
|
-
it "when file does not exist, raises error" do
|
47
|
-
lambda { dir.locate("nonexistent.js") }.should raise_error
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#locate when passed a name without an extension" do
|
52
|
-
it "when the name corresponds to a .js file in the directory, returns a SpecFileRunner for the file" do
|
53
|
-
file_runner = dir.locate("failing_spec")
|
54
|
-
file_runner.should be_an_instance_of(SpecFileRunner)
|
55
|
-
file_runner.file.should == spec_file("/failing_spec.js")
|
56
|
-
end
|
57
|
-
|
58
|
-
it "when name corresponds to a subdirectory, returns a DirectoryRunner for the directory" do
|
59
|
-
subdir = dir.locate("foo")
|
60
|
-
subdir.should be_an_instance_of(Resources::Dir)
|
61
|
-
subdir.should == spec_dir("/foo")
|
62
|
-
end
|
63
|
-
|
64
|
-
it "when name does not correspond to a .js file or directory, raises an error" do
|
65
|
-
lambda do
|
66
|
-
dir.locate("nonexistent")
|
67
|
-
end.should raise_error
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe Dir, "#glob" do
|
72
|
-
it "returns an array of matching Files under this directory with the correct relative paths" do
|
73
|
-
globbed_files = dir.glob("/**/*_spec.js")
|
74
|
-
|
75
|
-
globbed_files.size.should == 3
|
76
|
-
globbed_files.should contain_spec_file_with_correct_paths("/failing_spec.js")
|
77
|
-
globbed_files.should contain_spec_file_with_correct_paths("/foo/failing_spec.js")
|
78
|
-
globbed_files.should contain_spec_file_with_correct_paths("/foo/passing_spec.js")
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
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 File do
|
6
|
-
attr_reader :request, :file
|
7
|
-
|
8
|
-
before do
|
9
|
-
stub(EventMachine).send_data
|
10
|
-
stub(EventMachine).close_connection
|
11
|
-
@file = Resources::File.new(absolute_path, relative_path)
|
12
|
-
@request = create_request('get', relative_path)
|
13
|
-
end
|
14
|
-
|
15
|
-
def absolute_path
|
16
|
-
"#{spec_root_path}/failing_spec.js"
|
17
|
-
end
|
18
|
-
|
19
|
-
def relative_path
|
20
|
-
"/specs/failing_spec.js"
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#absolute_path" do
|
24
|
-
it "returns the absolute path passed into the initializer" do
|
25
|
-
file.absolute_path.should == absolute_path
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#relative_path" do
|
30
|
-
it "returns the relative path passed into the initializer" do
|
31
|
-
file.relative_path.should == relative_path
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#get" do
|
36
|
-
attr_reader :response
|
37
|
-
before do
|
38
|
-
@response = Rack::Response.new
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns the contents of the file" do
|
42
|
-
file.get(request, response)
|
43
|
-
response.body.should == ::File.read(absolute_path)
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "when File has an extension" do
|
47
|
-
describe '.js' do
|
48
|
-
it "sets Content-Type to text/javascript" do
|
49
|
-
file.get(request,response)
|
50
|
-
response.content_type.should == "text/javascript"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '.css' do
|
55
|
-
it "sets Content-Type to text/css" do
|
56
|
-
file.get(request, response)
|
57
|
-
response.content_type.should == "text/css"
|
58
|
-
end
|
59
|
-
|
60
|
-
def absolute_path
|
61
|
-
"#{core_path}/JSSpec.css"
|
62
|
-
end
|
63
|
-
|
64
|
-
def relative_path
|
65
|
-
"/core/JSSpec.css"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "==" do
|
72
|
-
it "returns true when passed a file with the same absolute and relative paths" do
|
73
|
-
file.should == Resources::File.new(absolute_path, relative_path)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "returns false when passed a file with a different absolute or relative path" do
|
77
|
-
file.should_not == Resources::File.new(absolute_path, "bogus")
|
78
|
-
file.should_not == Resources::File.new("bogus", relative_path)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "when passed a Dir, returns false because File is not a Dir" do
|
82
|
-
file.should_not == Resources::Dir.new(absolute_path, relative_path)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -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 Firefox1Runner" do
|
13
|
-
runner.locate('firefox').is_a?(Runners::FirefoxRunner).should be_true
|
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,152 +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, :request, :response, :driver
|
7
|
-
|
8
|
-
before do
|
9
|
-
Thread.current[:connection] = connection
|
10
|
-
@driver = "Selenium Driver"
|
11
|
-
stub(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://0.0.0.0:8080') do
|
12
|
-
driver
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#post" do
|
17
|
-
attr_reader :firefox_profile_path
|
18
|
-
before do
|
19
|
-
@request = Rack::Request.new( Rack::MockRequest.env_for('/runners/firefox') )
|
20
|
-
@response = Rack::Response.new
|
21
|
-
@runner = Runners::FirefoxRunner.new(request, response)
|
22
|
-
stub(Thread).start.yields
|
23
|
-
end
|
24
|
-
|
25
|
-
it "keeps the connection open" do
|
26
|
-
stub(driver).start
|
27
|
-
stub(driver).open
|
28
|
-
dont_allow(EventMachine).send_data
|
29
|
-
dont_allow(EventMachine).close_connection
|
30
|
-
runner.post(request, response)
|
31
|
-
|
32
|
-
response.body.should be_empty
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "when a selenium_host parameter is passed into the request" do
|
36
|
-
before do
|
37
|
-
request['selenium_host'] = "another-machine"
|
38
|
-
stub(driver).start
|
39
|
-
stub(driver).open
|
40
|
-
end
|
41
|
-
|
42
|
-
it "starts the Selenium Driver with the passed in selenium_host" do
|
43
|
-
mock(Selenium::SeleniumDriver).new('another-machine', 4444, '*firefox', 'http://0.0.0.0:8080') do
|
44
|
-
driver
|
45
|
-
end
|
46
|
-
runner.post(request, response)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "when a selenium_host parameter is not passed into the request" do
|
51
|
-
before do
|
52
|
-
request['selenium_host'].should be_nil
|
53
|
-
stub(driver).start
|
54
|
-
stub(driver).open
|
55
|
-
end
|
56
|
-
|
57
|
-
it "starts the Selenium Driver from localhost" do
|
58
|
-
mock(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://0.0.0.0:8080') do
|
59
|
-
driver
|
60
|
-
end
|
61
|
-
runner.post(request, response)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "when a selenium_port parameter is passed into the request" do
|
66
|
-
before do
|
67
|
-
request['selenium_port'] = "4000"
|
68
|
-
stub(driver).start
|
69
|
-
stub(driver).open
|
70
|
-
end
|
71
|
-
|
72
|
-
it "starts the Selenium Driver with the passed in selenium_port" do
|
73
|
-
mock(Selenium::SeleniumDriver).new('localhost', 4000, '*firefox', 'http://0.0.0.0:8080') do
|
74
|
-
driver
|
75
|
-
end
|
76
|
-
runner.post(request, response)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "when a selenium_port parameter is not passed into the request" do
|
81
|
-
before do
|
82
|
-
request['selenium_port'].should be_nil
|
83
|
-
stub(driver).start
|
84
|
-
stub(driver).open
|
85
|
-
end
|
86
|
-
|
87
|
-
it "starts the Selenium Driver from localhost" do
|
88
|
-
mock(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://0.0.0.0:8080') do
|
89
|
-
driver
|
90
|
-
end
|
91
|
-
runner.post(request, response)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "when a spec_url is passed into the request" do
|
96
|
-
before do
|
97
|
-
request['spec_url'] = "http://another-host:8080/specs/subdir"
|
98
|
-
end
|
99
|
-
|
100
|
-
it "runs Selenium with the passed in host and part to run the specified spec suite in Firefox" do
|
101
|
-
mock(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://another-host:8080') do
|
102
|
-
driver
|
103
|
-
end
|
104
|
-
mock(driver).start
|
105
|
-
mock(driver).open("http://another-host:8080/specs/subdir?guid=#{runner.guid}")
|
106
|
-
|
107
|
-
runner.post(request, response)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "when a spec_url is not passed into the request" do
|
112
|
-
before do
|
113
|
-
request['spec_url'].should be_nil
|
114
|
-
mock(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://0.0.0.0:8080') do
|
115
|
-
driver
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
it "uses Selenium to run the entire spec suite in Firefox" do
|
120
|
-
mock(driver).start
|
121
|
-
mock(driver).open("http://0.0.0.0:8080/specs?guid=#{runner.guid}")
|
122
|
-
|
123
|
-
runner.post(request, response)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "#finalize" do
|
129
|
-
before do
|
130
|
-
@request = Rack::Request.new( Rack::MockRequest.env_for('/runners/firefox') )
|
131
|
-
@response = Rack::Response.new
|
132
|
-
@runner = Runners::FirefoxRunner.new(request, response)
|
133
|
-
stub(driver).start
|
134
|
-
stub(driver).open
|
135
|
-
runner.post(request, response)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "kills the browser, sends the response body, and close the connection" do
|
139
|
-
mock(driver).stop
|
140
|
-
data = ""
|
141
|
-
stub(EventMachine).send_data do |signature, data, data_length|
|
142
|
-
data << data
|
143
|
-
end
|
144
|
-
mock(connection).close_connection_after_writing
|
145
|
-
|
146
|
-
runner.finalize("The text")
|
147
|
-
data.should include("The text")
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
@@ -1,48 +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
|
-
stub(EventMachine).send_data
|
10
|
-
stub(EventMachine).close_connection
|
11
|
-
@dir = Dir.new(spec_root_path, '/specs')
|
12
|
-
@runner = SpecDirRunner.new(dir)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#spec_files" do
|
16
|
-
it "returns a File for each *_spec.js file in the directory" do
|
17
|
-
spec_files = runner.spec_files
|
18
|
-
|
19
|
-
spec_files.should contain_spec_file_with_correct_paths("/failing_spec.js")
|
20
|
-
spec_files.should contain_spec_file_with_correct_paths("/foo/failing_spec.js")
|
21
|
-
spec_files.should contain_spec_file_with_correct_paths("/foo/passing_spec.js")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "#get" do
|
26
|
-
attr_reader :html, :doc
|
27
|
-
before do
|
28
|
-
request = request('get', '/specs')
|
29
|
-
response = Rack::Response.new
|
30
|
-
runner.get(request, response)
|
31
|
-
@html = response.body
|
32
|
-
@doc = Hpricot(html)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "returns script tags for each test javascript file" do
|
36
|
-
doc.at("script[@src='/specs/failing_spec.js']").should exist
|
37
|
-
end
|
38
|
-
|
39
|
-
it "returns the js specs template" do
|
40
|
-
doc.at("link[@href='/core/JSSpec.css']").should exist
|
41
|
-
doc.at("script[@src='/core/JSSpec.js']").should exist
|
42
|
-
doc.at("script[@src='/core/JSSpecExtensions.js']").should exist
|
43
|
-
doc.at("body/#js_spec_content").should_not be_nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsSpec
|
4
|
-
module Resources
|
5
|
-
describe SpecFileRunner, "#spec_files" do
|
6
|
-
attr_reader :absolute_path, :relative_path, :file, :runner
|
7
|
-
|
8
|
-
before do
|
9
|
-
@absolute_path = "#{spec_root_path}/failing_spec.js"
|
10
|
-
@relative_path = "/specs/failing_spec.js"
|
11
|
-
@file = File.new(absolute_path, relative_path)
|
12
|
-
@runner = SpecFileRunner.new(file)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns the single File to run in an Array" do
|
16
|
-
runner.spec_files.should == [file]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsSpec
|
4
|
-
module Resources
|
5
|
-
describe SuiteFinish do
|
6
|
-
attr_reader :stdout, :suite_finish, :suite
|
7
|
-
before do
|
8
|
-
@stdout = StringIO.new
|
9
|
-
SuiteFinish.const_set(:STDOUT, stdout)
|
10
|
-
@suite = Suite.new('foobar')
|
11
|
-
@suite_finish = SuiteFinish.new(suite)
|
12
|
-
end
|
13
|
-
|
14
|
-
after do
|
15
|
-
SuiteFinish.__send__(:remove_const, :STDOUT)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe ".post" do
|
19
|
-
describe "when the request has no guid" do
|
20
|
-
it "writes the body of the request to stdout" do
|
21
|
-
body = "The text in the POST body"
|
22
|
-
request = Rack::Request.new({'rack.input' => StringIO.new("text=#{body}")})
|
23
|
-
request.body.string.should == "text=#{body}"
|
24
|
-
response = Rack::Response.new
|
25
|
-
|
26
|
-
suite_finish.post(request, response)
|
27
|
-
stdout.string.should == "#{body}\n"
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns an empty string" do
|
31
|
-
body = "The text in the POST body"
|
32
|
-
request = Rack::Request.new({'rack.input' => StringIO.new("text=#{body}")})
|
33
|
-
request.body.string.should == "text=#{body}"
|
34
|
-
response = Rack::Response.new
|
35
|
-
|
36
|
-
suite_finish.post(request, response).should == ""
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsSpec
|
4
|
-
module Resources
|
5
|
-
describe Suite do
|
6
|
-
attr_reader :stdout
|
7
|
-
before do
|
8
|
-
@stdout = StringIO.new
|
9
|
-
Suite.const_set(:STDOUT, stdout)
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
Suite.__send__(:remove_const, :STDOUT)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe ".locate" do
|
17
|
-
it "when passed an identifier, returns an instance of Suite with the identifier" do
|
18
|
-
instance = Suite.locate('foobar')
|
19
|
-
instance.class.should == Suite
|
20
|
-
instance.id.should == 'foobar'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#locate" do
|
25
|
-
attr_reader :suite
|
26
|
-
before do
|
27
|
-
@suite = Suite.new('foobar')
|
28
|
-
end
|
29
|
-
|
30
|
-
it "when passed 'finish', returns a SuiteFinish that has access to the suite" do
|
31
|
-
suite_finish = suite.locate('finish')
|
32
|
-
suite_finish.class.should == SuiteFinish
|
33
|
-
suite_finish.suite.should == suite
|
34
|
-
end
|
35
|
-
|
36
|
-
it "when not passed 'finish', raises ArgumentError" do
|
37
|
-
lambda do
|
38
|
-
suite.locate('invalid')
|
39
|
-
end.should raise_error(ArgumentError, "Invalid path: invalid")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|