module RSpec::Mocks::TestDoubleFormatter

@private

Constants

IVAR_GET

@private

Public Class Methods

format(dbl, unwrap=false) click to toggle source
# File lib/rspec/mocks/test_double.rb, line 138
def self.format(dbl, unwrap=false)
  format = "#{type_desc(dbl)}#{verified_module_desc(dbl)} #{name_desc(dbl)}"
  return format if unwrap
  "#<#{format}>"
end

Private Class Methods

name_desc(dbl) click to toggle source
# File lib/rspec/mocks/test_double.rb, line 164
def name_desc(dbl)
  return "(anonymous)" unless (name = IVAR_GET.bind(dbl).call(:@name))
  name.inspect
end
type_desc(dbl) click to toggle source
# File lib/rspec/mocks/test_double.rb, line 147
def type_desc(dbl)
  case dbl
  when InstanceVerifyingDouble then "InstanceDouble"
  when ClassVerifyingDouble    then "ClassDouble"
  when ObjectVerifyingDouble   then "ObjectDouble"
  else "Double"
  end
end
verified_module_desc(dbl) click to toggle source
# File lib/rspec/mocks/test_double.rb, line 159
def verified_module_desc(dbl)
  return nil unless VerifyingDouble === dbl
  "(#{IVAR_GET.bind(dbl).call(:@doubled_module).description})"
end