Commit 353eafdd9270e5d2722fe0a59d8b4bf3910ce7de
Committed by
Paulo Meireles
1 parent
19445616
Exists in
master
and in
29 other branches
Refactoring Kalibro::Client::Port
service_address as instance variable
Showing
2 changed files
with
8 additions
and
14 deletions
Show diff stats
plugins/mezuro/lib/kalibro/client/port.rb
| @@ -2,18 +2,12 @@ require 'savon' | @@ -2,18 +2,12 @@ require 'savon' | ||
| 2 | 2 | ||
| 3 | class Kalibro::Client::Port | 3 | class Kalibro::Client::Port |
| 4 | 4 | ||
| 5 | - @@service_address = 'http://localhost:8080/KalibroService/' | ||
| 6 | - | ||
| 7 | - def self.service_address | ||
| 8 | - @@service_address | ||
| 9 | - end | ||
| 10 | - | ||
| 11 | - def self.service_address=(service_address) | ||
| 12 | - @@service_address = service_address | 5 | + def initialize(endpoint) |
| 6 | + @client = Savon::Client.new("#{service_address}#{endpoint}Endpoint/?wsdl") | ||
| 13 | end | 7 | end |
| 14 | 8 | ||
| 15 | - def initialize(endpoint) | ||
| 16 | - @client = Savon::Client.new("#{@@service_address}#{endpoint}Endpoint/?wsdl") | 9 | + def service_address |
| 10 | + @service_address ||= 'http://localhost:8080/KalibroService/' | ||
| 17 | end | 11 | end |
| 18 | 12 | ||
| 19 | def request(action, request_body = nil) | 13 | def request(action, request_body = nil) |
plugins/mezuro/test/unit/kalibro/client/port_test.rb
| 1 | class PortTest < Test::Unit::TestCase | 1 | class PortTest < Test::Unit::TestCase |
| 2 | 2 | ||
| 3 | def setup | 3 | def setup |
| 4 | - @service_address = Kalibro::Client::Port.service_address | 4 | + @default_address = 'http://localhost:8080/KalibroService/' |
| 5 | @client = mock | 5 | @client = mock |
| 6 | - Savon::Client.expects(:new).with("#{@service_address}PortTestEndpoint/?wsdl").returns(@client) | 6 | + Savon::Client.expects(:new).with("#{@default_address}PortTestEndpoint/?wsdl").returns(@client) |
| 7 | @port = Kalibro::Client::Port.new('PortTest') | 7 | @port = Kalibro::Client::Port.new('PortTest') |
| 8 | end | 8 | end |
| 9 | 9 | ||
| 10 | - should 'default address be localhost' do | ||
| 11 | - assert_equal 'http://localhost:8080/KalibroService/', @service_address | 10 | + should 'get default address' do |
| 11 | + assert_equal @default_address, @port.service_address | ||
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | should 'request action and return response' do | 14 | should 'request action and return response' do |