Class: HttpStub::Configurer::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/configurer/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Command

Returns a new instance of Command.



6
7
8
9
10
11
12
# File 'lib/http_stub/configurer/command.rb', line 6

def initialize(options)
  @host = options[:host]
  @port = options[:port]
  @request = options[:request]
  @description = options[:description]
  @resetable_flag = !!options[:resetable]
end

Instance Method Details

#execute ⇒ Object



14
15
16
17
# File 'lib/http_stub/configurer/command.rb', line 14

def execute
  response = Net::HTTP.start(@host, @port) { |http| http.request(@request) }
  raise "Error occurred #{@description}: #{response.message}" unless response.code == "200"
end

#resetable? ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/http_stub/configurer/command.rb', line 19

def resetable?
  @resetable_flag
end