Class: RSpec::Fire::ShouldProxy

Inherits:
SimpleDelegator
  • Object
show all
Includes:
RecursiveConstMethods
Defined in:
lib/rspec/fire.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.



136
137
138
139
140
141
142
# File 'lib/rspec/fire.rb', line 136

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



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/rspec/fire.rb', line 144

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