yield_star_client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.rvmrc +3 -0
- data/Gemfile +4 -0
- data/README.md +38 -0
- data/Rakefile +17 -0
- data/lib/yield_star_client/amenity_methods.rb +77 -0
- data/lib/yield_star_client/client.rb +84 -0
- data/lib/yield_star_client/errors.rb +52 -0
- data/lib/yield_star_client/floor_plan_methods.rb +78 -0
- data/lib/yield_star_client/lease_term_rent_methods.rb +185 -0
- data/lib/yield_star_client/property_methods.rb +138 -0
- data/lib/yield_star_client/rent_methods.rb +179 -0
- data/lib/yield_star_client/unit_methods.rb +95 -0
- data/lib/yield_star_client/validations.rb +18 -0
- data/lib/yield_star_client/version.rb +3 -0
- data/lib/yield_star_client.rb +74 -0
- data/spec/fixtures/faults/authentication_fault.xml +15 -0
- data/spec/fixtures/faults/generic_fault.xml +9 -0
- data/spec/fixtures/faults/internal_error_fault.xml +15 -0
- data/spec/fixtures/faults/operation_fault.xml +15 -0
- data/spec/fixtures/get_available_units/multiple_floor_plans.xml +53 -0
- data/spec/fixtures/get_available_units/no_floor_plans.xml +11 -0
- data/spec/fixtures/get_available_units/single_floor_plan.xml +28 -0
- data/spec/fixtures/get_floor_plan/full_floor_plan.xml +19 -0
- data/spec/fixtures/get_floor_plan/simple_floor_plan.xml +14 -0
- data/spec/fixtures/get_floor_plan_amenities/multiple_amenities.xml +19 -0
- data/spec/fixtures/get_floor_plan_amenities/no_amenities.xml +10 -0
- data/spec/fixtures/get_floor_plan_amenities/single_amenity.xml +15 -0
- data/spec/fixtures/get_floor_plans/multiple_floor_plans.xml +28 -0
- data/spec/fixtures/get_floor_plans/no_floor_plan.xml +10 -0
- data/spec/fixtures/get_floor_plans/single_floor_plan.xml +15 -0
- data/spec/fixtures/get_lease_term_rent/multiple_rates.xml +41 -0
- data/spec/fixtures/get_lease_term_rent/no_rates.xml +13 -0
- data/spec/fixtures/get_lease_term_rent/single_rate.xml +21 -0
- data/spec/fixtures/get_lease_term_rent_plus/multiple_rates.xml +43 -0
- data/spec/fixtures/get_lease_term_rent_plus/no_rates.xml +14 -0
- data/spec/fixtures/get_lease_term_rent_plus/single_rate.xml +22 -0
- data/spec/fixtures/get_properties/multiple_properties.xml +38 -0
- data/spec/fixtures/get_properties/no_property.xml +10 -0
- data/spec/fixtures/get_properties/single_property.xml +14 -0
- data/spec/fixtures/get_property/full_property.xml +25 -0
- data/spec/fixtures/get_property/simple_property.xml +14 -0
- data/spec/fixtures/get_property_parameters/full_parameters.xml +38 -0
- data/spec/fixtures/get_property_parameters/no_parameters.xml +10 -0
- data/spec/fixtures/get_property_parameters/simple_parameters.xml +14 -0
- data/spec/fixtures/get_renewal_lease_term_rent/multiple_rates.xml +28 -0
- data/spec/fixtures/get_renewal_lease_term_rent/no_rates.xml +10 -0
- data/spec/fixtures/get_renewal_lease_term_rent/single_rate.xml +21 -0
- data/spec/fixtures/get_rent_summary/multiple_summaries.xml +41 -0
- data/spec/fixtures/get_rent_summary/no_summaries.xml +11 -0
- data/spec/fixtures/get_rent_summary/single_summary.xml +24 -0
- data/spec/fixtures/get_unit/full_unit.xml +22 -0
- data/spec/fixtures/get_unit/simple_unit.xml +16 -0
- data/spec/fixtures/get_unit_amenities/multiple_amenities.xml +20 -0
- data/spec/fixtures/get_unit_amenities/no_amenities.xml +11 -0
- data/spec/fixtures/get_unit_amenities/single_amenity.xml +15 -0
- data/spec/fixtures/get_units/multiple_units.xml +32 -0
- data/spec/fixtures/get_units/no_units.xml +10 -0
- data/spec/fixtures/get_units/single_unit.xml +16 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/fault_handler_shared_examples.rb +68 -0
- data/spec/support/validator_shared_examples.rb +79 -0
- data/spec/yield_star_client/amenity_methods_spec.rb +165 -0
- data/spec/yield_star_client/client_spec.rb +150 -0
- data/spec/yield_star_client/errors_spec.rb +93 -0
- data/spec/yield_star_client/floor_plan_methods_spec.rb +126 -0
- data/spec/yield_star_client/lease_term_rent_methods_spec.rb +391 -0
- data/spec/yield_star_client/property_methods_spec.rb +189 -0
- data/spec/yield_star_client/rent_methods_spec.rb +271 -0
- data/spec/yield_star_client/unit_methods_spec.rb +168 -0
- data/spec/yield_star_client/validations_spec.rb +19 -0
- data/spec/yield_star_client_spec.rb +89 -0
- data/yield_star_client.gemspec +34 -0
- metadata +348 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<S:Body>
|
4
|
+
<getUnitResponse xmlns="http://yieldstar.com/ws/AppExchange/v1">
|
5
|
+
<return>
|
6
|
+
<externalPropertyId>42</externalPropertyId>
|
7
|
+
<unit>
|
8
|
+
<externalPropertyId>42</externalPropertyId>
|
9
|
+
<floorPlanName>Economy</floorPlanName>
|
10
|
+
<name>1A</name>
|
11
|
+
<availabilityStatus>Occupied on Notice</availabilityStatus>
|
12
|
+
</unit>
|
13
|
+
</return>
|
14
|
+
</getUnitResponse>
|
15
|
+
</S:Body>
|
16
|
+
</S:Envelope>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<S:Body>
|
4
|
+
<getUnitAmenitiesResponse xmlns="http://yieldstar.com/ws/AppExchange/v1">
|
5
|
+
<return>
|
6
|
+
<externalPropertyId>42</externalPropertyId>
|
7
|
+
<unitName>1A</unitName>
|
8
|
+
<amenity>
|
9
|
+
<name>Rent Adjustment</name>
|
10
|
+
<type>Fixed</type>
|
11
|
+
<value>50.00</value>
|
12
|
+
</amenity>
|
13
|
+
<amenity>
|
14
|
+
<name>Good Credit Adjustment</name>
|
15
|
+
<type>Variable</type>
|
16
|
+
</amenity>
|
17
|
+
</return>
|
18
|
+
</getUnitAmenitiesResponse>
|
19
|
+
</S:Body>
|
20
|
+
</S:Envelope>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<S:Body>
|
4
|
+
<getUnitAmenitiesResponse xmlns="http://yieldstar.com/ws/AppExchange/v1">
|
5
|
+
<return>
|
6
|
+
<externalPropertyId>42</externalPropertyId>
|
7
|
+
<unitName>1A</unitName>
|
8
|
+
</return>
|
9
|
+
</getUnitAmenitiesResponse>
|
10
|
+
</S:Body>
|
11
|
+
</S:Envelope>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" ?>
|
2
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<S:Body>
|
4
|
+
<getUnitAmenitiesResponse xmlns="http://yieldstar.com/ws/AppExchange/v1">
|
5
|
+
<return>
|
6
|
+
<externalPropertyId>42</externalPropertyId>
|
7
|
+
<unitName>1A</unitName>
|
8
|
+
<amenity>
|
9
|
+
<name>2nd Floor</name>
|
10
|
+
<type>Fixed</type>
|
11
|
+
</amenity>
|
12
|
+
</return>
|
13
|
+
</getUnitAmenitiesResponse>
|
14
|
+
</S:Body>
|
15
|
+
</S:Envelope>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<S:Body>
|
4
|
+
<getUnitsResponse xmlns="http://yieldstar.com/ws/AppExchange/v1">
|
5
|
+
<return>
|
6
|
+
<externalPropertyId>42</externalPropertyId>
|
7
|
+
<unit>
|
8
|
+
<externalPropertyId>42</externalPropertyId>
|
9
|
+
<floorPlanName>Economy</floorPlanName>
|
10
|
+
<name>Apt 313</name>
|
11
|
+
<bedRooms>2.0</bedRooms>
|
12
|
+
<bathRooms>1.1</bathRooms>
|
13
|
+
<squareFootage>1000</squareFootage>
|
14
|
+
<unitType>apartment</unitType>
|
15
|
+
<availabilityStatus>Pending</availabilityStatus>
|
16
|
+
</unit>
|
17
|
+
<unit>
|
18
|
+
<externalPropertyId>42</externalPropertyId>
|
19
|
+
<floorPlanName>Luxury</floorPlanName>
|
20
|
+
<name>The Villa</name>
|
21
|
+
<bedRooms>6.0</bedRooms>
|
22
|
+
<bathRooms>4.0</bathRooms>
|
23
|
+
<squareFootage>5000</squareFootage>
|
24
|
+
<unitType>single-family home</unitType>
|
25
|
+
<building>99</building>
|
26
|
+
<makeReadyDate>2011-04-01</makeReadyDate>
|
27
|
+
<availabilityStatus>Unknown</availabilityStatus>
|
28
|
+
</unit>
|
29
|
+
</return>
|
30
|
+
</getUnitsResponse>
|
31
|
+
</S:Body>
|
32
|
+
</S:Envelope>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<S:Body>
|
4
|
+
<getUnitsResponse xmlns="http://yieldstar.com/ws/AppExchange/v1">
|
5
|
+
<return>
|
6
|
+
<externalPropertyId>42</externalPropertyId>
|
7
|
+
</return>
|
8
|
+
</getUnitsResponse>
|
9
|
+
</S:Body>
|
10
|
+
</S:Envelope>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<S:Body>
|
4
|
+
<getUnitsResponse xmlns="http://yieldstar.com/ws/AppExchange/v1">
|
5
|
+
<return>
|
6
|
+
<externalPropertyId>42</externalPropertyId>
|
7
|
+
<unit>
|
8
|
+
<externalPropertyId>42</externalPropertyId>
|
9
|
+
<floorPlanName>FP99</floorPlanName>
|
10
|
+
<name>Unit 1</name>
|
11
|
+
<availabilityStatus>Occupied</availabilityStatus>
|
12
|
+
</unit>
|
13
|
+
</return>
|
14
|
+
</getUnitsResponse>
|
15
|
+
</S:Body>
|
16
|
+
</S:Envelope>
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require :default, :development
|
3
|
+
|
4
|
+
Dir[File.join(File.dirname(__FILE__), 'support', '*.rb')].each { |f| require f }
|
5
|
+
|
6
|
+
Savon::Spec::Fixture.path = File.expand_path("../fixtures", __FILE__)
|
7
|
+
Savon.configure do |config|
|
8
|
+
config.log = false
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include WebMock::API
|
13
|
+
config.include Savon::Spec::Macros
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'yield_star_client'
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for "a fault handler" do |soap_action|
|
4
|
+
context "when there is an authentication fault" do
|
5
|
+
before { savon.stubs(soap_action).raises_soap_fault.returns(Savon::Spec::Fixture[:faults, :authentication_fault]) }
|
6
|
+
|
7
|
+
it "should raise a YieldStarClient authentication error" do
|
8
|
+
expect { subject }.to raise_error(YieldStarClient::AuthenticationError)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should include the fault message in the error object" do
|
12
|
+
expect { subject }.to raise_error { |e| e.message.should == 'Client [foo] not found for this user [12e7e719764-21c]' }
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should include the fault code in the error object" do
|
16
|
+
expect { subject }.to raise_error { |e| e.code.should == '12e7e719764-21c' }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when there is an internal error fault" do
|
21
|
+
before { savon.stubs(soap_action).raises_soap_fault.returns(Savon::Spec::Fixture[:faults, :internal_error_fault]) }
|
22
|
+
|
23
|
+
it "should raise a YieldStarClient internal error" do
|
24
|
+
expect { subject }.to raise_error(YieldStarClient::InternalError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should include the fault message in the error object" do
|
28
|
+
expect { subject }.to raise_error { |e| e.message.should == 'Internal error [12e7cfbb782-37a]' }
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should include the fault code in the error object" do
|
32
|
+
expect { subject }.to raise_error { |e| e.code.should == '12e7cfbb782-37a' }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when there is an operation fault" do
|
37
|
+
before { savon.stubs(soap_action).raises_soap_fault.returns(Savon::Spec::Fixture[:faults, :operation_fault]) }
|
38
|
+
|
39
|
+
it "should raise a YieldStarClient operation error" do
|
40
|
+
expect { subject }.to raise_error(YieldStarClient::OperationError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should include the fault message in the error object" do
|
44
|
+
expect { subject }.to raise_error { |e| e.message.should == 'Invalid floor plan name null [12e7e6acc24-1b]' }
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should include the fault code in the error object" do
|
48
|
+
expect { subject }.to raise_error { |e| e.code.should == '12e7e6acc24-1b' }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when there is a generic fault" do
|
53
|
+
before { savon.stubs(soap_action).raises_soap_fault.returns(Savon::Spec::Fixture[:faults, :generic_fault]) }
|
54
|
+
|
55
|
+
it "should raise a YieldStarClient server error" do
|
56
|
+
expect { subject }.to raise_error(YieldStarClient::ServerError)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should include the fault message in the error object" do
|
60
|
+
expect { subject }.to raise_error { |e| e.message.should == 'java.lang.NullPointerException' }
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should include the fault code in the error object" do
|
64
|
+
expect { subject }.to raise_error { |e| e.code.should == 'S:Server' }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for "a client_name validator" do
|
4
|
+
it_should_behave_like "a required string validator", :client_name
|
5
|
+
it_should_behave_like "a string length validator", :client_name, 16
|
6
|
+
end
|
7
|
+
|
8
|
+
shared_examples_for "an external_property_id validator" do
|
9
|
+
it_should_behave_like "a required string validator", :external_property_id
|
10
|
+
it_should_behave_like "a string length validator", :external_property_id, 50
|
11
|
+
end
|
12
|
+
|
13
|
+
shared_examples_for 'a required string validator' do |param_name|
|
14
|
+
context "when #{param_name} is nil" do
|
15
|
+
let(param_name) { nil }
|
16
|
+
|
17
|
+
it "should raise an ArgumentError" do
|
18
|
+
expect { subject }.to raise_error(ArgumentError)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should indicate the error is related to the #{param_name}" do
|
22
|
+
expect { subject }.to raise_error { |e| e.message.should match(/#{param_name}/i) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when #{param_name} is blank" do
|
27
|
+
let(param_name) { ' ' }
|
28
|
+
|
29
|
+
it "should raise an ArgumentError" do
|
30
|
+
expect { subject }.to raise_error(ArgumentError)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should indicate the error is related to the #{param_name}" do
|
34
|
+
expect { subject }.to raise_error { |e| e.message.should match(/#{param_name}/i) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
shared_examples_for 'a string length validator' do |param_name, max_length|
|
40
|
+
context "when #{param_name} is too long" do
|
41
|
+
let(param_name) { "foo" * max_length }
|
42
|
+
|
43
|
+
it "should raise an ArgumentError" do
|
44
|
+
expect { subject }.to raise_error(ArgumentError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should indicate the error is related to the #{param_name}" do
|
48
|
+
expect { subject }.to raise_error { |e| e.message.should match(/#{param_name}/i) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
shared_examples_for 'an integer validator' do |param_name|
|
54
|
+
context "when #{param_name} cannot be cast to an int" do
|
55
|
+
let(param_name) { 'forty-two' }
|
56
|
+
|
57
|
+
it "should raise an ArgumentError" do
|
58
|
+
expect { subject }.to raise_error(ArgumentError)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should indicate the error is related to the #{param_name}" do
|
62
|
+
expect { subject }.to raise_error { |e| e.message.should match(/#{param_name}/i) }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
shared_examples_for 'a date validator' do |param_name|
|
68
|
+
context "when #{param_name} cannot be converted to a date" do
|
69
|
+
let(param_name) { 'foo' }
|
70
|
+
|
71
|
+
it "should raise an ArgumentError" do
|
72
|
+
expect { subject }.to raise_error(ArgumentError)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should indicate the error is related to the #{param_name}" do
|
76
|
+
expect { subject }.to raise_error { |e| e.message.should match(/#{param_name}/i) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "amenity methods" do
|
4
|
+
subject { test_object }
|
5
|
+
let(:test_object) { YieldStarClient::Client.new(:endpoint => 'http://bogusendpoint') }
|
6
|
+
|
7
|
+
let(:client_name) { 'my_client_name' }
|
8
|
+
let(:external_property_id) { 'my_prop_id' }
|
9
|
+
|
10
|
+
it { should respond_to(:get_floor_plan_amenities) }
|
11
|
+
it { should respond_to(:get_unit_amenities) }
|
12
|
+
|
13
|
+
describe "#get_floor_plan_amenities" do
|
14
|
+
before { savon.stubs(:get_floor_plan_amenities).returns(nil) }
|
15
|
+
|
16
|
+
subject { amenities }
|
17
|
+
let(:amenities) { test_object.get_floor_plan_amenities(client_name, external_property_id, floor_plan_name) }
|
18
|
+
let(:floor_plan_name) { 'my_floor_plan' }
|
19
|
+
|
20
|
+
it "should retrieve the amenity data from the service" do
|
21
|
+
soap_body = {:client_name => client_name,
|
22
|
+
:external_property_id => external_property_id,
|
23
|
+
:floor_plan_name => floor_plan_name}
|
24
|
+
savon.expects(:get_floor_plan_amenities).with(:request => soap_body).returns(:no_amenities)
|
25
|
+
subject.should be
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with no amenities" do
|
29
|
+
before { savon.stubs(:get_floor_plan_amenities).returns(:no_amenities) }
|
30
|
+
|
31
|
+
it { should be }
|
32
|
+
it { should be_empty }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with a single amenity" do
|
36
|
+
before { savon.stubs(:get_floor_plan_amenities).returns(:single_amenity) }
|
37
|
+
|
38
|
+
it { should have(1).amenity }
|
39
|
+
|
40
|
+
describe "first amenity" do
|
41
|
+
subject { amenities.first }
|
42
|
+
|
43
|
+
its(:name) { should == 'Garage Spot' }
|
44
|
+
its(:type) { should == 'Parking' }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with multiple amenities" do
|
49
|
+
before { savon.stubs(:get_floor_plan_amenities).returns(:multiple_amenities) }
|
50
|
+
|
51
|
+
it { should have(2).amenities }
|
52
|
+
|
53
|
+
describe "first amenity" do
|
54
|
+
subject { amenities.first }
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "last amenity" do
|
58
|
+
subject { amenities.last }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Validations
|
63
|
+
it_should_behave_like 'a client_name validator'
|
64
|
+
it_should_behave_like 'an external_property_id validator'
|
65
|
+
it_should_behave_like 'a required string validator', :floor_plan_name
|
66
|
+
|
67
|
+
# Error handling
|
68
|
+
it_should_behave_like 'a fault handler', :get_floor_plan_amenities
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#get_unit_amenities" do
|
72
|
+
before { savon.stubs(:get_unit_amenities).returns(nil) }
|
73
|
+
|
74
|
+
subject { amenities }
|
75
|
+
|
76
|
+
let(:amenities) { test_object.get_unit_amenities(client_name, external_property_id, unit_name, building) }
|
77
|
+
let(:unit_name) { 'my_unit_name' }
|
78
|
+
let(:building) { 'my_building' }
|
79
|
+
|
80
|
+
context "without a building" do
|
81
|
+
let(:amenities) { test_object.get_unit_amenities(client_name, external_property_id, unit_name) }
|
82
|
+
let(:soap_body) do
|
83
|
+
{:client_name => client_name,
|
84
|
+
:external_property_id => external_property_id,
|
85
|
+
:unit_name => unit_name}
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should retrieve the data from the service" do
|
89
|
+
savon.expects(:get_unit_amenities).with(:request => soap_body).returns(:no_amenities)
|
90
|
+
subject.should be
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "with a building" do
|
95
|
+
let(:soap_body) do
|
96
|
+
{:client_name => client_name,
|
97
|
+
:external_property_id => external_property_id,
|
98
|
+
:unit_name => unit_name,
|
99
|
+
:building => building}
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should retrieve the data from the service" do
|
103
|
+
savon.expects(:get_unit_amenities).with(:request => soap_body).returns(:no_amenities)
|
104
|
+
subject.should be
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "when there are no amenities" do
|
109
|
+
before { savon.stubs(:get_unit_amenities).returns(:no_amenities) }
|
110
|
+
|
111
|
+
it { should be }
|
112
|
+
it { should be_empty }
|
113
|
+
end
|
114
|
+
|
115
|
+
context "when there is one amenity" do
|
116
|
+
before { savon.stubs(:get_unit_amenities).returns(:single_amenity) }
|
117
|
+
|
118
|
+
it { should have(1).amenity }
|
119
|
+
|
120
|
+
describe "first amenity" do
|
121
|
+
subject { amenities.first }
|
122
|
+
|
123
|
+
its(:name) { should == '2nd Floor' }
|
124
|
+
its(:type) { should == 'Fixed' }
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "when there are multiple amenities" do
|
129
|
+
before { savon.stubs(:get_unit_amenities).returns(:multiple_amenities) }
|
130
|
+
|
131
|
+
describe "first amenity" do
|
132
|
+
subject { amenities.first }
|
133
|
+
|
134
|
+
its(:name) { should == 'Rent Adjustment' }
|
135
|
+
its(:type) { should == 'Fixed' }
|
136
|
+
its(:value) { should == 50.0 }
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "last amenity" do
|
140
|
+
subject { amenities.last }
|
141
|
+
|
142
|
+
its(:name) { should == 'Good Credit Adjustment' }
|
143
|
+
its(:type) { should == 'Variable' }
|
144
|
+
its(:value) { should be_nil }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Validation
|
149
|
+
it_should_behave_like 'a client_name validator'
|
150
|
+
it_should_behave_like 'an external_property_id validator'
|
151
|
+
it_should_behave_like 'a required string validator', :unit_name
|
152
|
+
|
153
|
+
context "when there is no building" do
|
154
|
+
before { savon.stubs(:get_unit_amenities).returns(:no_amenities) }
|
155
|
+
let(:amenities) { test_object.get_unit_amenities(client_name, external_property_id, unit_name) }
|
156
|
+
|
157
|
+
it "should not raise an error" do
|
158
|
+
expect { subject }.to_not raise_error
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Error handling
|
163
|
+
it_should_behave_like 'a fault handler', :get_unit_amenities
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe YieldStarClient::Client do
|
4
|
+
subject { client }
|
5
|
+
|
6
|
+
after { YieldStarClient.reset }
|
7
|
+
|
8
|
+
let(:client) do
|
9
|
+
YieldStarClient::Client.new({:endpoint => endpoint,
|
10
|
+
:username => username,
|
11
|
+
:password => password,
|
12
|
+
:namespace => namespace})
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:endpoint) { 'https://foo.com?wsdl' }
|
16
|
+
let(:default_endpoint) { YieldStarClient::DEFAULT_ENDPOINT }
|
17
|
+
let(:username) { 'test_user' }
|
18
|
+
let(:password) { 'secret' }
|
19
|
+
let(:namespace) { 'http://foo.com/namespace' }
|
20
|
+
|
21
|
+
its(:endpoint) { should == endpoint }
|
22
|
+
its(:username) { should == username }
|
23
|
+
its(:password) { should == password }
|
24
|
+
its(:namespace) { should == namespace }
|
25
|
+
|
26
|
+
# Methods from the PropertyMethods mixin
|
27
|
+
# The actual tests for these are in property_methods_spec
|
28
|
+
# TODO: test mixins using shared example groups?
|
29
|
+
# see: http://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shared-example-groups-in-rspec-2/
|
30
|
+
it { should respond_to(:get_properties) }
|
31
|
+
it { should respond_to(:get_property) }
|
32
|
+
it { should respond_to(:get_property_parameters) }
|
33
|
+
|
34
|
+
# Methods from the FloorPlanMethods mixin
|
35
|
+
it { should respond_to(:get_floor_plan) }
|
36
|
+
it { should respond_to(:get_floor_plans) }
|
37
|
+
|
38
|
+
# Methods from UnitMethods
|
39
|
+
it { should respond_to(:get_unit) }
|
40
|
+
it { should respond_to(:get_units) }
|
41
|
+
|
42
|
+
# Methods from AmenityMethods
|
43
|
+
it { should respond_to(:get_floor_plan_amenities) }
|
44
|
+
it { should respond_to(:get_unit_amenities) }
|
45
|
+
|
46
|
+
# Methods from RentMethods
|
47
|
+
it { should respond_to(:get_rent_summary) }
|
48
|
+
it { should respond_to(:get_available_units) }
|
49
|
+
|
50
|
+
# Methods from LeaseTermRentMethods
|
51
|
+
it { should respond_to(:get_lease_term_rent) }
|
52
|
+
it { should respond_to(:get_lease_term_rent_plus) }
|
53
|
+
it { should respond_to(:get_renewal_lease_term_rent) }
|
54
|
+
|
55
|
+
context "with default configuration" do
|
56
|
+
let(:client) { YieldStarClient::Client.new }
|
57
|
+
|
58
|
+
its(:endpoint) { should == default_endpoint }
|
59
|
+
its(:username) { should_not be }
|
60
|
+
its(:password) { should_not be }
|
61
|
+
its(:namespace) { should == YieldStarClient::DEFAULT_NAMESPACE }
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#endpoint=" do
|
65
|
+
subject { client.endpoint = new_endpoint }
|
66
|
+
|
67
|
+
context "with a new endpoint" do
|
68
|
+
let(:new_endpoint) { 'http://new-foo.com/service/' }
|
69
|
+
|
70
|
+
it "should change the endpoint" do
|
71
|
+
expect { subject }.to change{client.endpoint}.from(endpoint).to(new_endpoint)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "with a nil endpoint" do
|
76
|
+
let(:new_endpoint) { nil }
|
77
|
+
|
78
|
+
context "when there is no configured endpoint" do
|
79
|
+
it "should change to the default endpoint" do
|
80
|
+
expect { subject }.to change{client.endpoint}.from(endpoint).to(default_endpoint)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when there is a configured endpoint" do
|
85
|
+
let(:configured_endpoint) { 'http://configured.endpoint.com' }
|
86
|
+
before { YieldStarClient.configure { |config| config.endpoint = configured_endpoint } }
|
87
|
+
|
88
|
+
it "should change to the configured endpoint" do
|
89
|
+
expect { subject }.to change{client.endpoint}.from(endpoint).to(configured_endpoint)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#username=" do
|
96
|
+
subject { client.username = new_username }
|
97
|
+
let(:new_username) { 'new username' }
|
98
|
+
|
99
|
+
it "should change the username" do
|
100
|
+
expect { subject }.to change{client.username}.from(username).to(new_username)
|
101
|
+
end
|
102
|
+
|
103
|
+
context "with a nil username" do
|
104
|
+
let(:new_username) { nil }
|
105
|
+
|
106
|
+
context "when there is no configured username" do
|
107
|
+
it "should change the username to nil" do
|
108
|
+
expect { subject }.to change{client.username}.from(username).to(nil)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "when there is a configured username" do
|
113
|
+
let(:configured_username) { 'configured user' }
|
114
|
+
before { YieldStarClient.configure { |config| config.username = configured_username } }
|
115
|
+
|
116
|
+
it "should change the username to the configured username" do
|
117
|
+
expect { subject }.to change{client.username}.from(username).to(configured_username)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#password=" do
|
124
|
+
subject { client.password = new_password }
|
125
|
+
let(:new_password) { 'new secret' }
|
126
|
+
|
127
|
+
it "should change the password" do
|
128
|
+
expect { subject }.to change{client.password}.from(password).to(new_password)
|
129
|
+
end
|
130
|
+
|
131
|
+
context "with a nil password" do
|
132
|
+
let(:new_password) { nil }
|
133
|
+
|
134
|
+
context "when there is no configured password" do
|
135
|
+
it "should change the password to nil" do
|
136
|
+
expect { subject }.to change{client.password}.from(password).to(nil)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context "when there is a configured password" do
|
141
|
+
let(:configured_password) { 'configured password' }
|
142
|
+
before { YieldStarClient.configure { |config| config.password = configured_password } }
|
143
|
+
|
144
|
+
it "should change the password to the configured value" do
|
145
|
+
expect { subject }.to change{client.password}.from(password).to(configured_password)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|