Sha256: baaf7e5cadb7738f500236eaed12eabbe6ae5616c496cd3ba53d5105b792b59b

Contents?: true

Size: 954 Bytes

Versions: 2

Compression:

Stored size: 954 Bytes

Contents

require 'bundler/setup'
require 'cuukie'

def start_process(command)
  Process.detach fork { exec command }
end

def run_cucumber(feature = '')
  system "cd spec/test_project &&
          cucumber features/#{feature} --format cuukie"
end

require 'rest-client'

[:GET, :POST, :PUT, :DELETE].each do |method|
  Kernel.send :define_method, method do |*args|
    args[0] = "http://localhost:4569#{args[0]}"
    RestClient.send method.to_s.downcase, *args
  end
end

def html
  GET('/').body
end

def start_server
  start_process "ruby bin/cuukie --server >/dev/null 2>&1"
  wait_for_server_on_port 4569
end

def ping_on_port(port)
  RestClient.get "http://localhost:#{port}/ping"
end

def wait_for_server_on_port(port)
  loop do
    begin
      ping_on_port port
      return
    rescue; end
  end
end

def stop_server_on_port(port)
  # the server dies without replying, so we expect an error here
  RestClient.delete "http://localhost:#{port}/"
rescue
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cuukie-0.2.1 spec/spec_helper.rb
cuukie-0.2.0 spec/spec_helper.rb