Sha256: e557d973422f5332f42cfcd54b809bb55bc3bfeb45799fff9930e6b9ab623a37

Contents?: true

Size: 763 Bytes

Versions: 4

Compression:

Stored size: 763 Bytes

Contents

module Shoulda # :nodoc:
  module Matchers
    module Independent # :nodoc:
      class DelegateMatcher::StubbedTarget # :nodoc:
        def initialize(method)
          @received_method = false
          @received_arguments = []
          stub_method(method)
        end

        def has_received_method?
          received_method
        end

        def has_received_arguments?(*args)
          args == received_arguments
        end

        private

        def stub_method(method)
          class_eval do
            define_method method do |*args|
              @received_method = true
              @received_arguments = args
            end
          end
        end

        attr_reader :received_method, :received_arguments
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shoulda-matchers-2.6.1 lib/shoulda/matchers/independent/delegate_matcher/stubbed_target.rb
shoulda-matchers-2.6.1.rc2 lib/shoulda/matchers/independent/delegate_matcher/stubbed_target.rb
shoulda-matchers-2.6.1.rc1 lib/shoulda/matchers/independent/delegate_matcher/stubbed_target.rb
shoulda-matchers-2.6.0 lib/shoulda/matchers/independent/delegate_matcher/stubbed_target.rb