Class: RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/argument_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(*methods_to_respond_to) ⇒ DuckTypeMatcher

Returns a new instance of DuckTypeMatcher.



263
264
265
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/argument_matchers.rb', line 263

def initialize(*methods_to_respond_to)
  @methods_to_respond_to = methods_to_respond_to
end

Instance Method Details

#===(value) ⇒ Object



267
268
269
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/argument_matchers.rb', line 267

def ===(value)
  @methods_to_respond_to.all? { |message| value.respond_to?(message) }
end

#descriptionObject



271
272
273
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/argument_matchers.rb', line 271

def description
  "duck_type(#{@methods_to_respond_to.map(&:inspect).join(', ')})"
end