Class: FakeSQS::TestIntegration

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_sqs/test_integration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TestIntegration

Returns a new instance of TestIntegration.



8
9
10
# File 'lib/fake_sqs/test_integration.rb', line 8

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/fake_sqs/test_integration.rb', line 6

def options
  @options
end

Instance Method Details

#expireObject



45
46
47
# File 'lib/fake_sqs/test_integration.rb', line 45

def expire
  connection.put("/", "")
end

#hostObject



12
13
14
# File 'lib/fake_sqs/test_integration.rb', line 12

def host
  option :sqs_endpoint
end

#portObject



16
17
18
# File 'lib/fake_sqs/test_integration.rb', line 16

def port
  option :sqs_port
end

#resetObject



41
42
43
# File 'lib/fake_sqs/test_integration.rb', line 41

def reset
  connection.delete("/")
end

#startObject



20
21
22
23
# File 'lib/fake_sqs/test_integration.rb', line 20

def start
  start! unless up?
  reset
end

#start!Object



25
26
27
28
29
# File 'lib/fake_sqs/test_integration.rb', line 25

def start!
  args = [ binfile, "-p", port.to_s, verbose, logging, "--database", database, { :out => out, :err => out } ].flatten.compact
  @pid = Process.spawn(*args)
  wait_until_up
end

#stopObject



31
32
33
34
35
36
37
38
39
# File 'lib/fake_sqs/test_integration.rb', line 31

def stop
  if @pid
    Process.kill("INT", @pid)
    Process.waitpid(@pid)
    @pid = nil
  else
    $stderr.puts "FakeSQS is not running"
  end
end

#up?Boolean

Returns:

  • (Boolean)


57
58
59
60
61
# File 'lib/fake_sqs/test_integration.rb', line 57

def up?
  @pid && connection.get("/").code.to_s == "200"
rescue Errno::ECONNREFUSED
  false
end

#uriObject



53
54
55
# File 'lib/fake_sqs/test_integration.rb', line 53

def uri
  URI(url)
end

#urlObject



49
50
51
# File 'lib/fake_sqs/test_integration.rb', line 49

def url
  "http://#{host}:#{port}"
end