Skip to content

Commit

Permalink
Session should connect using the :port option
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Beck committed Mar 1, 2018
1 parent 7a139b3 commit b2c89d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/march_hare/session.rb
Expand Up @@ -402,7 +402,14 @@ def self.hostname_from(options)

# @private
def self.adresses_from(options)
options[:addresses] || options[:hosts] || [hostname_from(options)]
options[:addresses] || options[:hosts] || [address_with_port(options)]
end

# @private
def self.address_with_port(options)
address = hostname_from(options)
address = "#{address}:#{options[:port]}" if options[:port]
address
end

# @private
Expand Down
10 changes: 10 additions & 0 deletions spec/higher_level_api/integration/connection_spec.rb
Expand Up @@ -78,6 +78,16 @@
c.close
end

it "lets you specify host and port" do
expect {
MarchHare.connect(host: "127.0.0.1", port: 35672, network_recovery_interval: 0)
}.to raise_error(MarchHare::ConnectionRefused)

c = MarchHare.connect(host: "127.0.0.1", port: 5672, network_recovery_interval: 0)
expect(c).to be_connected
c.close
end

it "lets you specify multiple hosts" do
c = MarchHare.connect(hosts: ["127.0.0.1"], network_recovery_interval: 0)
expect(c).to be_connected
Expand Down

0 comments on commit b2c89d7

Please sign in to comment.