Sha256: 074625d557590206389a00ef75c790333deb683387a5b28bddb94d8f09aa1bbe

Contents?: true

Size: 1.8 KB

Versions: 71

Compression:

Stored size: 1.8 KB

Contents

module RSpec
  module Wait
    class Target < RSpec::Expectations::ExpectationTarget
      # From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L22
      UndefinedValue = Module.new

      # From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L30-L41
      def self.for(value, block, options = {})
        if UndefinedValue.equal?(value)
          unless block
            raise ArgumentError, "You must pass either an argument or a block to `wait_for`."
          end
          new(block, options)
        elsif block
          raise ArgumentError, "You cannot pass both an argument and a block to `wait_for`."
        else
          new(value, options)
        end
      end

      # From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L25-L27
      def initialize(target, options)
        @wait_options = options
        super(target)
      end

      # From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L53-L54
      def to(matcher = nil, message = nil, &block)
        prevent_operator_matchers(:to, matcher) unless matcher
        with_wait { PositiveHandler.handle_matcher(@target, matcher, message, &block) }
      end

      # From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L66-L67
      def not_to(matcher = nil, message = nil, &block)
        prevent_operator_matchers(:not_to, matcher) unless matcher
        with_wait { NegativeHandler.handle_matcher(@target, matcher, message, &block) }
      end

      alias_method :to_not, :not_to

      private

      def with_wait
        Wait.with_wait(@wait_options) { yield }
      end
    end
  end
end

Version data entries

71 entries across 66 versions & 18 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/rspec-wait-0.0.9/lib/rspec/wait/target.rb