ghostbuster 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/Rakefile +27 -40
- data/lib/ghostbuster.coffee +9 -5
- data/lib/ghostbuster/version.rb +1 -1
- data/test/non_working_ghost/Ghostfile +1 -1
- data/test/non_working_ghost/start.sh +2 -1
- data/test/non_working_ghost/stop.sh +2 -1
- data/test/non_working_ghost/test_ghost.coffee +5 -0
- data/test/non_working_ghost/test_ghostmore.coffee +5 -0
- data/test/server1/Gemfile +6 -0
- data/test/server1/config.ru +5 -0
- data/test/server1/start.sh +1 -1
- data/test/working_ghost/start.sh +2 -1
- data/test/working_ghost/stop.sh +2 -1
- data/test/working_ghost/test_ghost.coffee +1 -0
- data/test/working_ghost/test_ghostmore.coffee +5 -0
- metadata +6 -22
- data/test/non_working_ghost/config.ru +0 -23
- data/test/non_working_ghost/views/form.erb +0 -12
- data/test/non_working_ghost/views/index.erb +0 -15
- data/test/non_working_ghost/views/slow.erb +0 -12
- data/test/output +0 -31
- data/test/working_ghost/config.ru +0 -23
- data/test/working_ghost/views/form.erb +0 -12
- data/test/working_ghost/views/index.erb +0 -15
- data/test/working_ghost/views/slow.erb +0 -12
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -3,45 +3,32 @@ require 'bundler/gem_tasks'
|
|
3
3
|
STDOUT.sync = true
|
4
4
|
|
5
5
|
namespace :test do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
fork {
|
33
|
-
ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
|
34
|
-
`bundle install`
|
35
|
-
out = `bundle exec rake test:ghostbuster 2>&1`
|
36
|
-
unless matcher.all?{|m|out[m]}
|
37
|
-
puts out
|
38
|
-
exit(1)
|
39
|
-
end
|
40
|
-
raise("There are a weird number of screenshots") unless Dir['*.png'].to_a.size == 12
|
41
|
-
exit
|
42
|
-
}
|
43
|
-
_, status = Process.wait2
|
44
|
-
puts status.success? ? "PASSED" : "FAILED"
|
6
|
+
[:working_via_bin, :working_via_rake].each do |task_name|
|
7
|
+
desc "Run test for `working' test suite (via binary)"
|
8
|
+
task task_name do
|
9
|
+
print "#{task_name} ... "
|
10
|
+
Dir.chdir("test/working_ghost") do
|
11
|
+
matcher = [/10 success, 0 failure, 1 pending/]
|
12
|
+
fork {
|
13
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
|
14
|
+
`bundle install`
|
15
|
+
out = case task_name
|
16
|
+
when :working_via_rake then `bundle exec rake test:ghostbuster 2>&1`
|
17
|
+
when :working_via_bin then `bundle exec ghostbuster . 2>&1`
|
18
|
+
end
|
19
|
+
begin
|
20
|
+
matcher.each{|m| out[m] or raise("Couldn't match for #{m.inspect}")}
|
21
|
+
raise("There are a weird number of screenshots") unless Dir['*.png'].to_a.size == 14
|
22
|
+
exit
|
23
|
+
rescue
|
24
|
+
puts $!.message
|
25
|
+
puts out
|
26
|
+
exit(1)
|
27
|
+
end
|
28
|
+
}
|
29
|
+
_, status = Process.wait2
|
30
|
+
puts status.success? ? "PASSED" : "FAILED"
|
31
|
+
end
|
45
32
|
end
|
46
33
|
end
|
47
34
|
|
@@ -49,7 +36,7 @@ namespace :test do
|
|
49
36
|
task :non_working do
|
50
37
|
print "non_working_ghost ... "
|
51
38
|
Dir.chdir("test/non_working_ghost") do
|
52
|
-
matcher = [/0 success,
|
39
|
+
matcher = [/0 success, 6 failure, 1 pending/, /Bad link traversal\s+Assert location failed: Excepted http:\/\/127\.0\.0\.1:4567\/not-correct, got http:\/\/127\.0\.0\.1:4567\//, /Form input not equal\s+Assert first for selector #out did not meet expectations/, /This test will explode!\s+I hate you!/, /This test has no succeed\s+This test took too long/]
|
53
40
|
fork {
|
54
41
|
ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
|
55
42
|
`bundle install`
|
data/lib/ghostbuster.coffee
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Test
|
2
|
-
constructor: (@runner, @name, @testBody) ->
|
2
|
+
constructor: (@runner, @name, @maxDuration, @testBody) ->
|
3
3
|
@page = new WebPage()
|
4
4
|
if @runner.useScreenshots()
|
5
5
|
@page.viewportSize = @runner.viewportDimensions()
|
@@ -42,7 +42,7 @@ class Test
|
|
42
42
|
@testTimer ||= setTimeout (->
|
43
43
|
test.setLastError("This test took too long")
|
44
44
|
test.fail()
|
45
|
-
),
|
45
|
+
), @maxDuration
|
46
46
|
runWithFunction: (fn, @callback) ->
|
47
47
|
fn.call(this)
|
48
48
|
get: (path, opts, getCallback) ->
|
@@ -52,7 +52,7 @@ class Test
|
|
52
52
|
@waitForAssertions ->
|
53
53
|
test = this
|
54
54
|
fatalCallback = ->
|
55
|
-
test.fail("The request for #{
|
55
|
+
test.fail("The request for #{test.runner.normalizePath(path)} failed")
|
56
56
|
fatal = setTimeout fatalCallback, if opts.total then opts.total * 1000 else 1000
|
57
57
|
loadedCallback = (status) ->
|
58
58
|
clearTimeout fatal
|
@@ -262,10 +262,14 @@ class TestFile
|
|
262
262
|
addPending: (name, body) -> @tests.push new PendingTest(this, name)
|
263
263
|
before: (body) -> @befores.push(body)
|
264
264
|
after: (body) -> @afters.push(body)
|
265
|
-
add: (name, body) ->
|
265
|
+
add: (name, opts, body) ->
|
266
|
+
unless body?
|
267
|
+
body = opts
|
268
|
+
opts = {}
|
266
269
|
for test in @tests
|
267
270
|
throw("Identically named test already exists for name #{name} in #{@name}") if test.name == name
|
268
|
-
|
271
|
+
maxDuration = (opts.total || 5) * 1000
|
272
|
+
@tests.push new Test(this, name, maxDuration, body)
|
269
273
|
run: (callback, idx) ->
|
270
274
|
throw "No root is defined" unless @root?
|
271
275
|
testFile = this
|
data/lib/ghostbuster/version.rb
CHANGED
@@ -7,3 +7,8 @@ phantom.test.add "This test will explode!", ->
|
|
7
7
|
phantom.test.add "This test has no succeed", ->
|
8
8
|
@get '/form', ->
|
9
9
|
"so, like, this test sucks"
|
10
|
+
|
11
|
+
phantom.test.add "This test sets its max test duration too low", total: 1, ->
|
12
|
+
@get '/form', ->
|
13
|
+
@wait 2, ->
|
14
|
+
@succeed()
|
data/test/server1/config.ru
CHANGED
data/test/server1/start.sh
CHANGED
data/test/working_ghost/start.sh
CHANGED
data/test/working_ghost/stop.sh
CHANGED
@@ -24,6 +24,11 @@ phantom.test.add "Slow form", ->
|
|
24
24
|
out.innerHTML == 'this is my input'
|
25
25
|
@succeed()
|
26
26
|
|
27
|
+
phantom.test.add "Simple form with specified max test duration", total: 2, ->
|
28
|
+
@get '/form', ->
|
29
|
+
@wait 1, ->
|
30
|
+
@succeed()
|
31
|
+
|
27
32
|
phantom.test.add "Before block var", ->
|
28
33
|
@get '/form', ->
|
29
34
|
@body.input "#in", @var
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghostbuster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Hull
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-02 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -108,16 +108,12 @@ files:
|
|
108
108
|
- lib/ghostbuster/version.rb
|
109
109
|
- test/non_working_ghost/Gemfile
|
110
110
|
- test/non_working_ghost/Ghostfile
|
111
|
-
- test/non_working_ghost/config.ru
|
112
111
|
- test/non_working_ghost/start.sh
|
113
112
|
- test/non_working_ghost/stop.sh
|
114
113
|
- test/non_working_ghost/test_ghost.coffee
|
115
114
|
- test/non_working_ghost/test_ghostmore.coffee
|
116
115
|
- test/non_working_ghost/test_withoutroot.js
|
117
|
-
- test/
|
118
|
-
- test/non_working_ghost/views/index.erb
|
119
|
-
- test/non_working_ghost/views/slow.erb
|
120
|
-
- test/output
|
116
|
+
- test/server1/Gemfile
|
121
117
|
- test/server1/config.ru
|
122
118
|
- test/server1/start.sh
|
123
119
|
- test/server1/stop.sh
|
@@ -127,15 +123,11 @@ files:
|
|
127
123
|
- test/working_ghost/Gemfile
|
128
124
|
- test/working_ghost/Ghostfile
|
129
125
|
- test/working_ghost/Rakefile
|
130
|
-
- test/working_ghost/config.ru
|
131
126
|
- test/working_ghost/start.sh
|
132
127
|
- test/working_ghost/stop.sh
|
133
128
|
- test/working_ghost/test_ghost.coffee
|
134
129
|
- test/working_ghost/test_ghostmore.coffee
|
135
130
|
- test/working_ghost/test_injs.js
|
136
|
-
- test/working_ghost/views/form.erb
|
137
|
-
- test/working_ghost/views/index.erb
|
138
|
-
- test/working_ghost/views/slow.erb
|
139
131
|
has_rdoc: true
|
140
132
|
homepage: https://github.com/joshbuddy/ghostbuster
|
141
133
|
licenses: []
|
@@ -173,16 +165,12 @@ summary: Integration testing ftw
|
|
173
165
|
test_files:
|
174
166
|
- test/non_working_ghost/Gemfile
|
175
167
|
- test/non_working_ghost/Ghostfile
|
176
|
-
- test/non_working_ghost/config.ru
|
177
168
|
- test/non_working_ghost/start.sh
|
178
169
|
- test/non_working_ghost/stop.sh
|
179
170
|
- test/non_working_ghost/test_ghost.coffee
|
180
171
|
- test/non_working_ghost/test_ghostmore.coffee
|
181
172
|
- test/non_working_ghost/test_withoutroot.js
|
182
|
-
- test/
|
183
|
-
- test/non_working_ghost/views/index.erb
|
184
|
-
- test/non_working_ghost/views/slow.erb
|
185
|
-
- test/output
|
173
|
+
- test/server1/Gemfile
|
186
174
|
- test/server1/config.ru
|
187
175
|
- test/server1/start.sh
|
188
176
|
- test/server1/stop.sh
|
@@ -192,12 +180,8 @@ test_files:
|
|
192
180
|
- test/working_ghost/Gemfile
|
193
181
|
- test/working_ghost/Ghostfile
|
194
182
|
- test/working_ghost/Rakefile
|
195
|
-
- test/working_ghost/config.ru
|
196
183
|
- test/working_ghost/start.sh
|
197
184
|
- test/working_ghost/stop.sh
|
198
185
|
- test/working_ghost/test_ghost.coffee
|
199
186
|
- test/working_ghost/test_ghostmore.coffee
|
200
187
|
- test/working_ghost/test_injs.js
|
201
|
-
- test/working_ghost/views/form.erb
|
202
|
-
- test/working_ghost/views/index.erb
|
203
|
-
- test/working_ghost/views/slow.erb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'sinatra'
|
3
|
-
|
4
|
-
class App < Sinatra::Base
|
5
|
-
get "/" do
|
6
|
-
erb :index
|
7
|
-
end
|
8
|
-
|
9
|
-
get "/form" do
|
10
|
-
erb :form
|
11
|
-
end
|
12
|
-
|
13
|
-
get "/slow" do
|
14
|
-
erb :slow
|
15
|
-
end
|
16
|
-
|
17
|
-
get "/slow-index" do
|
18
|
-
sleep 2
|
19
|
-
erb :index
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
run App
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>This is my index</title>
|
4
|
-
</head>
|
5
|
-
<body>
|
6
|
-
<form>
|
7
|
-
<input type="text" id="in">
|
8
|
-
<input type="button" id="btn" onclick="document.getElementById('out').innerHTML = document.getElementById('in').value;">
|
9
|
-
</form>
|
10
|
-
<p id="out"></p>
|
11
|
-
</body>
|
12
|
-
</html>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>This is my index</title>
|
4
|
-
</head>
|
5
|
-
<body>
|
6
|
-
<h1>First header</h1>
|
7
|
-
<p>This is my paragraph</p>
|
8
|
-
<ul>
|
9
|
-
<li>List item 1</li>
|
10
|
-
<li>List item 2</li>
|
11
|
-
<li>List item 3</li>
|
12
|
-
</ul>
|
13
|
-
<a href="/form">form</a>
|
14
|
-
</body>
|
15
|
-
</html>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>This is my index</title>
|
4
|
-
</head>
|
5
|
-
<body>
|
6
|
-
<form>
|
7
|
-
<input type="text" id="in">
|
8
|
-
<input type="button" id="btn" onclick="setTimeout( function() { document.getElementById('out').innerHTML = document.getElementById('in').value;}, 2000);">
|
9
|
-
</form>
|
10
|
-
<p id="out"></p>
|
11
|
-
</body>
|
12
|
-
</html>
|
data/test/output
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
(in /Users/joshbuddy/Development/ghostbuster)
|
2
|
-
Starting server
|
3
|
-
GhostBuster
|
4
|
-
For [1mtest_ghost.coffee[0m
|
5
|
-
[32m✓[0m Simple index
|
6
|
-
[32m✓[0m Simple slow index
|
7
|
-
[32m✓[0m Form input
|
8
|
-
[32m✓[0m Link traversal
|
9
|
-
[31m✗[0m Bad link traversal
|
10
|
-
Assert location failed: Excepted http://127.0.0.1:4567/not-correct, got http://127.0.0.1:4567/
|
11
|
-
[31m✗[0m Form input not equal
|
12
|
-
Assert first for selector #out did not meet expectations
|
13
|
-
|
14
|
-
For [1mtest_ghostmore.coffee[0m
|
15
|
-
[32m✓[0m Simple form
|
16
|
-
[33m◐[0m Form should do more things
|
17
|
-
[32m✓[0m Simple form with wait
|
18
|
-
[32m✓[0m Slow form
|
19
|
-
[32m✓[0m Before block var
|
20
|
-
[31m✗[0m This test will explode!
|
21
|
-
I hate you!
|
22
|
-
[31m✗[0m This test has no succeed
|
23
|
-
This test took too long
|
24
|
-
|
25
|
-
For [1mtest_injs.js[0m
|
26
|
-
[32m✓[0m Test for 3 li's
|
27
|
-
|
28
|
-
For [1mtest_withoutroot.js[0m
|
29
|
-
[31m✗[0m No root is defined
|
30
|
-
9 success, 5 failure, 1 pending
|
31
|
-
Stopping server
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'sinatra'
|
3
|
-
|
4
|
-
class App < Sinatra::Base
|
5
|
-
get "/" do
|
6
|
-
erb :index
|
7
|
-
end
|
8
|
-
|
9
|
-
get "/form" do
|
10
|
-
erb :form
|
11
|
-
end
|
12
|
-
|
13
|
-
get "/slow" do
|
14
|
-
erb :slow
|
15
|
-
end
|
16
|
-
|
17
|
-
get "/slow-index" do
|
18
|
-
sleep 2
|
19
|
-
erb :index
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
run App
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>This is my index</title>
|
4
|
-
</head>
|
5
|
-
<body>
|
6
|
-
<form>
|
7
|
-
<input type="text" id="in">
|
8
|
-
<input type="button" id="btn" onclick="document.getElementById('out').innerHTML = document.getElementById('in').value;">
|
9
|
-
</form>
|
10
|
-
<p id="out"></p>
|
11
|
-
</body>
|
12
|
-
</html>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>This is my index</title>
|
4
|
-
</head>
|
5
|
-
<body>
|
6
|
-
<h1>First header</h1>
|
7
|
-
<p>This is my paragraph</p>
|
8
|
-
<ul>
|
9
|
-
<li>List item 1</li>
|
10
|
-
<li>List item 2</li>
|
11
|
-
<li>List item 3</li>
|
12
|
-
</ul>
|
13
|
-
<a href="/form">form</a>
|
14
|
-
</body>
|
15
|
-
</html>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>This is my index</title>
|
4
|
-
</head>
|
5
|
-
<body>
|
6
|
-
<form>
|
7
|
-
<input type="text" id="in">
|
8
|
-
<input type="button" id="btn" onclick="setTimeout( function() { document.getElementById('out').innerHTML = document.getElementById('in').value;}, 2000);">
|
9
|
-
</form>
|
10
|
-
<p id="out"></p>
|
11
|
-
</body>
|
12
|
-
</html>
|