Permalink
Browse files

clean up tests

  • Loading branch information...
1 parent 2b8f2d9 commit 71344554aee7f1ffe26cf2a57f554b577a95d6d0 @joshbuddy committed Sep 2, 2011
View
@@ -3,4 +3,4 @@
Gemfile.lock
pkg/*
*.png
-this.log
+test/server1/log
View
@@ -3,53 +3,40 @@ require 'bundler/gem_tasks'
STDOUT.sync = true
namespace :test do
- desc "Run test for `working' test suite (via binary)"
- task :working_via_bin do
- print "working_ghost via bin ... "
- Dir.chdir("test/working_ghost") do
- matcher = [/9 success, 0 failure, 1 pending/]
- fork {
- ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
- `bundle install`
- out = `bundle exec ghostbuster . 2>&1`
- unless matcher.all?{|m|out[m]}
- puts out
- exit(1)
- end
- raise("There are a weird number of screenshots") unless Dir['*.png'].to_a.size == 12
- exit
- }
- _, status = Process.wait2
- puts status.success? ? "PASSED" : "FAILED"
- end
- end
-
- desc "Run test for `working' test suite (via rake)"
- task :working_via_rake do
- print "working_ghost via rake ... "
- Dir.chdir("test/working_ghost") do
- matcher = [/9 success, 0 failure, 1 pending/]
- fork {
- ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
- `bundle install`
- out = `bundle exec rake test:ghostbuster 2>&1`
- unless matcher.all?{|m|out[m]}
- puts out
- exit(1)
- end
- raise("There are a weird number of screenshots") unless Dir['*.png'].to_a.size == 12
- exit
- }
- _, status = Process.wait2
- puts status.success? ? "PASSED" : "FAILED"
+ [:working_via_bin, :working_via_rake].each do |task_name|
+ desc "Run test for `working' test suite (via binary)"
+ task task_name do
+ print "#{task_name} ... "
+ Dir.chdir("test/working_ghost") do
+ matcher = [/10 success, 0 failure, 1 pending/]
+ fork {
+ ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
+ `bundle install`
+ out = case task_name
+ when :working_via_rake then `bundle exec rake test:ghostbuster 2>&1`
+ when :working_via_bin then `bundle exec ghostbuster . 2>&1`
+ end
+ begin
+ matcher.each{|m| out[m] or raise("Couldn't match for #{m.inspect}")}
+ raise("There are a weird number of screenshots") unless Dir['*.png'].to_a.size == 13
+ exit
+ rescue
+ puts $!.message
+ puts out
+ exit(1)
+ end
+ }
+ _, status = Process.wait2
+ puts status.success? ? "PASSED" : "FAILED"
+ end
end
end
desc "Run test for `non_working' test suite"
task :non_working do
print "non_working_ghost ... "
Dir.chdir("test/non_working_ghost") do
- 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/]
+ matcher = [/0 success, 5 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/]
fork {
ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
`bundle install`
@@ -52,7 +52,7 @@ class Test
@waitForAssertions ->
test = this
fatalCallback = ->
- test.fail("The request for #{@runner.normalizePath(path)} failed")
+ test.fail("The request for #{test.runner.normalizePath(path)} failed")
fatal = setTimeout fatalCallback, if opts.total then opts.total * 1000 else 1000
loadedCallback = (status) ->
clearTimeout fatal
@@ -1,4 +1,4 @@
ghost.pattern = "test_*.{coffee,js}"
-ghost.take_screenshots! # or do_not_takescreenshots! defaults to true
+ghost.do_not_take_screenshots! # or do_not_takescreenshots! defaults to true
ghost.screenshot_dir = '.'
ghost.screenshot_dimensions 800, 2000
@@ -1,23 +0,0 @@
-require 'rubygems'
-require 'sinatra'
-
-class App < Sinatra::Base
- get "/" do
- erb :index
- end
-
- get "/form" do
- erb :form
- end
-
- get "/slow" do
- erb :slow
- end
-
- get "/slow-index" do
- sleep 2
- erb :index
- end
-end
-
-run App
@@ -1,3 +1,4 @@
#!/bin/bash
-bundle exec thin --port 4567 -P thin.pid -d -R config.ru start
+cd ../server1
+./start.sh
@@ -1,3 +1,4 @@
#!/bin/bash
-bundle exec thin --port 4567 -P thin.pid -d -R config.ru stop
+cd ../server1
+./stop.sh
@@ -13,3 +13,8 @@ phantom.test.add "Form input not equal", ->
@body.assertFirst '#out', (out) ->
out.innerHTML == 'this is NOT my input'
@succeed()
+
+phantom.test.addPending "To a non existent page", ->
+ @get '/404', ->
+ @succeed()
+
@@ -1,12 +0,0 @@
-<html>
-<head>
- <title>This is my index</title>
-</head>
-<body>
- <form>
- <input type="text" id="in">
- <input type="button" id="btn" onclick="document.getElementById('out').innerHTML = document.getElementById('in').value;">
- </form>
- <p id="out"></p>
-</body>
-</html>
@@ -1,15 +0,0 @@
-<html>
-<head>
- <title>This is my index</title>
-</head>
-<body>
- <h1>First header</h1>
- <p>This is my paragraph</p>
- <ul>
- <li>List item 1</li>
- <li>List item 2</li>
- <li>List item 3</li>
- </ul>
- <a href="/form">form</a>
-</body>
-</html>
@@ -1,12 +0,0 @@
-<html>
-<head>
- <title>This is my index</title>
-</head>
-<body>
- <form>
- <input type="text" id="in">
- <input type="button" id="btn" onclick="setTimeout( function() { document.getElementById('out').innerHTML = document.getElementById('in').value;}, 2000);">
- </form>
- <p id="out"></p>
-</body>
-</html>
View
@@ -1,31 +0,0 @@
-(in /Users/joshbuddy/Development/ghostbuster)
-Starting server
-GhostBuster
-For test_ghost.coffee
- ✓ Simple index
- ✓ Simple slow index
- ✓ Form input
- ✓ Link traversal
- ✗ Bad link traversal
- Assert location failed: Excepted http://127.0.0.1:4567/not-correct, got http://127.0.0.1:4567/
- ✗ Form input not equal
- Assert first for selector #out did not meet expectations
-
-For test_ghostmore.coffee
- ✓ Simple form
- ◐ Form should do more things
- ✓ Simple form with wait
- ✓ Slow form
- ✓ Before block var
- ✗ This test will explode!
- I hate you!
- ✗ This test has no succeed
- This test took too long
-
-For test_injs.js
- ✓ Test for 3 li's
-
-For test_withoutroot.js
- ✗ No root is defined
-9 success, 5 failure, 1 pending
-Stopping server
@@ -0,0 +1,6 @@
+source :rubygems
+
+gem 'ghostbuster', :path => '../..'
+gem 'thin'
+gem 'sinatra'
+gem 'rake'
@@ -18,6 +18,11 @@ class App < Sinatra::Base
sleep 2
erb :index
end
+
+ get "/very-slow-index" do
+ sleep 7
+ erb :index
+ end
end
run App
@@ -1,3 +1,3 @@
#!/bin/bash
-bundle exec thin --port 4567 -P thin.pid -d -R config.ru start
+bundle exec thin --port 4567 -P thin.pid -d -R ./config.ru start
@@ -1,23 +0,0 @@
-require 'rubygems'
-require 'sinatra'
-
-class App < Sinatra::Base
- get "/" do
- erb :index
- end
-
- get "/form" do
- erb :form
- end
-
- get "/slow" do
- erb :slow
- end
-
- get "/slow-index" do
- sleep 2
- erb :index
- end
-end
-
-run App
@@ -1,3 +1,4 @@
#!/bin/bash
-source ../server1/start.sh
+cd ../server1
+./start.sh
@@ -1,3 +1,4 @@
#!/bin/bash
-source ../server1/stop.sh
+cd ../server1
+./stop.sh
@@ -27,3 +27,4 @@ phantom.test.add "Link traversal", ->
@body.click 'a'
@body.assertLocation('/form')
@succeed()
+
@@ -1,12 +0,0 @@
-<html>
-<head>
- <title>This is my index</title>
-</head>
-<body>
- <form>
- <input type="text" id="in">
- <input type="button" id="btn" onclick="document.getElementById('out').innerHTML = document.getElementById('in').value;">
- </form>
- <p id="out"></p>
-</body>
-</html>
@@ -1,15 +0,0 @@
-<html>
-<head>
- <title>This is my index</title>
-</head>
-<body>
- <h1>First header</h1>
- <p>This is my paragraph</p>
- <ul>
- <li>List item 1</li>
- <li>List item 2</li>
- <li>List item 3</li>
- </ul>
- <a href="/form">form</a>
-</body>
-</html>
@@ -1,12 +0,0 @@
-<html>
-<head>
- <title>This is my index</title>
-</head>
-<body>
- <form>
- <input type="text" id="in">
- <input type="button" id="btn" onclick="setTimeout( function() { document.getElementById('out').innerHTML = document.getElementById('in').value;}, 2000);">
- </form>
- <p id="out"></p>
-</body>
-</html>

0 comments on commit 7134455

Please sign in to comment.