test_lib/broker_config.rb in message-driver-0.1.0 vs test_lib/broker_config.rb in message-driver-0.2.0.rc1
- old
+ new
@@ -1,25 +1,55 @@
-module BrokerConfig
- def self.config
- adapter_file = File.expand_path("../../.adapter_under_test", __FILE__)
- adapter = ENV['ADAPTER'] || (File.exist?(adapter_file) && File.read(adapter_file).chomp)
- case adapter
- when 'bunny'
- {
- adapter: :bunny,
- vhost: 'message-driver-test'
- }
- when 'in_memory'
- {adapter: :in_memory}
- else
- {adapter: :in_memory}
+class BrokerConfig
+ class << self
+ def config
+ adapter_file = File.expand_path("../../.adapter_under_test", __FILE__)
+ @adapter, @version = (ENV['ADAPTER'] || (File.exist?(adapter_file) && File.read(adapter_file).chomp)).split(":")
+ case @adapter
+ when 'bunny'
+ {
+ adapter: :bunny,
+ vhost: 'message-driver-test'
+ }
+ when 'in_memory'
+ {adapter: :in_memory}
+ when 'stomp'
+ {
+ adapter: :stomp,
+ vhost: 'message-driver-test',
+ hosts: [{host: 'localhost', login: 'guest', passcode: 'guest'}],
+ reliable: false,
+ max_reconnect_attempts: 1
+ }
+ else
+ {adapter: :in_memory}
+ end
end
- end
- def self.current_adapter
- config[:adapter]
- end
+ def all_adapters
+ %w(in_memory bunny stomp)
+ end
- def self.unconfigured_adapters
- %w(bunny in_memory) - current_adapter
+ def current_adapter
+ config[:adapter]
+ end
+
+ def adapter_version
+ config unless @version
+ @version
+ end
+
+ def unconfigured_adapters
+ all_adapters - [current_adapter]
+ end
+
+ def current_adapter_port
+ case current_adapter
+ when :bunny
+ 5672
+ when :stomp
+ 61613
+ else
+ nil
+ end
+ end
end
end