Sha256: 35c42fc1b607f047b41f31c67644a1fb8a8826074acbae16a7131aa58257431c

Contents?: true

Size: 827 Bytes

Versions: 19

Compression:

Stored size: 827 Bytes

Contents

module Shoulda
  module Matchers
    module Independent
      class DelegateMethodMatcher
        # @private
        class StubbedTarget
          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

          protected

          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
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
shoulda-matchers-4.3.0 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-4.2.0 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-4.1.2 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-4.1.1 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-4.1.0 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-4.0.1 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-3.1.3 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-4.0.0.rc1 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-3.1.2 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-3.1.1 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-3.1.0 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-3.0.1 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-3.0.0 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-3.0.0.rc1 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-2.8.0 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-2.8.0.rc2 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-2.8.0.rc1 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
shoulda-matchers-2.7.0 lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb