Exception: Rapid::NotMatchingTemplateError

Inherits:
TemplateError show all
Defined in:
lib/rapid/error.rb,
lib/rapid/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, expected_content, content, options = {}) ⇒ NotMatchingTemplateError

Returns a new instance of NotMatchingTemplateError.



52
53
54
55
# File 'lib/rapid/error.rb', line 52

def initialize result, expected_content, content, options = {}
  @result, @expected_content, @content = result, expected_content, content
  @previous_content = options[:previous]
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



50
51
52
# File 'lib/rapid/error.rb', line 50

def content
  @content
end

#expected_contentObject (readonly)

Returns the value of attribute expected_content.



50
51
52
# File 'lib/rapid/error.rb', line 50

def expected_content
  @expected_content
end

#previous_contentObject (readonly)

Returns the value of attribute previous_content.



50
51
52
# File 'lib/rapid/error.rb', line 50

def previous_content
  @previous_content
end

#resultObject (readonly)

Returns the value of attribute result.



50
51
52
# File 'lib/rapid/error.rb', line 50

def result
  @result
end

Instance Method Details

#messageObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/rapid/error.rb', line 57

def message
  messages = [
    "after:    #{previous_content.nil? ? "nil" : previous_content[0..100].inspect}",
    "expected: #{expected_content[0..100].inspect}",
    "received: #{content[0..100].inspect}",
    "current:  #{result.inspect}"
  ]
  
  messages.join("\n")
end