spassky 0.1.37 → 0.1.38
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.md +6 -13
- data/bin/spassky +30 -1
- data/examples/qunit-failing/main.js +3 -2
- data/examples/qunit-passing/main.js +3 -2
- data/features/device_timeout.feature +1 -1
- data/features/list_devices.feature +1 -2
- data/features/run_html_tests.feature +8 -8
- data/features/run_qunit_tests.feature +34 -9
- data/features/server.feature +1 -1
- data/features/step_definitions/steps.rb +2 -2
- data/features/summary.feature +3 -3
- data/features/support/env.rb +1 -2
- data/lib/spassky/client/cli.rb +1 -7
- data/lib/spassky/client/device_list_retriever.rb +0 -2
- data/lib/spassky/server/app.rb +6 -5
- data/lib/spassky/server/assert.js +7 -5
- data/lib/spassky/server/device_database.rb +1 -1
- data/lib/spassky/server/{html_test.rb → test_suite_container.rb} +6 -4
- data/lib/spassky/test_suite_result_summariser.rb +3 -6
- data/lib/spassky/version.rb +1 -1
- data/spassky.gemspec +1 -1
- data/spec/spassky/server/app_spec.rb +8 -46
- data/spec/spassky/server/device_database_spec.rb +1 -6
- data/spec/spassky/server/test_suite_container_spec.rb +46 -0
- metadata +32 -30
data/README.md
CHANGED
|
@@ -29,15 +29,10 @@ Architecture
|
|
|
29
29
|
+-------+ +-------+ +-----+
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
32
|
Developers push JS unit tests to the Spassky server through a command line interface.
|
|
35
33
|
Multiple devices connected to the central Spassky server will poll the server for a suite of tests.
|
|
36
34
|
The browser will be redirected to the test page, run the tests, and then are redirected to the idle loop.
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
36
|
Installation
|
|
42
37
|
------------
|
|
43
38
|
|
|
@@ -45,8 +40,6 @@ Installation
|
|
|
45
40
|
gem install spassky
|
|
46
41
|
```
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
43
|

|
|
51
44
|
|
|
52
45
|
|
|
@@ -56,7 +49,7 @@ Usage
|
|
|
56
49
|
Start the server:
|
|
57
50
|
|
|
58
51
|
```
|
|
59
|
-
spassky server 9191
|
|
52
|
+
spassky server --port 9191
|
|
60
53
|
```
|
|
61
54
|
|
|
62
55
|
Connect test devices by browsing to http://localhost:9191/device/connect on the device. The device will stay in an idle meta refresh loop until it receives a test to run.
|
|
@@ -64,25 +57,25 @@ Connect test devices by browsing to http://localhost:9191/device/connect on the
|
|
|
64
57
|
Check what devices are connected to the server:
|
|
65
58
|
|
|
66
59
|
```
|
|
67
|
-
spassky devices http://localhost:9191
|
|
60
|
+
spassky devices --server http://localhost:9191
|
|
68
61
|
```
|
|
69
62
|
|
|
70
63
|
Run a single html file (the second parameter is the test name):
|
|
71
64
|
|
|
72
65
|
```
|
|
73
|
-
spassky run html_test.html html_test.html http://localhost:9191
|
|
66
|
+
spassky run --pattern html_test.html --test html_test.html --server http://localhost:9191
|
|
74
67
|
```
|
|
75
68
|
|
|
76
69
|
Run a test with colour:
|
|
77
70
|
|
|
78
71
|
```
|
|
79
|
-
spassky run html_test.html html_test.html http://localhost:9191 --colour
|
|
72
|
+
spassky run --pattern html_test.html --test html_test.html --server http://localhost:9191 --colour
|
|
80
73
|
```
|
|
81
74
|
|
|
82
75
|
Run a directory that contains a test
|
|
83
76
|
|
|
84
77
|
```
|
|
85
|
-
spassky run test_directory html_test.html http://localhost:9191
|
|
78
|
+
spassky run --pattern test_directory --test html_test.html --server http://localhost:9191
|
|
86
79
|
```
|
|
87
80
|
|
|
88
81
|
Why?
|
|
@@ -97,7 +90,7 @@ Test structure
|
|
|
97
90
|
--------------
|
|
98
91
|
Tests can be either a single html file, or a directory containing multiple files.
|
|
99
92
|
|
|
100
|
-
If spassky is given a directory, it will pass all files in that directory to that server.
|
|
93
|
+
If spassky is given a directory, it will pass all files in that directory to that server. Any other files in the test directory can be linked to from the html file relatively.
|
|
101
94
|
|
|
102
95
|
### An example test directory:
|
|
103
96
|
```
|
data/bin/spassky
CHANGED
|
@@ -4,5 +4,34 @@ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(_
|
|
|
4
4
|
require 'rubygems'
|
|
5
5
|
require 'spassky'
|
|
6
6
|
require 'spassky/client/cli'
|
|
7
|
+
require 'trollop'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
command = ARGV.shift
|
|
10
|
+
|
|
11
|
+
if command == "run"
|
|
12
|
+
options = Trollop::options do
|
|
13
|
+
opt :pattern, "Test file name or test directory", :type => String
|
|
14
|
+
opt :test, "Test file name", :type => String
|
|
15
|
+
opt :server, "Spassky server", :type => String, :default => Spassky::Client::Cli::DEFAULT_SERVER
|
|
16
|
+
opt :colour, "Output tests results in colour", :default => false
|
|
17
|
+
end
|
|
18
|
+
Spassky::Client::Cli.new.run(options[:pattern], options[:test], options[:server], options[:colour])
|
|
19
|
+
elsif command == "devices"
|
|
20
|
+
options = Trollop::options do
|
|
21
|
+
opt :server, "Spassky server", :type => String, :default => Spassky::Client::Cli::DEFAULT_SERVER
|
|
22
|
+
end
|
|
23
|
+
Spassky::Client::Cli.new.devices(options[:server])
|
|
24
|
+
elsif command == "server"
|
|
25
|
+
options = Trollop::options do
|
|
26
|
+
opt :port, "The port to run the server on", :type => String, :default => Spassky::Client::Cli::DEFAULT_PORT
|
|
27
|
+
end
|
|
28
|
+
Spassky::Client::Cli.new.server(options[:port])
|
|
29
|
+
else
|
|
30
|
+
puts <<-USAGE
|
|
31
|
+
Spassky (version #{Spassky::VERSION})
|
|
32
|
+
Usage:
|
|
33
|
+
spassky run --pattern <pattern> --test <test> [--server <server>] [--colour]
|
|
34
|
+
spassky devices [--server <server>]
|
|
35
|
+
spassky server [--port <port>]
|
|
36
|
+
USAGE
|
|
37
|
+
end
|
|
@@ -21,7 +21,7 @@ Feature: Device Timeout
|
|
|
21
21
|
Scenario: One device times out
|
|
22
22
|
Given a connected mobile device "ipad"
|
|
23
23
|
When the device disconnects
|
|
24
|
-
And I run "spassky run timed-out.html timed-out.html <host>" with the server host
|
|
24
|
+
And I run "spassky run --pattern timed-out.html --test timed-out.html --server <host>" with the server host
|
|
25
25
|
Then the output should contain:
|
|
26
26
|
"""
|
|
27
27
|
TIMED OUT timed-out.html on ipad
|
|
@@ -7,11 +7,10 @@ Feature: List Connected Devices
|
|
|
7
7
|
Given a Wireless Universal Resource FiLe
|
|
8
8
|
And a connected mobile device "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3"
|
|
9
9
|
And a connected mobile device "Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10"
|
|
10
|
-
When I run "spassky devices <host>" with the server host
|
|
10
|
+
When I run "spassky devices --server <host>" with the server host
|
|
11
11
|
Then the output should contain exactly:
|
|
12
12
|
"""
|
|
13
13
|
iPhone (id = apple_iphone_ver1_suba543, mobile_browser = Safari, device_os_version = 1.0)
|
|
14
14
|
iPad (id = apple_ipad_ver1_sub5312110, mobile_browser = Safari, device_os_version = 3.2)
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
"""
|
|
@@ -13,7 +13,7 @@ Feature: Run HTML Tests
|
|
|
13
13
|
<body>
|
|
14
14
|
<h1>A PASSING test!</h1>
|
|
15
15
|
<script type="text/javascript">
|
|
16
|
-
assert(true, 'this test should pass');
|
|
16
|
+
new Spassky().assert(true, 'this test should pass');
|
|
17
17
|
</script>
|
|
18
18
|
</body>
|
|
19
19
|
</html>
|
|
@@ -26,7 +26,7 @@ Feature: Run HTML Tests
|
|
|
26
26
|
<body>
|
|
27
27
|
<h1>A FAILING test!</h1>
|
|
28
28
|
<script type="text/javascript">
|
|
29
|
-
assert(false, 'this test should fail');
|
|
29
|
+
new Spassky().assert(false, 'this test should fail');
|
|
30
30
|
</script>
|
|
31
31
|
</body>
|
|
32
32
|
</html>
|
|
@@ -34,7 +34,7 @@ Feature: Run HTML Tests
|
|
|
34
34
|
|
|
35
35
|
Scenario: No connected devices
|
|
36
36
|
Given I have no connected devices
|
|
37
|
-
When I run "spassky run passing.html passing.html <host>" with the server host
|
|
37
|
+
When I run "spassky run --pattern passing.html --test passing.html --server <host>" with the server host
|
|
38
38
|
Then the output should contain:
|
|
39
39
|
"""
|
|
40
40
|
There are no connected devices
|
|
@@ -43,7 +43,7 @@ Feature: Run HTML Tests
|
|
|
43
43
|
|
|
44
44
|
Scenario: One device with a user agent that exists in WURFL
|
|
45
45
|
Given a connected mobile device "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3"
|
|
46
|
-
When I run "spassky run passing.html passing.html <host>" with the server host
|
|
46
|
+
When I run "spassky run --pattern passing.html --test passing.html --server <host>" with the server host
|
|
47
47
|
Then the output should contain:
|
|
48
48
|
"""
|
|
49
49
|
PASS passing.html on iPhone (id = apple_iphone_ver1_suba543, mobile_browser = Safari, device_os_version = 1.0)
|
|
@@ -52,7 +52,7 @@ Feature: Run HTML Tests
|
|
|
52
52
|
|
|
53
53
|
Scenario: One passing test on one device
|
|
54
54
|
Given a connected mobile device "blackberry"
|
|
55
|
-
When I run "spassky run passing.html passing.html <host>" with the server host
|
|
55
|
+
When I run "spassky run --pattern passing.html --test passing.html --server <host>" with the server host
|
|
56
56
|
Then the output should contain:
|
|
57
57
|
"""
|
|
58
58
|
PASS passing.html on blackberry
|
|
@@ -62,7 +62,7 @@ Feature: Run HTML Tests
|
|
|
62
62
|
Scenario: One passing test on two devices
|
|
63
63
|
Given a connected mobile device "blackberry"
|
|
64
64
|
And a connected mobile device "iphone"
|
|
65
|
-
When I run "spassky run passing.html passing.html <host>" with the server host
|
|
65
|
+
When I run "spassky run --pattern passing.html --test passing.html --server <host>" with the server host
|
|
66
66
|
Then the output should contain:
|
|
67
67
|
"""
|
|
68
68
|
PASS passing.html on blackberry
|
|
@@ -75,7 +75,7 @@ Feature: Run HTML Tests
|
|
|
75
75
|
|
|
76
76
|
Scenario: Failing test
|
|
77
77
|
Given a connected mobile device "blackberry"
|
|
78
|
-
When I run "spassky run failing.html failing.html <host>" with the server host
|
|
78
|
+
When I run "spassky run --pattern failing.html --test failing.html --server <host>" with the server host
|
|
79
79
|
Then the output should contain:
|
|
80
80
|
"""
|
|
81
81
|
FAIL failing.html on blackberry
|
|
@@ -84,7 +84,7 @@ Feature: Run HTML Tests
|
|
|
84
84
|
|
|
85
85
|
Scenario: Failing Test with Message
|
|
86
86
|
Given a connected mobile device "blackberry"
|
|
87
|
-
When I run "spassky run failing.html failing.html <host>" with the server host
|
|
87
|
+
When I run "spassky run --pattern failing.html --test failing.html --server <host>" with the server host
|
|
88
88
|
Then the output should contain:
|
|
89
89
|
"""
|
|
90
90
|
FAIL failing.html on blackberry
|
|
@@ -8,10 +8,11 @@ Feature: Run QUnit Tests
|
|
|
8
8
|
Given a file named "qunit_passing/qunit_test/passing.js" with:
|
|
9
9
|
"""
|
|
10
10
|
QUnit.done = function(result) {
|
|
11
|
+
var spassky = new Spassky();
|
|
11
12
|
if (result.failed > 0) {
|
|
12
|
-
assert(false, "qunit failed");
|
|
13
|
+
spassky.assert(false, "qunit failed");
|
|
13
14
|
} else {
|
|
14
|
-
assert(true, "qunit passed");
|
|
15
|
+
spassky.assert(true, "qunit passed");
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
|
|
@@ -32,7 +33,7 @@ Feature: Run QUnit Tests
|
|
|
32
33
|
</html>
|
|
33
34
|
"""
|
|
34
35
|
And a connected mobile device "blackberry"
|
|
35
|
-
When I run "spassky run qunit_passing/qunit_test test_suite.html <host>" with the server host
|
|
36
|
+
When I run "spassky run --pattern qunit_passing/qunit_test --test test_suite.html --server <host>" with the server host
|
|
36
37
|
Then the output should contain:
|
|
37
38
|
"""
|
|
38
39
|
PASS test_suite.html on blackberry
|
|
@@ -43,10 +44,11 @@ Feature: Run QUnit Tests
|
|
|
43
44
|
Given a file named "qunit_failing/qunit_test/failing.js" with:
|
|
44
45
|
"""
|
|
45
46
|
QUnit.done = function(result) {
|
|
47
|
+
var spassky = new Spassky();
|
|
46
48
|
if (result.failed > 0) {
|
|
47
|
-
assert(false, "qunit failed");
|
|
49
|
+
spassky.assert(false, "qunit failed");
|
|
48
50
|
} else {
|
|
49
|
-
assert(true, "qunit passed");
|
|
51
|
+
spassky.assert(true, "qunit passed");
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
54
|
|
|
@@ -67,7 +69,7 @@ Feature: Run QUnit Tests
|
|
|
67
69
|
</html>
|
|
68
70
|
"""
|
|
69
71
|
And a connected mobile device "blackberry"
|
|
70
|
-
When I run "spassky run qunit_failing/qunit_test test_suite.html <host>" with the server host
|
|
72
|
+
When I run "spassky run --pattern qunit_failing/qunit_test --test test_suite.html --server <host>" with the server host
|
|
71
73
|
Then the output should contain:
|
|
72
74
|
"""
|
|
73
75
|
FAIL test_suite.html on blackberry
|
|
@@ -78,10 +80,11 @@ Feature: Run QUnit Tests
|
|
|
78
80
|
Given a file named "qunit_passing/qunit_test/another_directory/passing.js" with:
|
|
79
81
|
"""
|
|
80
82
|
QUnit.done = function(result) {
|
|
83
|
+
var spassky = new Spassky();
|
|
81
84
|
if (result.failed > 0) {
|
|
82
|
-
assert(false, "qunit failed");
|
|
85
|
+
spassky.assert(false, "qunit failed");
|
|
83
86
|
} else {
|
|
84
|
-
assert(true, "qunit passed");
|
|
87
|
+
spassky.assert(true, "qunit passed");
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
90
|
|
|
@@ -102,9 +105,31 @@ Feature: Run QUnit Tests
|
|
|
102
105
|
</html>
|
|
103
106
|
"""
|
|
104
107
|
And a connected mobile device "blackberry"
|
|
105
|
-
When I run "spassky run qunit_passing/qunit_test test_suite.html <host>" with the server host
|
|
108
|
+
When I run "spassky run --pattern qunit_passing/qunit_test --test test_suite.html --server <host>" with the server host
|
|
106
109
|
Then the output should contain:
|
|
107
110
|
"""
|
|
108
111
|
PASS test_suite.html on blackberry
|
|
109
112
|
"""
|
|
110
113
|
And the exit status should be 0
|
|
114
|
+
|
|
115
|
+
Scenario: Test with a file in a relative path
|
|
116
|
+
Given a file named "test/js/passing.js" with:
|
|
117
|
+
"""
|
|
118
|
+
new Spassky().assert(true, "qunit passed");
|
|
119
|
+
"""
|
|
120
|
+
And a file named "test/html/suite.html" with:
|
|
121
|
+
"""
|
|
122
|
+
<html>
|
|
123
|
+
<head></head>
|
|
124
|
+
<body>
|
|
125
|
+
<script type="text/javascript" src="../js/passing.js"></script>
|
|
126
|
+
</body>
|
|
127
|
+
</html>
|
|
128
|
+
"""
|
|
129
|
+
And a connected mobile device "blackberry"
|
|
130
|
+
When I run "spassky run --pattern test --test html/suite.html --server <host>" with the server host
|
|
131
|
+
Then the output should contain:
|
|
132
|
+
"""
|
|
133
|
+
PASS html/suite.html on blackberry
|
|
134
|
+
"""
|
|
135
|
+
And the exit status should be 0
|
data/features/server.feature
CHANGED
|
@@ -61,8 +61,8 @@ When /^the device disconnects$/ do
|
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
Given /^I run the command "spassky server 9393"$/ do
|
|
65
|
-
@spassky_server_process = ChildProcess.build('./bin/spassky server 9393')
|
|
64
|
+
Given /^I run the command "spassky server --port 9393"$/ do
|
|
65
|
+
@spassky_server_process = ChildProcess.build('./bin/spassky server --port 9393')
|
|
66
66
|
@spassky_server_process.start
|
|
67
67
|
end
|
|
68
68
|
|
data/features/summary.feature
CHANGED
|
@@ -10,7 +10,7 @@ Feature: Summary
|
|
|
10
10
|
<head></head>
|
|
11
11
|
<body>
|
|
12
12
|
<script type="text/javascript">
|
|
13
|
-
assert(true, 'this test should pass');
|
|
13
|
+
new Spassky().assert(true, 'this test should pass');
|
|
14
14
|
</script>
|
|
15
15
|
</body>
|
|
16
16
|
</html>
|
|
@@ -21,7 +21,7 @@ Feature: Summary
|
|
|
21
21
|
<head></head>
|
|
22
22
|
<body>
|
|
23
23
|
<script type="text/javascript">
|
|
24
|
-
assert(false, 'this test should fail');
|
|
24
|
+
new Spassky().assert(false, 'this test should fail');
|
|
25
25
|
</script>
|
|
26
26
|
</body>
|
|
27
27
|
</html>
|
|
@@ -29,5 +29,5 @@ Feature: Summary
|
|
|
29
29
|
|
|
30
30
|
Scenario: One test passing on all devices
|
|
31
31
|
Given I have two connected devices
|
|
32
|
-
When I run "spassky run passing.html passing.html <host>" with the server host
|
|
32
|
+
When I run "spassky run --pattern passing.html --test passing.html --server <host>" with the server host
|
|
33
33
|
Then the output should contain "2 passed"
|
data/features/support/env.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'capybara'
|
|
2
2
|
require 'capybara/dsl'
|
|
3
3
|
require 'capybara/cucumber'
|
|
4
|
-
|
|
5
4
|
require 'aruba/cucumber'
|
|
6
5
|
|
|
7
6
|
$:.unshift(File.join(File.dirname(__FILE__), '../../lib'))
|
|
@@ -28,4 +27,4 @@ def register_driver_with_user_agent user_agent
|
|
|
28
27
|
Capybara.current_driver = user_agent.to_sym
|
|
29
28
|
end
|
|
30
29
|
|
|
31
|
-
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
|
30
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
data/lib/spassky/client/cli.rb
CHANGED
|
@@ -5,24 +5,19 @@ require 'spassky/client/device_list_retriever'
|
|
|
5
5
|
require 'spassky/client/test_suite_runner'
|
|
6
6
|
require 'spassky/client/pusher'
|
|
7
7
|
require 'spassky/client/directory_reader'
|
|
8
|
-
require 'commandable'
|
|
9
8
|
|
|
10
9
|
module Spassky::Client
|
|
11
10
|
class Cli
|
|
12
|
-
extend Commandable
|
|
13
|
-
|
|
14
11
|
DEFAULT_PORT = "9191"
|
|
15
12
|
DEFAULT_SERVER = "http://localhost:#{DEFAULT_PORT}"
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
def run(pattern, test, server = DEFAULT_SERVER, colour = false)
|
|
14
|
+
def run(pattern, test, server = DEFAULT_SERVER, colour = FALSE)
|
|
19
15
|
writer = colour ? ColouredWriter : DefaultWriter
|
|
20
16
|
pusher = Pusher.new(server)
|
|
21
17
|
test_suite_runner = TestSuiteRunner.new(pusher, writer.new(STDOUT), DirectoryReader.new(pattern))
|
|
22
18
|
test_suite_runner.run_test_suite(pattern, test)
|
|
23
19
|
end
|
|
24
20
|
|
|
25
|
-
command "list devices"
|
|
26
21
|
def devices(server = DEFAULT_SERVER)
|
|
27
22
|
Spassky::Client::DeviceListRetriever.new(server).get_connected_devices.each do |device|
|
|
28
23
|
puts device
|
|
@@ -30,7 +25,6 @@ module Spassky::Client
|
|
|
30
25
|
nil
|
|
31
26
|
end
|
|
32
27
|
|
|
33
|
-
command "run the spassky server"
|
|
34
28
|
def server(port = DEFAULT_PORT)
|
|
35
29
|
Spassky::Server::App.set :port, port
|
|
36
30
|
Spassky::Server::App.run!
|
|
@@ -2,7 +2,6 @@ require 'restclient'
|
|
|
2
2
|
|
|
3
3
|
module Spassky::Client
|
|
4
4
|
class DeviceListRetriever
|
|
5
|
-
|
|
6
5
|
def initialize(url)
|
|
7
6
|
@url = url
|
|
8
7
|
end
|
|
@@ -10,6 +9,5 @@ module Spassky::Client
|
|
|
10
9
|
def get_connected_devices
|
|
11
10
|
JSON.parse(RestClient.get(@url + "/devices/list"))
|
|
12
11
|
end
|
|
13
|
-
|
|
14
12
|
end
|
|
15
13
|
end
|
data/lib/spassky/server/app.rb
CHANGED
|
@@ -2,7 +2,7 @@ require 'sinatra/base'
|
|
|
2
2
|
require 'spassky/server/random_string_generator'
|
|
3
3
|
require 'spassky/server/test_run'
|
|
4
4
|
require 'spassky/server/device_list'
|
|
5
|
-
require 'spassky/server/
|
|
5
|
+
require 'spassky/server/test_suite_container'
|
|
6
6
|
require 'spassky/server/device_database'
|
|
7
7
|
|
|
8
8
|
module Spassky::Server
|
|
@@ -57,8 +57,7 @@ module Spassky::Server
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
get "/test_runs/:id/run/:random/*" do
|
|
60
|
-
|
|
61
|
-
get_test_file_contents params[:id], file_name
|
|
60
|
+
get_test_file_contents
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
private
|
|
@@ -79,8 +78,10 @@ module Spassky::Server
|
|
|
79
78
|
JSON.parse(params[:contents])
|
|
80
79
|
end
|
|
81
80
|
|
|
82
|
-
def get_test_file_contents
|
|
83
|
-
|
|
81
|
+
def get_test_file_contents
|
|
82
|
+
file_name = params[:splat].join("/")
|
|
83
|
+
assert_post_back_url = "/test_runs/#{params[:id]}/run/#{params[:random]}/assert"
|
|
84
|
+
TestSuiteContainer.new(test_run.contents, idle_url, assert_post_back_url, 1).get_file(file_name)
|
|
84
85
|
end
|
|
85
86
|
|
|
86
87
|
def save_test_result
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function Spassky() {
|
|
2
|
+
this.assert = function(status, message) {
|
|
3
|
+
var img = document.createElement('img');
|
|
4
|
+
img.setAttribute('src', '{ASSERT_POST_BACK_URL}?status=' + (status ? 'pass' : 'fail') + '&message=' + escape(message));
|
|
5
|
+
document.body.appendChild(img);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -45,7 +45,7 @@ module Spassky::Server
|
|
|
45
45
|
def uncached_device_identifier user_agent
|
|
46
46
|
@stored_device_identifiers ||= {}
|
|
47
47
|
if device = @wurfl[user_agent]
|
|
48
|
-
@stored_device_identifiers[user_agent] = "#{device.model_name} (id = #{device
|
|
48
|
+
@stored_device_identifiers[user_agent] = "#{device.model_name} (id = #{device[:id]}, mobile_browser = #{device.mobile_browser}, device_os_version = #{device.device_os_version})"
|
|
49
49
|
else
|
|
50
50
|
@stored_device_identifiers[user_agent] = user_agent
|
|
51
51
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Spassky::Server
|
|
2
|
-
class
|
|
3
|
-
def initialize(contents,
|
|
2
|
+
class TestSuiteContainer
|
|
3
|
+
def initialize(contents, next_url_to_redirect_to, assert_post_back_url, seconds)
|
|
4
4
|
@contents = contents
|
|
5
|
-
@
|
|
5
|
+
@next_url_to_redirect_to = next_url_to_redirect_to
|
|
6
|
+
@assert_post_back_url = assert_post_back_url
|
|
6
7
|
@seconds = seconds
|
|
7
8
|
end
|
|
8
9
|
|
|
@@ -19,11 +20,12 @@ module Spassky::Server
|
|
|
19
20
|
|
|
20
21
|
def assert_js_script
|
|
21
22
|
assert_js = File.read(File.join(File.dirname(__FILE__), 'assert.js'))
|
|
23
|
+
assert_js.gsub!("{ASSERT_POST_BACK_URL}", @assert_post_back_url)
|
|
22
24
|
"<script type=\"text/javascript\">#{assert_js}</script>"
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def meta_refresh_tag
|
|
26
|
-
"<meta http-equiv=\"refresh\" content=\"#{@seconds}; url='#{@
|
|
28
|
+
"<meta http-equiv=\"refresh\" content=\"#{@seconds}; url='#{@next_url_to_redirect_to}'\">"
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
end
|
|
@@ -6,12 +6,9 @@ module Spassky
|
|
|
6
6
|
|
|
7
7
|
def summary
|
|
8
8
|
statuses = []
|
|
9
|
-
{"pass"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
statuses << "#{status_count} #{description}"
|
|
13
|
-
end
|
|
14
|
-
end
|
|
9
|
+
statuses << "#{status_count("pass")} passed" if status_count("pass") > 0
|
|
10
|
+
statuses << "#{status_count("fail")} failed" if status_count("fail") > 0
|
|
11
|
+
statuses << "#{status_count("timed out")} timed out" if status_count("timed out") > 0
|
|
15
12
|
statuses.join ", "
|
|
16
13
|
end
|
|
17
14
|
|
data/lib/spassky/version.rb
CHANGED
data/spassky.gemspec
CHANGED
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
s.add_dependency 'sinatra'
|
|
24
24
|
s.add_dependency 'rainbow'
|
|
25
25
|
s.add_dependency 'wurfl-lite'
|
|
26
|
-
s.add_dependency '
|
|
26
|
+
s.add_dependency 'trollop'
|
|
27
27
|
|
|
28
28
|
s.add_development_dependency 'rake'
|
|
29
29
|
s.add_development_dependency 'rspec'
|
|
@@ -93,52 +93,14 @@ module Spassky::Server
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
describe "GET /test_runs/:id/run/:random/path/to/file" do
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
context "file name is a file" do
|
|
106
|
-
it "returns the specified file" do
|
|
107
|
-
test = mock(:test, :name => "fake_test.html.file", :contents => @test_contents)
|
|
108
|
-
TestRun.stub!(:find).with('123').and_return(test)
|
|
109
|
-
get "/test_runs/123/run/random/fake_test.html.file"
|
|
110
|
-
last_response.body.should include("don't choose this one")
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
context "with a file that is in a subdirectory" do
|
|
115
|
-
it "returns the file" do
|
|
116
|
-
test = mock(:test, :name => "test_name", :contents => @test_contents)
|
|
117
|
-
TestRun.stub!(:find).and_return(test)
|
|
118
|
-
get "/test_runs/123/run/random/directory/another_directory/filename.txt"
|
|
119
|
-
last_response.body.should include "file 1 contents"
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
describe "when the test contents includes a </head> tag" do
|
|
124
|
-
before do
|
|
125
|
-
@test_contents["test_name.html"] = "</head>"
|
|
126
|
-
@test = mock(:test, :name => "test_name", :contents => @test_contents)
|
|
127
|
-
TestRun.stub!(:find).with('123').and_return(@test)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "adds a meta-refresh tag to the test contents" do
|
|
131
|
-
RandomStringGenerator.stub!(:random_string).and_return("next-iteration")
|
|
132
|
-
get "/test_runs/123/run/random/test_name.html"
|
|
133
|
-
url = "/device/idle/next-iteration"
|
|
134
|
-
last_response.body.should include("<meta http-equiv=\"refresh\" content=\"1; url='#{url}'\"></head>")
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
it "adds the assert.js script to the head" do
|
|
138
|
-
File.stub!(:read).and_return("assert.js!")
|
|
139
|
-
get "/test_runs/123/run/random/test_name.html"
|
|
140
|
-
last_response.body.should include("<script type=\"text/javascript\">assert.js!</script>")
|
|
141
|
-
end
|
|
96
|
+
it "gets the contents of the file" do
|
|
97
|
+
test = mock(:test, :name => "fake_test.html.file", :contents => {})
|
|
98
|
+
TestRun.stub!(:find).with('123').and_return(test)
|
|
99
|
+
html_test = mock(:html_test)
|
|
100
|
+
html_test.stub!(:get_file).and_return("contents")
|
|
101
|
+
TestSuiteContainer.should_receive(:new).with({}, "/device/idle/random-string", "/test_runs/123/run/random/assert", 1).and_return html_test
|
|
102
|
+
get "/test_runs/123/run/random/fake_test.html.file"
|
|
103
|
+
last_response.body.should == "contents"
|
|
142
104
|
end
|
|
143
105
|
end
|
|
144
106
|
|
|
@@ -16,11 +16,6 @@ module Spassky::Server
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
context ".new" do
|
|
19
|
-
it "creates the wurfl directory" do
|
|
20
|
-
FileUtils.should_receive(:mkdir_p).with(Spassky::Server::WURFL_DIRECTORY)
|
|
21
|
-
DeviceDatabase.new
|
|
22
|
-
end
|
|
23
|
-
|
|
24
19
|
it "loads up the wurfl database" do
|
|
25
20
|
wurfl = mock(:wurfl).as_null_object
|
|
26
21
|
WURFL.should_receive(:new).with(Spassky::Server::WURFL_FILE).and_return(wurfl)
|
|
@@ -56,7 +51,7 @@ module Spassky::Server
|
|
|
56
51
|
it "returns the device identifier" do
|
|
57
52
|
device = mock(:device)
|
|
58
53
|
device.stub!(:model_name).and_return "MODEL"
|
|
59
|
-
device.stub!(:id).and_return
|
|
54
|
+
device.stub!(:[]).with(:id).and_return("ID")
|
|
60
55
|
device.stub!(:mobile_browser).and_return "BROWSER"
|
|
61
56
|
device.stub!(:device_os_version).and_return "OS_VERSION"
|
|
62
57
|
wurfl = mock(:wurfl)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "spassky/server/test_suite_container"
|
|
3
|
+
|
|
4
|
+
module Spassky::Server
|
|
5
|
+
describe TestSuiteContainer do
|
|
6
|
+
before do
|
|
7
|
+
@test_contents = {
|
|
8
|
+
"test_file.js" => "some javascript",
|
|
9
|
+
"fake_test.html.file" => "don't choose this one",
|
|
10
|
+
"test_name.html" => "actual test!",
|
|
11
|
+
"directory/another_directory/filename.txt" => "file 1 contents",
|
|
12
|
+
"example_test.html" => "</head>"
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context "file name is a file" do
|
|
17
|
+
it "returns the specified file" do
|
|
18
|
+
TestSuiteContainer.new(@test_contents, nil, "", nil).get_file("test_file.js").should == "some javascript"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context "with a file that is in a subdirectory" do
|
|
23
|
+
it "returns the file" do
|
|
24
|
+
TestSuiteContainer.new(@test_contents, nil, "", nil).get_file("directory/another_directory/filename.txt").should == "file 1 contents"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "when the test contents includes a </head> tag" do
|
|
29
|
+
it "adds a meta-refresh tag to the test contents" do
|
|
30
|
+
url = "http://example.org"
|
|
31
|
+
seconds = 23
|
|
32
|
+
TestSuiteContainer.new(@test_contents, url, "", seconds).get_file("example_test.html").should include "<meta http-equiv=\"refresh\" content=\"#{seconds}; url='#{url}'\"></head>"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "adds the assert.js script to the head" do
|
|
36
|
+
File.stub!(:read).and_return("assert.js!")
|
|
37
|
+
TestSuiteContainer.new(@test_contents, nil, "", nil).get_file("example_test.html").should include "<script type=\"text/javascript\">assert.js!</script>"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "injects the assert post back url into assert.js" do
|
|
41
|
+
File.stub!(:read).and_return("assert.js! {ASSERT_POST_BACK_URL}")
|
|
42
|
+
TestSuiteContainer.new(@test_contents, nil, "http://assert.org", nil).get_file("example_test.html").should include "assert.js! http://assert.org"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spassky
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.38
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -11,11 +11,11 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2011-09-
|
|
14
|
+
date: 2011-09-29 00:00:00.000000000Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: rest-client
|
|
18
|
-
requirement: &
|
|
18
|
+
requirement: &70310251255100 !ruby/object:Gem::Requirement
|
|
19
19
|
none: false
|
|
20
20
|
requirements:
|
|
21
21
|
- - ! '>='
|
|
@@ -23,10 +23,10 @@ dependencies:
|
|
|
23
23
|
version: '0'
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
|
-
version_requirements: *
|
|
26
|
+
version_requirements: *70310251255100
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: json
|
|
29
|
-
requirement: &
|
|
29
|
+
requirement: &70310251254640 !ruby/object:Gem::Requirement
|
|
30
30
|
none: false
|
|
31
31
|
requirements:
|
|
32
32
|
- - ! '>='
|
|
@@ -34,10 +34,10 @@ dependencies:
|
|
|
34
34
|
version: '0'
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
|
-
version_requirements: *
|
|
37
|
+
version_requirements: *70310251254640
|
|
38
38
|
- !ruby/object:Gem::Dependency
|
|
39
39
|
name: sinatra
|
|
40
|
-
requirement: &
|
|
40
|
+
requirement: &70310251254120 !ruby/object:Gem::Requirement
|
|
41
41
|
none: false
|
|
42
42
|
requirements:
|
|
43
43
|
- - ! '>='
|
|
@@ -45,10 +45,10 @@ dependencies:
|
|
|
45
45
|
version: '0'
|
|
46
46
|
type: :runtime
|
|
47
47
|
prerelease: false
|
|
48
|
-
version_requirements: *
|
|
48
|
+
version_requirements: *70310251254120
|
|
49
49
|
- !ruby/object:Gem::Dependency
|
|
50
50
|
name: rainbow
|
|
51
|
-
requirement: &
|
|
51
|
+
requirement: &70310251253620 !ruby/object:Gem::Requirement
|
|
52
52
|
none: false
|
|
53
53
|
requirements:
|
|
54
54
|
- - ! '>='
|
|
@@ -56,10 +56,10 @@ dependencies:
|
|
|
56
56
|
version: '0'
|
|
57
57
|
type: :runtime
|
|
58
58
|
prerelease: false
|
|
59
|
-
version_requirements: *
|
|
59
|
+
version_requirements: *70310251253620
|
|
60
60
|
- !ruby/object:Gem::Dependency
|
|
61
61
|
name: wurfl-lite
|
|
62
|
-
requirement: &
|
|
62
|
+
requirement: &70310251252960 !ruby/object:Gem::Requirement
|
|
63
63
|
none: false
|
|
64
64
|
requirements:
|
|
65
65
|
- - ! '>='
|
|
@@ -67,10 +67,10 @@ dependencies:
|
|
|
67
67
|
version: '0'
|
|
68
68
|
type: :runtime
|
|
69
69
|
prerelease: false
|
|
70
|
-
version_requirements: *
|
|
70
|
+
version_requirements: *70310251252960
|
|
71
71
|
- !ruby/object:Gem::Dependency
|
|
72
|
-
name:
|
|
73
|
-
requirement: &
|
|
72
|
+
name: trollop
|
|
73
|
+
requirement: &70310251251840 !ruby/object:Gem::Requirement
|
|
74
74
|
none: false
|
|
75
75
|
requirements:
|
|
76
76
|
- - ! '>='
|
|
@@ -78,10 +78,10 @@ dependencies:
|
|
|
78
78
|
version: '0'
|
|
79
79
|
type: :runtime
|
|
80
80
|
prerelease: false
|
|
81
|
-
version_requirements: *
|
|
81
|
+
version_requirements: *70310251251840
|
|
82
82
|
- !ruby/object:Gem::Dependency
|
|
83
83
|
name: rake
|
|
84
|
-
requirement: &
|
|
84
|
+
requirement: &70310251251340 !ruby/object:Gem::Requirement
|
|
85
85
|
none: false
|
|
86
86
|
requirements:
|
|
87
87
|
- - ! '>='
|
|
@@ -89,10 +89,10 @@ dependencies:
|
|
|
89
89
|
version: '0'
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
|
-
version_requirements: *
|
|
92
|
+
version_requirements: *70310251251340
|
|
93
93
|
- !ruby/object:Gem::Dependency
|
|
94
94
|
name: rspec
|
|
95
|
-
requirement: &
|
|
95
|
+
requirement: &70310251250800 !ruby/object:Gem::Requirement
|
|
96
96
|
none: false
|
|
97
97
|
requirements:
|
|
98
98
|
- - ! '>='
|
|
@@ -100,10 +100,10 @@ dependencies:
|
|
|
100
100
|
version: '0'
|
|
101
101
|
type: :development
|
|
102
102
|
prerelease: false
|
|
103
|
-
version_requirements: *
|
|
103
|
+
version_requirements: *70310251250800
|
|
104
104
|
- !ruby/object:Gem::Dependency
|
|
105
105
|
name: cucumber
|
|
106
|
-
requirement: &
|
|
106
|
+
requirement: &70310251238380 !ruby/object:Gem::Requirement
|
|
107
107
|
none: false
|
|
108
108
|
requirements:
|
|
109
109
|
- - ! '>='
|
|
@@ -111,10 +111,10 @@ dependencies:
|
|
|
111
111
|
version: '0'
|
|
112
112
|
type: :development
|
|
113
113
|
prerelease: false
|
|
114
|
-
version_requirements: *
|
|
114
|
+
version_requirements: *70310251238380
|
|
115
115
|
- !ruby/object:Gem::Dependency
|
|
116
116
|
name: capybara
|
|
117
|
-
requirement: &
|
|
117
|
+
requirement: &70310251237700 !ruby/object:Gem::Requirement
|
|
118
118
|
none: false
|
|
119
119
|
requirements:
|
|
120
120
|
- - ! '>='
|
|
@@ -122,10 +122,10 @@ dependencies:
|
|
|
122
122
|
version: '0'
|
|
123
123
|
type: :development
|
|
124
124
|
prerelease: false
|
|
125
|
-
version_requirements: *
|
|
125
|
+
version_requirements: *70310251237700
|
|
126
126
|
- !ruby/object:Gem::Dependency
|
|
127
127
|
name: aruba
|
|
128
|
-
requirement: &
|
|
128
|
+
requirement: &70310251237280 !ruby/object:Gem::Requirement
|
|
129
129
|
none: false
|
|
130
130
|
requirements:
|
|
131
131
|
- - ! '>='
|
|
@@ -133,10 +133,10 @@ dependencies:
|
|
|
133
133
|
version: '0'
|
|
134
134
|
type: :development
|
|
135
135
|
prerelease: false
|
|
136
|
-
version_requirements: *
|
|
136
|
+
version_requirements: *70310251237280
|
|
137
137
|
- !ruby/object:Gem::Dependency
|
|
138
138
|
name: fakefs
|
|
139
|
-
requirement: &
|
|
139
|
+
requirement: &70310251236860 !ruby/object:Gem::Requirement
|
|
140
140
|
none: false
|
|
141
141
|
requirements:
|
|
142
142
|
- - ! '>='
|
|
@@ -144,10 +144,10 @@ dependencies:
|
|
|
144
144
|
version: '0'
|
|
145
145
|
type: :development
|
|
146
146
|
prerelease: false
|
|
147
|
-
version_requirements: *
|
|
147
|
+
version_requirements: *70310251236860
|
|
148
148
|
- !ruby/object:Gem::Dependency
|
|
149
149
|
name: factory_girl
|
|
150
|
-
requirement: &
|
|
150
|
+
requirement: &70310251236420 !ruby/object:Gem::Requirement
|
|
151
151
|
none: false
|
|
152
152
|
requirements:
|
|
153
153
|
- - ! '>='
|
|
@@ -155,7 +155,7 @@ dependencies:
|
|
|
155
155
|
version: '0'
|
|
156
156
|
type: :development
|
|
157
157
|
prerelease: false
|
|
158
|
-
version_requirements: *
|
|
158
|
+
version_requirements: *70310251236420
|
|
159
159
|
description: ''
|
|
160
160
|
email:
|
|
161
161
|
- andrew.vos@gmail.com
|
|
@@ -202,9 +202,9 @@ files:
|
|
|
202
202
|
- lib/spassky/server/assert.js
|
|
203
203
|
- lib/spassky/server/device_database.rb
|
|
204
204
|
- lib/spassky/server/device_list.rb
|
|
205
|
-
- lib/spassky/server/html_test.rb
|
|
206
205
|
- lib/spassky/server/random_string_generator.rb
|
|
207
206
|
- lib/spassky/server/test_run.rb
|
|
207
|
+
- lib/spassky/server/test_suite_container.rb
|
|
208
208
|
- lib/spassky/test_suite_result.rb
|
|
209
209
|
- lib/spassky/test_suite_result_summariser.rb
|
|
210
210
|
- lib/spassky/version.rb
|
|
@@ -222,6 +222,7 @@ files:
|
|
|
222
222
|
- spec/spassky/server/device_list_spec.rb
|
|
223
223
|
- spec/spassky/server/random_string_generator_spec.rb
|
|
224
224
|
- spec/spassky/server/test_run_spec.rb
|
|
225
|
+
- spec/spassky/server/test_suite_container_spec.rb
|
|
225
226
|
- spec/spassky/test_suite_result_spec.rb
|
|
226
227
|
- spec/spassky/test_suite_result_summariser_spec.rb
|
|
227
228
|
- spec/spec_helper.rb
|
|
@@ -272,6 +273,7 @@ test_files:
|
|
|
272
273
|
- spec/spassky/server/device_list_spec.rb
|
|
273
274
|
- spec/spassky/server/random_string_generator_spec.rb
|
|
274
275
|
- spec/spassky/server/test_run_spec.rb
|
|
276
|
+
- spec/spassky/server/test_suite_container_spec.rb
|
|
275
277
|
- spec/spassky/test_suite_result_spec.rb
|
|
276
278
|
- spec/spassky/test_suite_result_summariser_spec.rb
|
|
277
279
|
- spec/spec_helper.rb
|