Exception: RSpec::Httpd::ExpectationFailed

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/rspec/httpd/expectation_failed.rb

Overview

rubocop:disable Metrics/AbcSize

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_error, response:) ⇒ ExpectationFailed

Returns a new instance of ExpectationFailed.



6
7
8
# File 'lib/rspec/httpd/expectation_failed.rb', line 6

def initialize(original_error, response:)
  @original_error, @response = original_error, response
end

Instance Attribute Details

#original_errorObject (readonly)

Returns the value of attribute original_error.



4
5
6
# File 'lib/rspec/httpd/expectation_failed.rb', line 4

def original_error
  @original_error
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/rspec/httpd/expectation_failed.rb', line 4

def response
  @response
end

Instance Method Details

#requestObject



10
11
12
# File 'lib/rspec/httpd/expectation_failed.rb', line 10

def request
  response.request
end

#to_sObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/rspec/httpd/expectation_failed.rb', line 14

def to_s
  parts = []
  parts.push(original_error.to_s)
  parts.push("=== #{request} =====================")
  parts.push("> " + request.body.gsub("\n", "\n> ")) if request.body
  parts.push("--- response ------------------------------------")
  parts.push("< " + response.body.gsub("\n", "\n< ")) if response.body
  parts.push("==================================================================")
  parts.join("\n")
end