Class: Cucumber::Formatter::IOHTTPBuffer
- Inherits:
-
Object
- Object
- Cucumber::Formatter::IOHTTPBuffer
- Defined in:
- lib/cucumber/formatter/http_io.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #flush ⇒ Object
-
#initialize(uri, method, headers = {}, https_verify_mode = nil, reporter = nil) ⇒ IOHTTPBuffer
constructor
A new instance of IOHTTPBuffer.
- #write(data) ⇒ Object
Constructor Details
#initialize(uri, method, headers = {}, https_verify_mode = nil, reporter = nil) ⇒ IOHTTPBuffer
Returns a new instance of IOHTTPBuffer.
65 66 67 68 69 70 71 72 |
# File 'lib/cucumber/formatter/http_io.rb', line 65 def initialize(uri, method, headers = {}, https_verify_mode = nil, reporter = nil) @uri = URI(uri) @method = method @headers = headers @write_io = Tempfile.new('cucumber', encoding: 'UTF-8') @https_verify_mode = https_verify_mode @reporter = reporter || NoReporter.new end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
63 64 65 |
# File 'lib/cucumber/formatter/http_io.rb', line 63 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
63 64 65 |
# File 'lib/cucumber/formatter/http_io.rb', line 63 def method @method end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
63 64 65 |
# File 'lib/cucumber/formatter/http_io.rb', line 63 def uri @uri end |
Instance Method Details
#close ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/cucumber/formatter/http_io.rb', line 74 def close response = send_content(@uri, @method, @headers) @reporter.report(response.body) @write_io.close return if response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPRedirection) raise StandardError, "request to #{uri} failed with status #{response.code}" end |
#closed? ⇒ Boolean
90 91 92 |
# File 'lib/cucumber/formatter/http_io.rb', line 90 def closed? @write_io.closed? end |
#flush ⇒ Object
86 87 88 |
# File 'lib/cucumber/formatter/http_io.rb', line 86 def flush @write_io.flush end |
#write(data) ⇒ Object
82 83 84 |
# File 'lib/cucumber/formatter/http_io.rb', line 82 def write(data) @write_io.write(data) end |