HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-2.5.9/spec/mspec/lib/mspec/matchers/have_instance_method.rb
require 'mspec/matchers/method'

class HaveInstanceMethodMatcher < MethodMatcher
  def matches?(mod)
    @mod = mod
    mod.instance_methods(@include_super).include? @method
  end

  def failure_message
    ["Expected #{@mod} to have instance method '#{@method.to_s}'",
     "but it does not"]
  end

  def negative_failure_message
    ["Expected #{@mod} NOT to have instance method '#{@method.to_s}'",
     "but it does"]
  end
end

module MSpecMatchers
  private def have_instance_method(method, include_super=true)
    HaveInstanceMethodMatcher.new method, include_super
  end
end