Skip to content

Instantly share code, notes, and snippets.

@charger
Created October 2, 2018 12:06
Show Gist options
  • Save charger/8d1f47a75cec2a6cc93789c05f399965 to your computer and use it in GitHub Desktop.
Save charger/8d1f47a75cec2a6cc93789c05f399965 to your computer and use it in GitHub Desktop.
#/spec/support/the_service.rb
#ensure that after all specs TheService will be stopped
RSpec.configure do |config|
config.after :suite do
TheServiceControl.stop
end
end
class TheServiceControl
class << self
@pid = nil
@config = nil
def config
puts "Please create file: #{config_path}" unless File.exist?(config_path)
@config = YAML.load_file(config_path)
end
def host
TheServiceControl.config['server']['addr']
end
def config_path
Rails.root.join('spec', 'support', 'the_service_config.yml')
end
def start
# will be described below
end
def stop
# will be described below
end
def post(params, headers)
HTTParty.post("http://#{host}/request", body: params, headers: headers )
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment