Sha256: 17bddda4c0f43be05640e906ccd618ce4d0e96c593df84e861d23af6b993c523

Contents?: true

Size: 1.22 KB

Versions: 31

Compression:

Stored size: 1.22 KB

Contents

if defined?(RSpec)
  TIMING_EXCEPTIONS = {
    raise_unknown_object_exception: Watir::Exception::UnknownObjectException,
    raise_no_matching_window_exception: Watir::Exception::NoMatchingWindowFoundException,
    raise_unknown_frame_exception: Watir::Exception::UnknownFrameException,
    raise_object_disabled_exception: Watir::Exception::ObjectDisabledException,
    raise_object_read_only_exception: Watir::Exception::ObjectReadOnlyException,
    raise_no_value_found_exception: Watir::Exception::NoValueFoundException
  }.freeze

  TIMING_EXCEPTIONS.each do |matcher, exception|
    RSpec::Matchers.define matcher do |message|
      match do |actual|
        original_timeout = Watir.default_timeout
        Watir.default_timeout = 0
        begin
          actual.call
          false
        rescue exception => ex
          raise exception, "expected '#{message}' to be included in: '#{ex.message}'" unless message.nil? || ex.message.include?(message)
          true
        ensure
          Watir.default_timeout = original_timeout
        end
      end

      failure_message do |_actual|
        "expected #{exception} but nothing was raised"
      end

      def supports_block_expectations?
        true
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
watir-6.11.0 spec/watirspec/support/raise_exception_matchers.rb
watir-6.11.0.beta2 spec/watirspec/support/raise_exception_matchers.rb
watir-6.11.0.beta1 spec/watirspec/support/raise_exception_matchers.rb
watir-6.10.3 spec/watirspec/support/raise_exception_matchers.rb
watir-6.10.2 spec/watirspec/support/raise_exception_matchers.rb
watir-6.10.0 spec/watirspec/support/raise_exception_matchers.rb
watir-6.9.1 spec/watirspec/support/raise_exception_matchers.rb
watir-6.9.0 spec/watirspec/support/raise_exception_matchers.rb
watir-6.8.4 spec/watirspec/support/raise_exception_matchers.rb
watir-6.8.3 spec/watirspec/support/raise_exception_matchers.rb
watir-6.8.2 spec/watirspec/support/raise_exception_matchers.rb
watir-6.8.1 spec/watirspec/support/raise_exception_matchers.rb
watir-6.8.0 spec/watirspec/support/raise_exception_matchers.rb
watir-6.7.3 spec/watirspec/support/raise_exception_matchers.rb
watir-6.7.2 spec/watirspec/support/raise_exception_matchers.rb
watir-6.7.1 spec/watirspec/support/raise_exception_matchers.rb
watir-6.7.0 spec/watirspec/support/raise_exception_matchers.rb
watir-6.6.3 spec/watirspec/support/raise_exception_matchers.rb
watir-6.6.2 spec/watirspec/support/raise_exception_matchers.rb
watir-6.6.1 spec/watirspec/support/raise_exception_matchers.rb