Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
spec/runner: catch timeouts in the specs
  • Loading branch information
meh committed Jan 30, 2014
1 parent 1249105 commit 9c4f61e
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions spec/runner.rb
Expand Up @@ -82,33 +82,37 @@

print "\rRunning specs..."

# wait until the specs have finished, thus changing the content of #totals
Selenium::WebDriver::Wait.new(timeout: 1200, interval: 30).until {
print '.'
begin
# wait until the specs have finished, thus changing the content of #totals
Selenium::WebDriver::Wait.new(timeout: 1200, interval: 30).until {
print '.'

not browser['totals'].text.strip.empty?
}
not browser['totals'].text.strip.empty?
}

totals = browser['totals'].text
duration = browser[css: '#duration strong'].text
totals = browser['totals'].text
duration = browser[css: '#duration strong'].text

print "\r#{totals} in #{duration}"
print "\r#{totals} in #{duration}"

# take a screenshot and upload it to imgur
begin
browser.save_screenshot('screenshot.png')
response = RestClient.post('https://api.imgur.com/3/upload',
{ image: File.open('screenshot.png') },
{ 'Authorization' => 'Client-ID 1979876fe2a097e' })

print " ("
print JSON.parse(response.to_str)['data']['link']
puts ")"
rescue Exception
puts
end

# no failures, happy times
unless totals =~ / 0 failures/
exit 1
# no failures, happy times
unless totals =~ / 0 failures/
exit 1
end
rescue Selenium::WebDriver::Error::TimeOutError
print "\rThe specs have timed out."
ensure
# take a screenshot and upload it to imgur
begin
browser.save_screenshot('screenshot.png')
response = RestClient.post('https://api.imgur.com/3/upload',
{ image: File.open('screenshot.png') },
{ 'Authorization' => 'Client-ID 1979876fe2a097e' })

print " ("
print JSON.parse(response.to_str)['data']['link']
puts ")"
rescue Exception
puts
end
end

0 comments on commit 9c4f61e

Please sign in to comment.