lib/watir/after_hooks.rb in watir-6.13.0 vs lib/watir/after_hooks.rb in watir-6.14.0

- old
+ new

@@ -1,7 +1,6 @@ module Watir - # # After hooks are blocks that run after certain browser events. # They are generally used to ensure application under test does not encounter # any error and are automatically executed after following events: # 1. Open URL. @@ -23,11 +22,11 @@ # # @example # browser.after_hooks.add do |browser| # browser.text.include?("Server Error") and puts "Application exception or 500 error!" # end - # browser.goto "watir.github.io/404" + # browser.goto "watir.com/404" # "Application exception or 500 error!" # # @param [#call] after_hook Object responding to call # @yield after_hook block # @yieldparam [Watir::Browser] @@ -37,23 +36,23 @@ if block_given? @after_hooks << block elsif after_hook.respond_to? :call @after_hooks << after_hook else - raise ArgumentError, "expected block or object responding to #call" + raise ArgumentError, 'expected block or object responding to #call' end end - alias_method :<<, :add + alias << add # # Deletes after hook. # # @example # browser.after_hooks.add do |browser| # browser.text.include?("Server Error") and puts "Application exception or 500 error!" # end - # browser.goto "watir.github.io/404" + # browser.goto "watir.com/404" # "Application exception or 500 error!" # browser.after_hooks.delete browser.after_hooks[0] # browser.refresh # @@ -64,13 +63,13 @@ # # Runs after hooks. # def run - if @after_hooks.any? && @browser.window.present? && !@browser.alert.exists? - each { |after_hook| after_hook.call(@browser) } - end + return unless @after_hooks.any? && @browser.window.present? && !@browser.alert.exists? + + each { |after_hook| after_hook.call(@browser) } end # # Executes a block without running error after hooks. # @@ -113,11 +112,11 @@ # def length @after_hooks.length end - alias_method :size, :length + alias size length # # Gets the after hook at the given index. # # @param [Integer] index @@ -125,8 +124,7 @@ # def [](index) @after_hooks[index] end - end # AfterHooks end # Watir