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 CHANGED
@@ -3,4 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  *.png
6
- this.log
6
+ test/server1/log
data/Rakefile CHANGED
@@ -3,45 +3,32 @@ require 'bundler/gem_tasks'
3
3
  STDOUT.sync = true
4
4
 
5
5
  namespace :test do
6
- desc "Run test for `working' test suite (via binary)"
7
- task :working_via_bin do
8
- print "working_ghost via bin ... "
9
- Dir.chdir("test/working_ghost") do
10
- matcher = [/9 success, 0 failure, 1 pending/]
11
- fork {
12
- ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
13
- `bundle install`
14
- out = `bundle exec ghostbuster . 2>&1`
15
- unless matcher.all?{|m|out[m]}
16
- puts out
17
- exit(1)
18
- end
19
- raise("There are a weird number of screenshots") unless Dir['*.png'].to_a.size == 12
20
- exit
21
- }
22
- _, status = Process.wait2
23
- puts status.success? ? "PASSED" : "FAILED"
24
- end
25
- end
26
-
27
- desc "Run test for `working' test suite (via rake)"
28
- task :working_via_rake do
29
- print "working_ghost via rake ... "
30
- Dir.chdir("test/working_ghost") do
31
- matcher = [/9 success, 0 failure, 1 pending/]
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, 5 failure, 0 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/]
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`
@@ -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
- ), 5000
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 #{@runner.normalizePath(path)} failed")
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
- @tests.push new Test(this, name, body)
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
@@ -1,3 +1,3 @@
1
1
  class Ghostbuster
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -1,4 +1,4 @@
1
1
  ghost.pattern = "test_*.{coffee,js}"
2
- ghost.take_screenshots! # or do_not_takescreenshots! defaults to true
2
+ ghost.do_not_take_screenshots! # or do_not_takescreenshots! defaults to true
3
3
  ghost.screenshot_dir = '.'
4
4
  ghost.screenshot_dimensions 800, 2000
@@ -1,3 +1,4 @@
1
1
  #!/bin/bash
2
2
 
3
- bundle exec thin --port 4567 -P thin.pid -d -R config.ru start
3
+ cd ../server1
4
+ ./start.sh
@@ -1,3 +1,4 @@
1
1
  #!/bin/bash
2
2
 
3
- bundle exec thin --port 4567 -P thin.pid -d -R config.ru stop
3
+ cd ../server1
4
+ ./stop.sh
@@ -13,3 +13,8 @@ phantom.test.add "Form input not equal", ->
13
13
  @body.assertFirst '#out', (out) ->
14
14
  out.innerHTML == 'this is NOT my input'
15
15
  @succeed()
16
+
17
+ phantom.test.addPending "To a non existent page", ->
18
+ @get '/404', ->
19
+ @succeed()
20
+
@@ -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()
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem 'ghostbuster', :path => '../..'
4
+ gem 'thin'
5
+ gem 'sinatra'
6
+ gem 'rake'
@@ -18,6 +18,11 @@ class App < Sinatra::Base
18
18
  sleep 2
19
19
  erb :index
20
20
  end
21
+
22
+ get "/very-slow-index" do
23
+ sleep 7
24
+ erb :index
25
+ end
21
26
  end
22
27
 
23
28
  run App
@@ -1,3 +1,3 @@
1
1
  #!/bin/bash
2
2
 
3
- bundle exec thin --port 4567 -P thin.pid -d -R config.ru start
3
+ bundle exec thin --port 4567 -P thin.pid -d -R ./config.ru start
@@ -1,3 +1,4 @@
1
1
  #!/bin/bash
2
2
 
3
- source ../server1/start.sh
3
+ cd ../server1
4
+ ./start.sh
@@ -1,3 +1,4 @@
1
1
  #!/bin/bash
2
2
 
3
- source ../server1/stop.sh
3
+ cd ../server1
4
+ ./stop.sh
@@ -27,3 +27,4 @@ phantom.test.add "Link traversal", ->
27
27
  @body.click 'a'
28
28
  @body.assertLocation('/form')
29
29
  @succeed()
30
+
@@ -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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
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-01 00:00:00 -05:00
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/non_working_ghost/views/form.erb
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/non_working_ghost/views/form.erb
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 test_ghost.coffee
5
- ✓ Simple index
6
- ✓ Simple slow index
7
- ✓ Form input
8
- ✓ Link traversal
9
- ✗ Bad link traversal
10
- Assert location failed: Excepted http://127.0.0.1:4567/not-correct, got http://127.0.0.1:4567/
11
- ✗ Form input not equal
12
- Assert first for selector #out did not meet expectations
13
-
14
- For test_ghostmore.coffee
15
- ✓ Simple form
16
- ◐ Form should do more things
17
- ✓ Simple form with wait
18
- ✓ Slow form
19
- ✓ Before block var
20
- ✗ This test will explode!
21
- I hate you!
22
- ✗ This test has no succeed
23
- This test took too long
24
-
25
- For test_injs.js
26
- ✓ Test for 3 li's
27
-
28
- For test_withoutroot.js
29
- ✗ 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>