Sha256: e445966d0d3b93cc1087355c1d9e1339f5792ba5c987cc29503a252834c9a3ba

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 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 |_expected|
      match do |actual|
        original_timeout = Watir.default_timeout
        Watir.default_timeout = 0
        begin
          actual.call
          false
        rescue exception
          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

1 entries across 1 versions & 1 rubygems

Version Path
watir-6.1.0 spec/watirspec/support/raise_exception_matchers.rb