1
0
Fork 0
mirror of https://github.com/twbs/bootstrap-sass.git synced 2022-11-09 12:27:02 -05:00
twbs--bootstrap-sass/test/support/integration_test.rb
2013-09-10 18:01:56 +02:00

29 lines
No EOL
728 B
Ruby

require 'capybara'
module IntegrationTest
include Capybara::DSL
def setup
super
%x[rm -rf test/dummy/tmp/cache]
end
def teardown
super
Capybara.reset_sessions!
Capybara.use_default_driver
end
def after_teardown
if @passed.blank?
screenshot!
puts "Failed at: #{current_url}"
end
end
def screenshot!
screenshot_dir = File.expand_path('../../tmp/', File.dirname(__FILE__))
page.driver.render(File.join(screenshot_dir, "#{@__name__}.png"), :full => true)
source = page.evaluate_script("document.getElementsByTagName('html')[0].outerHTML") rescue nil
File.open(File.join(screenshot_dir, "#{@__name__}.html"), 'w') { |f| f.write(source) } if source
end
end