Sha256: 3ad79815a405bba918b5f96577d16c70d3231742579b377a61584d7c55bb687c

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

require 'test/unit/assertions'
require 'hardmock/errors'

module Hardmock
  class Trapper #:nodoc:
    include Hardmock::MethodCleanout

    def initialize(mock,mock_control,expectation_builder)
      @mock = mock
      @mock_control = mock_control
      @expectation_builder = expectation_builder
    end

    def method_missing(mname, *args)
      if block_given?
        raise ExpectationError.new("Don't pass blocks when using 'trap' (setting exepectations for '#{mname}')")
      end
      
      the_block = lambda { |target_block| target_block }
      expectation = @expectation_builder.build_expectation(
        :mock => @mock, 
        :method => mname, 
        :arguments => args, 
        :suppress_arguments_to_block => true,
        :block => the_block)

      @mock_control.add_expectation expectation
      expectation
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ceedling-0.29.1 vendor/hardmock/lib/hardmock/trapper.rb
ceedling-0.29.0 vendor/hardmock/lib/hardmock/trapper.rb