-
Notifications
You must be signed in to change notification settings - Fork 17
/
Rakefile
61 lines (57 loc) · 2.58 KB
/
Rakefile
1
2
3
4
5
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require 'bundler/gem_tasks'
STDOUT.sync = true
namespace :test do
[:working_via_bin, :working_via_rake].each do |task_name|
desc "Run test for `working' test suite (#{task_name})"
task task_name do
print "#{task_name} ... "
Dir.chdir("test/working_ghost") do
matcher = [/14 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}")}
real_size = Dir['*.png'].to_a.size
expected_size = 23
raise("There are a weird number of screenshots, expected #{expected_size}, got #{real_size}") unless expected_size == real_size
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, 10 failure, 1 pending/m, %r|Bad link traversal\s+Assert location failed: Expected http://127.0.0.1:4567/not-correct, got http://127.0.0.1:4567/|im, /Form input not equal\s+Assert first for selector #out did not meet expectations/m, /To an invalid URL\s+The request for http:\/\/127\.0\.0\.1:this-url-is-invalid failed/m, /This test will explode!\s+I hate you!/m, /This test has no succeed\s+This test took too long/m, /This test has a custom assertion name\s+Assert first "custom assertion name" did not meet expectations/m, /Bad click selector\s+Couldn't find element 0 for selector i-just-made-this-up/m, /Bad click follow\s+Assert not location failed: Expected not http:\/\/127\.0\.0\.1:4567\/, got http:\/\/127\.0\.0\.1:4567\//m]
fork {
ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
`bundle install`
out = `bundle exec ghostbuster . 2>&1`
begin
matcher.each{|m| out[m] or raise("Couldn't match for #{m.inspect}")}
exit
rescue
puts $!.message
puts out
exit(1)
end
}
_, status = Process.wait2
puts status.success? ? "PASSED" : "FAILED"
end
end
end
task :test => [:'test:working_via_bin', :'test:working_via_rake', :'test:non_working']