class RSpec::PowerAssert::DummyAssertionMatcher

Constants

INDENT_LEVEL

Public Class Methods

new(msg, method_name) click to toggle source
# File lib/rspec/power_assert.rb, line 86
def initialize(msg, method_name)
  @msg = msg
  @assertion_method = method_name
end

Public Instance Methods

description() click to toggle source
# File lib/rspec/power_assert.rb, line 91
def description
  if @msg =~ /^(\s*)#{@assertion_method}/
    output = @msg.sub(/^(\s*#{@assertion_method})/, "#{display_message}")
    offset = display_message.length - $1.length
  else
    output = @msg.sub(/^(\s*)(\S.*?)$/, "#{display_message} { \\2 }")
    offset = display_message.length + 3 - $1.length
  end

  "#{$/}#{build_message(output, offset)}"
end

Private Instance Methods

build_message(output, offset) click to toggle source
# File lib/rspec/power_assert.rb, line 105
def build_message(output, offset)
  if RSpec::PowerAssert.verbose_successful_report
    output.each_line.with_index.map do |l, idx|
      next l if idx == 0

      if offset > 1
        " " * offset + l
      else
        l.each_char.drop(offset.abs).join
      end
    end.join
  else
    output.each_line.first
  end
end
display_message() click to toggle source
# File lib/rspec/power_assert.rb, line 121
def display_message
  " " * INDENT_LEVEL + "be asserted by"
end