Sha256: 04552faa21df6213ae355ac1517692349c14381b28809618e25d5d820c228290

Contents?: true

Size: 877 Bytes

Versions: 9

Compression:

Stored size: 877 Bytes

Contents

module RR
  class DoubleDefinitionBuilder #:nodoc:
    attr_reader :definition

    def initialize(definition, args, handler)
      @definition = definition
      @args = args
      @handler = handler
    end
    
    def mock!
      @definition.with(*@args).once
    end

    def stub!
      @definition.any_number_of_times
      permissive_argument!
    end

    def dont_allow!
      @definition.never
      permissive_argument!
      reimplementation!
    end

    def permissive_argument!
      if @args.empty?
        @definition.with_any_args
      else
        @definition.with(*@args)
      end
    end

    def reimplementation!
      @definition.returns(&@handler)
    end
    
    def proxy!
      @definition.after_call_block_callback_strategy!
      @definition.implemented_by_original_method
      @definition.after_call(&@handler) if @handler
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rr-0.4.7 lib/rr/double_definition_builder.rb
rr-0.4.2 lib/rr/double_definition_builder.rb
rr-0.4.4 lib/rr/double_definition_builder.rb
rr-0.4.8 lib/rr/double_definition_builder.rb
rr-0.4.5 lib/rr/double_definition_builder.rb
rr-0.4.3 lib/rr/double_definition_builder.rb
rr-0.4.0 lib/rr/double_definition_builder.rb
rr-0.4.6 lib/rr/double_definition_builder.rb
rr-0.4.1 lib/rr/double_definition_builder.rb