Class: Surrogate::RSpec::AbstractFailureMessage::ArgsInspector

Inherits:
Object
  • Object
show all
Defined in:
lib/surrogate/rspec/abstract_failure_message.rb

Class Method Summary collapse

Class Method Details

.inspect(invocation) ⇒ Object



5
6
7
8
9
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 5

def self.inspect(invocation)
  inspected_arguments = invocation.args.map { |argument| inspect_argument argument }
  inspected_arguments << 'no args' if inspected_arguments.empty?
  "`" << inspected_arguments.join(", ") << "'"
end

.inspect_argument(to_inspect) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 11

def self.inspect_argument(to_inspect)
  if RSpec.rspec_mocks_loaded? && to_inspect.respond_to?(:description)
    to_inspect.description
  else
    to_inspect.inspect
  end
end