class RSpec::Matchers::DelegateMatcher::Expected

Attributes

allow_nil[RW]
args[R]
as[RW]
check_return[RW]
method_name[RW]
return_value[RW]
subject[RW]
to[RW]

Public Class Methods

new() click to toggle source
# File lib/delegate_matcher/expected.rb, line 10
def initialize
  self.check_return = true
  # @args = [Mocks::ArgumentMatchers::NoArgsMatcher::INSTANCE]
end

Public Instance Methods

args=(args) click to toggle source
# File lib/delegate_matcher/expected.rb, line 33
def args=(args)
  @args_set ? @as_args = args : @args = args
  @args_set = true
end
as_args() click to toggle source
# File lib/delegate_matcher/expected.rb, line 38
def as_args
  @as_args || args
end
delegator_method_name() click to toggle source
# File lib/delegate_matcher/expected.rb, line 46
def delegator_method_name
  "#{prefix}#{method_name}"
end
description() click to toggle source
# File lib/delegate_matcher/expected.rb, line 50
def description
  "delegate #{delegator_description} to #{delegate_description}#{options_description}"
end
prefix() click to toggle source
# File lib/delegate_matcher/expected.rb, line 20
def prefix
  case
  when !@has_prefix
    ''
  when @prefix
    "#{@prefix}_"
  when to[0].is_a?(String) || to[0].is_a?(Symbol)
    to[0].to_s.delete('@').downcase + '_'
  else
    ''
  end
end
prefix=(prefix) click to toggle source
# File lib/delegate_matcher/expected.rb, line 15
def prefix=(prefix)
  @has_prefix = true
  @prefix     = prefix
end
to_description() click to toggle source
# File lib/delegate_matcher/expected.rb, line 54
def to_description
  to.join(',')
end

Private Instance Methods

argument_description(arguments = args) click to toggle source
# File lib/delegate_matcher/expected.rb, line 76
def argument_description(arguments = args)
  if arguments
    "(#{arguments.map { |a| a.respond_to?(:description) ? a.description : a.inspect }.join(', ')})"
  else
    ''
  end
end
block_description() click to toggle source
# File lib/delegate_matcher/expected.rb, line 99
def block_description
  case
  when block.nil?
    ''
  when block == true
    ' with a block'
  when block == false
    ' without a block'
  else
    " with block \"#{block_source}\""
  end
end
delegate_description() click to toggle source
# File lib/delegate_matcher/expected.rb, line 64
def delegate_description
  %("#{to_description}") +
    case
    when !args.eql?(as_args)
      ".#{as}#{argument_description(as_args)}"
    when as.to_s.eql?(delegator_method_name)
      ''
    else
      ".#{as}"
    end
end
delegator_description() click to toggle source
# File lib/delegate_matcher/expected.rb, line 60
def delegator_description
  "#{delegator_method_name}#{argument_description}"
end
nil_description() click to toggle source
# File lib/delegate_matcher/expected.rb, line 88
def nil_description
  case
  when allow_nil.nil?
    ''
  when allow_nil
    ' with nil allowed'
  else
    ' with nil not allowed'
  end
end
options_description() click to toggle source
# File lib/delegate_matcher/expected.rb, line 84
def options_description
  "#{nil_description}#{block_description}#{return_value_description}"
end
return_value_description() click to toggle source
# File lib/delegate_matcher/expected.rb, line 112
def return_value_description
  case
  when return_value
    " and return \"#{return_value}\""
  when !check_return
    ' without using delegate return value'
  else
    ''
  end
end