class Telegram::Bot::RSpec::ArgListMatcher

Proxy that uses RSpec::Mocks::ArgListMatcher when it's available. Otherwise just performs `#==` match.

Also allows to check argumets with custom block.

Attributes

expected[R]
expected_proc[R]

Public Class Methods

new(*args, &block) click to toggle source
# File lib/telegram/bot/rspec/client_matchers.rb, line 11
def initialize(*args, &block)
  @expected_proc = block if block_given?
  @expected =
    if mocks_matcher?
      ::RSpec::Mocks::ArgumentListMatcher.new(*args)
    else
      args
    end
end

Public Instance Methods

args() click to toggle source
# File lib/telegram/bot/rspec/client_matchers.rb, line 32
def args
  mocks_matcher? ? expected.args : expected
end
args_match?(*actual) click to toggle source
# File lib/telegram/bot/rspec/client_matchers.rb, line 21
def args_match?(*actual)
  if expected_proc
    expected_proc[*actual]
    true
  elsif mocks_matcher?
    expected.args_match?(*actual)
  else
    expected == actual
  end
end
mocks_matcher?() click to toggle source
# File lib/telegram/bot/rspec/client_matchers.rb, line 36
def mocks_matcher?
  defined?(::RSpec::Mocks::ArgumentListMatcher)
end
to_s() click to toggle source
# File lib/telegram/bot/rspec/client_matchers.rb, line 40
def to_s
  if mocks_matcher?
    expected.expected_args.inspect
  elsif expected_proc
    '(proc matcher)'
  else
    expected.inspect
  end
end