Class: RBeautifyMatchers::BeBlockEndLike

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-beautify/spec/spec_helper.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(block_start, offset, match, after_match) ⇒ BeBlockEndLike

Returns a new instance of BeBlockEndLike.



49
50
51
52
53
54
55
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 49

def initialize(block_start, offset, match, after_match)
  # triggers the standard Spec::Matchers::Be magic, as if the original Spec::Matchers#method_missing had fired
  @block_start = block_start
  @offset = offset
  @match = match
  @after_match = after_match
end

Instance Method Details

#descriptionObject



82
83
84
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 82

def description
  "block end with"
end

#expected_stringObject



70
71
72
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 70

def expected_string
  "block_end: #{@block_start.name}, offset: #{@offset}, match: '#{@match}', after_match: '#{@after_match}'"
end

#failure_messageObject



62
63
64
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 62

def failure_message
  "expected\n#{expected_string} but got\n#{got_string}"
end

#got_stringObject



74
75
76
77
78
79
80
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 74

def got_string
  if @target_block.nil?
    'nil'
  else
    "block_end: #{@target_block.block_start.name}, offset: #{@target_block.offset}, match: '#{@target_block.match}', after_match: '#{@target_block.after_match}'"
  end
end

#matches?(target_block) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
60
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 57

def matches?(target_block)
  @target_block = target_block
  expected_string == got_string
end

#negative_failure_messageObject



66
67
68
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 66

def negative_failure_message
  "expected to be different from #{expected_string}"
end