Class: Cucumber::Formatter::IOHTTPBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/formatter/http_io.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, method, headers = {}, https_verify_mode = nil, reporter = nil) ⇒ IOHTTPBuffer

Returns a new instance of IOHTTPBuffer.



70
71
72
73
74
75
76
77
# File 'lib/cucumber/formatter/http_io.rb', line 70

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

#headersObject (readonly)

Returns the value of attribute headers.



68
69
70
# File 'lib/cucumber/formatter/http_io.rb', line 68

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method.



68
69
70
# File 'lib/cucumber/formatter/http_io.rb', line 68

def method
  @method
end

#uriObject (readonly)

Returns the value of attribute uri.



68
69
70
# File 'lib/cucumber/formatter/http_io.rb', line 68

def uri
  @uri
end

Instance Method Details

#closeObject

Raises:

  • (StandardError)


79
80
81
82
83
84
85
86
# File 'lib/cucumber/formatter/http_io.rb', line 79

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

Returns:

  • (Boolean)


96
97
98
# File 'lib/cucumber/formatter/http_io.rb', line 96

def closed?
  @write_io.closed?
end

#flushObject



92
93
94
# File 'lib/cucumber/formatter/http_io.rb', line 92

def flush
  @write_io.flush
end

#write(data) ⇒ Object



88
89
90
# File 'lib/cucumber/formatter/http_io.rb', line 88

def write(data)
  @write_io.write(data)
end