You can get rejected after the hook using your usual statements. Did not do much with Capybara / rspec exceptions, but I think you can do:
page.should have_selector?(:dialog_message, 1, :text => 'Error')
However, if you do this or run the .fail! () Script, you still will not be logged out. You need to wrap it in a start-guarantee block.
Try the following:
After do |scenario| begin page.should have_selector?(:dialog_message, 1, :text => 'Error') ensure logout end end
Update
If you do not want to invoke standard statements and directly fail, you can do the following: you need to use fail instead of fail! :
After() do |scenario| begin
Justin ko
source share