Class: RSpec::Fire::ShouldProxy

Inherits:
SimpleDelegator
  • Object
show all
Includes:
RecursiveConstMethods
Defined in:
lib/rspec/fire/legacy.rb

Constant Summary collapse

AM =
RSpec::Mocks::ArgumentMatchers

Instance Method Summary collapse

Methods included from RecursiveConstMethods

#const_defined_on?, #get_const_defined_on, #recursive_const_defined?, #recursive_const_get

Constructor Details

#initialize(double, method_finder, backing) ⇒ ShouldProxy

Returns a new instance of ShouldProxy.



117
118
119
120
121
122
123
# File 'lib/rspec/fire/legacy.rb', line 117

def initialize(double, method_finder, backing)
  @double             = double
  @method_finder      = method_finder
  @backing            = backing
  @sym = backing.respond_to?(:sym) ? @backing.sym : @backing.message
  super(backing)
end

Instance Method Details

#with(*args, &block) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/rspec/fire/legacy.rb', line 125

def with(*args, &block)
  unless AM::AnyArgsMatcher === args.first
    expected_arity = if AM::NoArgsMatcher === args.first
      0
    elsif args.length > 0
      args.length
    elsif block
      block.arity
    else
      raise ArgumentError.new("No arguments nor block given.")
    end
    ensure_arity(expected_arity)
  end
  __getobj__.with(*args, &block)
end