Only clear the sessions if block_given? and no error

Because otherwise capybara-screenshot/rspec can't
take the screenshots for us. If we got an error,
we don't want to continue anyway?
This commit is contained in:
Lin Jen-Shin 2018-06-13 20:20:36 +08:00
parent 031ee142b1
commit 11a19e64ec
1 changed files with 1 additions and 13 deletions

View File

@ -102,19 +102,7 @@ module QA
def perform(&block)
visit(url)
yield if block_given?
rescue
raise if block.nil?
# RSpec examples will take care of screenshots on their own
#
unless block.binding.receiver.is_a?(RSpec::Core::ExampleGroup)
screenshot_and_save_page
end
raise
ensure
clear! if block_given?
yield.tap { clear! } if block_given?
end
##