Class: FakeSNS::TestIntegration
- Inherits:
-
Object
- Object
- FakeSNS::TestIntegration
- Defined in:
- lib/fake_sns/test_integration.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #connection ⇒ Object
- #data ⇒ Object
- #drain(message_id = nil, options = {}) ⇒ Object
- #host ⇒ Object
-
#initialize(options = {}) ⇒ TestIntegration
constructor
A new instance of TestIntegration.
- #port ⇒ Object
- #reset ⇒ Object
- #start ⇒ Object
- #start! ⇒ Object
- #stop ⇒ Object
- #up? ⇒ Boolean
- #url ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TestIntegration
Returns a new instance of TestIntegration.
8 9 10 |
# File 'lib/fake_sns/test_integration.rb', line 8 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/fake_sns/test_integration.rb', line 6 def @options end |
Instance Method Details
#connection ⇒ Object
70 71 72 |
# File 'lib/fake_sns/test_integration.rb', line 70 def connection @connection ||= Faraday.new(url) end |
#data ⇒ Object
54 55 56 |
# File 'lib/fake_sns/test_integration.rb', line 54 def data YAML.load(connection.get("/").body) end |
#drain(message_id = nil, options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fake_sns/test_integration.rb', line 58 def drain( = nil, = {}) path = ? "/drain/#{}" : "/drain" default = { aws_config: AWS.config.send(:supplied) } body = default.merge().to_json result = connection.post(path, body) if result.success? true else raise "Unable to drain messages: #{result.body}" end end |
#host ⇒ Object
12 13 14 |
# File 'lib/fake_sns/test_integration.rb', line 12 def host option :sns_endpoint end |
#port ⇒ Object
16 17 18 |
# File 'lib/fake_sns/test_integration.rb', line 16 def port option :sns_port end |
#reset ⇒ Object
40 41 42 |
# File 'lib/fake_sns/test_integration.rb', line 40 def reset connection.delete("/") end |
#start ⇒ Object
20 21 22 23 |
# File 'lib/fake_sns/test_integration.rb', line 20 def start start! unless up? reset end |
#start! ⇒ Object
25 26 27 28 |
# File 'lib/fake_sns/test_integration.rb', line 25 def start! @pid = Process.spawn(binfile, "-p", port.to_s, "--database", database, :out => out, :err => out) wait_until_up end |
#stop ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/fake_sns/test_integration.rb', line 30 def stop if @pid Process.kill("INT", @pid) Process.waitpid(@pid) @pid = nil else $stderr.puts "FakeSNS is not running" end end |
#up? ⇒ Boolean
48 49 50 51 52 |
# File 'lib/fake_sns/test_integration.rb', line 48 def up? @pid && connection.get("/").success? rescue Errno::ECONNREFUSED, Faraday::Error::ConnectionFailed false end |
#url ⇒ Object
44 45 46 |
# File 'lib/fake_sns/test_integration.rb', line 44 def url "http://#{host}:#{port}" end |