suitcase 1.3.1 → 1.4.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/README.md +2 -2
- data/Rakefile +6 -5
- data/lib/suitcase/cache.rb +2 -2
- data/lib/suitcase/hotel/amenity.rb +1 -1
- data/lib/suitcase/hotel/hotel.rb +189 -60
- data/lib/suitcase/hotel/room.rb +9 -1
- data/lib/suitcase/version.rb +1 -1
- data/suitcase.gemspec +4 -2
- data/test/car_rentals/car_rental_test.rb +30 -0
- data/test/hotels/amenity_test.rb +23 -0
- data/test/hotels/caching_test.rb +42 -0
- data/test/hotels/ean_exception_test.rb +24 -0
- data/test/hotels/helpers_test.rb +44 -0
- data/test/hotels/hotel_location_test.rb +23 -0
- data/test/hotels/hotel_test.rb +85 -0
- data/test/hotels/image_test.rb +20 -0
- data/test/hotels/payment_option_test.rb +15 -0
- data/test/hotels/reservation_test.rb +15 -0
- data/test/hotels/room_test.rb +45 -0
- data/test/hotels/session_test.rb +14 -0
- data/{spec → test}/keys.rb +4 -2
- data/test/minitest_helper.rb +17 -0
- metadata +49 -31
- data/spec/amenity_spec.rb +0 -25
- data/spec/car_rentals/car_rental_spec.rb +0 -20
- data/spec/hotels/caching_spec.rb +0 -32
- data/spec/hotels/helpers_spec.rb +0 -40
- data/spec/hotels/hotel_location_spec.rb +0 -21
- data/spec/hotels/hotels_spec.rb +0 -77
- data/spec/hotels/images_spec.rb +0 -23
- data/spec/hotels/payment_options_spec.rb +0 -13
- data/spec/hotels/reservation_spec.rb +0 -11
- data/spec/hotels/rooms_spec.rb +0 -63
- data/spec/hotels/sessions_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -3
@@ -0,0 +1,23 @@
|
|
1
|
+
require "minitest_helper"
|
2
|
+
|
3
|
+
describe Suitcase::Hotel::Location do
|
4
|
+
before :each do
|
5
|
+
@location = Suitcase::Hotel::Location.new({})
|
6
|
+
end
|
7
|
+
|
8
|
+
[:destination_id, :province, :country, :country_code, :city, :type,
|
9
|
+
:active].each do |accessor|
|
10
|
+
it "has an accessor for #{accessor}" do
|
11
|
+
@location.must_respond_to(accessor)
|
12
|
+
@location.must_respond_to((accessor.to_s + "=").to_sym)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".find" do
|
17
|
+
it "returns an Array of Locations" do
|
18
|
+
locations = Suitcase::Hotel::Location.find(destination_string: "Lond")
|
19
|
+
locations.must_be_kind_of(Array)
|
20
|
+
locations.first.must_be_kind_of(Suitcase::Hotel::Location)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "minitest_helper"
|
2
|
+
|
3
|
+
describe Suitcase::Hotel do
|
4
|
+
before :each do
|
5
|
+
@hotel = Suitcase::Hotel.find(id: 123904)
|
6
|
+
end
|
7
|
+
|
8
|
+
[:id, :name, :address, :city, :amenities, :masked_amenities, :country_code,
|
9
|
+
:high_rate, :low_rate, :longitude, :latitude, :rating, :postal_code,
|
10
|
+
:images, :nightly_rate_total, :property_description, :number_of_floors,
|
11
|
+
:number_of_rooms, :deep_link, :tripadvisor_rating].each do |attribute|
|
12
|
+
it "has an attr_accessor for #{attribute}" do
|
13
|
+
@hotel.must_respond_to(attribute)
|
14
|
+
@hotel.must_respond_to((attribute.to_s + "=").to_sym)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".find" do
|
19
|
+
it "returns a single Hotel if passed an ID" do
|
20
|
+
@hotel.must_be_kind_of(Suitcase::Hotel)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns multiple Hotels if an ID is not passed in" do
|
24
|
+
hotels = Suitcase::Hotel.find(location: "London, UK")
|
25
|
+
hotels.must_be_kind_of(Array)
|
26
|
+
hotels.first.must_be_kind_of(Suitcase::Hotel)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns multiple Hotels if multiple ID's are passed in" do
|
30
|
+
hotels = Suitcase::Hotel.find(ids: [123904, 191937, 220166])
|
31
|
+
hotels.must_be_kind_of(Array)
|
32
|
+
hotels.first.must_be_kind_of(Suitcase::Hotel)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns an Array with a single Hotel if an Array with a single ID is passed in" do
|
36
|
+
hotels = Suitcase::Hotel.find(ids: [123904])
|
37
|
+
hotels.count.must_equal(1)
|
38
|
+
hotels.first.must_be_kind_of(Suitcase::Hotel)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "sets a recovery attribute on the raised error when the location is not specific enough" do
|
42
|
+
begin
|
43
|
+
Suitcase::Hotel.find(location: "Mexico")
|
44
|
+
rescue Suitcase::EANException => e
|
45
|
+
e.recoverable?.must_equal(true) if e.type == :multiple_locations
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "sets the error type when the location is not specific enough" do
|
50
|
+
begin
|
51
|
+
Suitcase::Hotel.find(location: "Mexico")
|
52
|
+
rescue Suitcase::EANException => e
|
53
|
+
e.type.must_equal(:multiple_locations)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#images" do
|
59
|
+
it "correctly gets the URLs of the images" do
|
60
|
+
images = @hotel.images
|
61
|
+
images.must_be_kind_of(Array)
|
62
|
+
images.map { |image| URI.parse(image.url) }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#thumbnail_url" do
|
67
|
+
it "returns the first image's thumbnail URL" do
|
68
|
+
@hotel.thumbnail_url.must_equal @hotel.images.first.thumbnail_url
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#rooms" do
|
73
|
+
before do
|
74
|
+
@info = {
|
75
|
+
arrival: "1/1/2013",
|
76
|
+
departure: "1/8/2013"
|
77
|
+
}
|
78
|
+
@rooms = @hotel.rooms(@info)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns an Array of available Rooms" do
|
82
|
+
@rooms.must_be_kind_of(Array)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "minitest_helper"
|
2
|
+
|
3
|
+
describe Suitcase::Image do
|
4
|
+
before :each do
|
5
|
+
@image = Suitcase::Hotel.find(id: 123904).images.first
|
6
|
+
end
|
7
|
+
|
8
|
+
[:url, :id, :caption, :height, :width, :thumbnail_url, :name].each do |meth|
|
9
|
+
it "has an accessor for #{meth}" do
|
10
|
+
@image.must_respond_to(meth)
|
11
|
+
@image.must_respond_to((meth.to_s + "=").to_sym)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#url" do
|
16
|
+
it "returns a valid URL" do
|
17
|
+
URI.parse(@image.url).must_be_kind_of(URI)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "minitest_helper"
|
2
|
+
|
3
|
+
describe Suitcase::PaymentOption do
|
4
|
+
before :each do
|
5
|
+
@info = { currency_code: "USD" }
|
6
|
+
end
|
7
|
+
|
8
|
+
describe ".find" do
|
9
|
+
it "returns an Array of PaymentOption's" do
|
10
|
+
options = Suitcase::PaymentOption.find(@info)
|
11
|
+
options.must_be_kind_of(Array)
|
12
|
+
options.first.must_be_kind_of(Suitcase::PaymentOption)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "minitest_helper"
|
2
|
+
|
3
|
+
describe Suitcase::Reservation do
|
4
|
+
before :each do
|
5
|
+
@reservation = Suitcase::Reservation.new({})
|
6
|
+
end
|
7
|
+
|
8
|
+
it "has a reader for itinerary_id" do
|
9
|
+
@reservation.must_respond_to :itinerary_id
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has a reader for confirmation_numbers" do
|
13
|
+
@reservation.must_respond_to :confirmation_numbers
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "minitest_helper"
|
2
|
+
|
3
|
+
describe Suitcase::Room do
|
4
|
+
before :each do
|
5
|
+
@room = Suitcase::Hotel.find(id: 123904).rooms(arrival: "6/23/2012", departure: "6/30/2012").first
|
6
|
+
end
|
7
|
+
|
8
|
+
%w(arrival departure rate_code room_type_code supplier_type tax_rate
|
9
|
+
non_refundable occupancy quoted_occupancy min_guest_age total surcharge_total
|
10
|
+
average_base_rate average_base_rate average_rate max_nightly_rate
|
11
|
+
currency_code value_adds room_type_description price_breakdown total_price
|
12
|
+
average_nightly_rate promo rate_key hotel_id supplier_type bed_types
|
13
|
+
rooms).each do |attribute|
|
14
|
+
it "has an attr_accessor for #{attribute}" do
|
15
|
+
@room.must_respond_to attribute.to_sym
|
16
|
+
@room.must_respond_to (attribute + "=").to_sym
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#reserve!" do
|
21
|
+
before :each do
|
22
|
+
@info = { email: "walter.john.nelson@gmail.com",
|
23
|
+
first_name: "Walter",
|
24
|
+
last_name: "Nelson",
|
25
|
+
home_phone: "3831039402",
|
26
|
+
payment_option: Keys::SUITCASE_PAYMENT_OPTION, # Visa
|
27
|
+
credit_card_number: Keys::CREDIT_CARD_NUMBER_TESTING,
|
28
|
+
credit_card_verification_code: Keys::CREDIT_CARD_CVV_TESTING, # CVV
|
29
|
+
credit_card_expiration_date: Keys::CREDIT_CARD_EXPIRATION_DATE_TESTING,
|
30
|
+
address1: "travelnow", # for testing
|
31
|
+
address2: "Apt. 4A",
|
32
|
+
city: "Boston",
|
33
|
+
province: "MA",
|
34
|
+
country: "US",
|
35
|
+
postal_code: "02111" }
|
36
|
+
@room.rooms[0][:bed_type] = @room.bed_types[0]
|
37
|
+
@room.rooms[0][:smoking_preference] = "NS"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns a Suitcase::Reservation" do
|
41
|
+
reservation = @room.reserve!(@info)
|
42
|
+
reservation.must_be_kind_of(Suitcase::Reservation)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "minitest_helper"
|
2
|
+
|
3
|
+
describe Suitcase::Session do
|
4
|
+
before :each do
|
5
|
+
@session = Suitcase::Session.new
|
6
|
+
end
|
7
|
+
|
8
|
+
[:id, :ip_address, :user_agent, :locale, :currency_code].each do |accessor|
|
9
|
+
it "has an accessor for #{accessor}" do
|
10
|
+
@session.must_respond_to(accessor)
|
11
|
+
@session.must_respond_to((accessor.to_s + "=").to_sym)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/{spec → test}/keys.rb
RENAMED
@@ -6,8 +6,10 @@
|
|
6
6
|
# Or configure with a block:
|
7
7
|
|
8
8
|
Suitcase.configure do |config|
|
9
|
-
config.hotel_api_key = "
|
10
|
-
config.hotel_cid = "
|
9
|
+
config.hotel_api_key = "..."
|
10
|
+
config.hotel_cid = "..."
|
11
|
+
|
12
|
+
config.hotwire_api_key = "..."
|
11
13
|
# config.hotel_shared_secret = "none"
|
12
14
|
# config.use_signature_auth = false
|
13
15
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "turn"
|
2
|
+
require "minitest/spec"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "mocha"
|
5
|
+
|
6
|
+
require "pry"
|
7
|
+
|
8
|
+
$: << File.dirname(__FILE__) + "/../lib"
|
9
|
+
$: << File.dirname(__FILE__)
|
10
|
+
require "suitcase"
|
11
|
+
require "keys"
|
12
|
+
|
13
|
+
Turn.config do |config|
|
14
|
+
config.format = :pretty
|
15
|
+
# config.trace = true
|
16
|
+
config.natural = true
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: suitcase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: minitest
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: mocha
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
@@ -44,7 +44,23 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: turn
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
49
65
|
none: false
|
50
66
|
requirements:
|
@@ -141,20 +157,21 @@ files:
|
|
141
157
|
- lib/suitcase/hotel/room.rb
|
142
158
|
- lib/suitcase/session.rb
|
143
159
|
- lib/suitcase/version.rb
|
144
|
-
- spec/amenity_spec.rb
|
145
|
-
- spec/car_rentals/car_rental_spec.rb
|
146
|
-
- spec/hotels/caching_spec.rb
|
147
|
-
- spec/hotels/helpers_spec.rb
|
148
|
-
- spec/hotels/hotel_location_spec.rb
|
149
|
-
- spec/hotels/hotels_spec.rb
|
150
|
-
- spec/hotels/images_spec.rb
|
151
|
-
- spec/hotels/payment_options_spec.rb
|
152
|
-
- spec/hotels/reservation_spec.rb
|
153
|
-
- spec/hotels/rooms_spec.rb
|
154
|
-
- spec/hotels/sessions_spec.rb
|
155
|
-
- spec/keys.rb
|
156
|
-
- spec/spec_helper.rb
|
157
160
|
- suitcase.gemspec
|
161
|
+
- test/car_rentals/car_rental_test.rb
|
162
|
+
- test/hotels/amenity_test.rb
|
163
|
+
- test/hotels/caching_test.rb
|
164
|
+
- test/hotels/ean_exception_test.rb
|
165
|
+
- test/hotels/helpers_test.rb
|
166
|
+
- test/hotels/hotel_location_test.rb
|
167
|
+
- test/hotels/hotel_test.rb
|
168
|
+
- test/hotels/image_test.rb
|
169
|
+
- test/hotels/payment_option_test.rb
|
170
|
+
- test/hotels/reservation_test.rb
|
171
|
+
- test/hotels/room_test.rb
|
172
|
+
- test/hotels/session_test.rb
|
173
|
+
- test/keys.rb
|
174
|
+
- test/minitest_helper.rb
|
158
175
|
homepage: http://github.com/thoughtfusion/suitcase
|
159
176
|
licenses: []
|
160
177
|
post_install_message:
|
@@ -180,17 +197,18 @@ signing_key:
|
|
180
197
|
specification_version: 3
|
181
198
|
summary: Locates available hotels and rental cars through Expedia and Hotwire
|
182
199
|
test_files:
|
183
|
-
-
|
184
|
-
-
|
185
|
-
-
|
186
|
-
-
|
187
|
-
-
|
188
|
-
-
|
189
|
-
-
|
190
|
-
-
|
191
|
-
-
|
192
|
-
-
|
193
|
-
-
|
194
|
-
-
|
195
|
-
-
|
200
|
+
- test/car_rentals/car_rental_test.rb
|
201
|
+
- test/hotels/amenity_test.rb
|
202
|
+
- test/hotels/caching_test.rb
|
203
|
+
- test/hotels/ean_exception_test.rb
|
204
|
+
- test/hotels/helpers_test.rb
|
205
|
+
- test/hotels/hotel_location_test.rb
|
206
|
+
- test/hotels/hotel_test.rb
|
207
|
+
- test/hotels/image_test.rb
|
208
|
+
- test/hotels/payment_option_test.rb
|
209
|
+
- test/hotels/reservation_test.rb
|
210
|
+
- test/hotels/room_test.rb
|
211
|
+
- test/hotels/session_test.rb
|
212
|
+
- test/keys.rb
|
213
|
+
- test/minitest_helper.rb
|
196
214
|
has_rdoc:
|
data/spec/amenity_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Suitcase
|
4
|
-
describe Amenity do
|
5
|
-
describe ".parse_mask" do
|
6
|
-
context "when provided bitmask is not nil or 0" do
|
7
|
-
it "returns an array of symbols representing given amenities" do
|
8
|
-
Amenity.parse_mask(5).should == [:business_services, :hot_tub]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context "when provided bitmask is 0" do
|
13
|
-
it "returns an empty array" do
|
14
|
-
Amenity.parse_mask(0).should == []
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when provided bitmask is nil" do
|
19
|
-
it "returns nil" do
|
20
|
-
Amenity.parse_mask(nil).should == nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Suitcase::CarRental do
|
4
|
-
before :each do
|
5
|
-
@rentals = Suitcase::CarRental.find(destination: "Seattle", start_date: "07/04/2012", end_date: "07/11/2012", pickup_time: "07:30", dropoff_time: "07:30")
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '.find' do
|
9
|
-
it 'returns an Array of CarRentals' do
|
10
|
-
@rentals.class.should eq Array
|
11
|
-
@rentals.first.class.should eq Suitcase::CarRental
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
subject { @rentals.first }
|
16
|
-
|
17
|
-
[:seating, :type_name, :type_code, :possible_features, :possible_models].each do |method|
|
18
|
-
it { should respond_to method }
|
19
|
-
end
|
20
|
-
end
|
data/spec/hotels/caching_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Suitcase do
|
4
|
-
before :all do
|
5
|
-
Suitcase::Configuration.cache = {}
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should cache all non-secure queries" do
|
9
|
-
hotel = Suitcase::Hotel.find(id: 123904)
|
10
|
-
Suitcase::Hotel.find(location: "Boston, US")
|
11
|
-
room = hotel.rooms(arrival: "6/23/2012", departure: "6/30/2012").first
|
12
|
-
Suitcase::PaymentOption.find currency_code: "USD"
|
13
|
-
room.rooms[0][:bed_type] = room.bed_types[0]
|
14
|
-
room.rooms[0][:smoking_preference] = "NS"
|
15
|
-
room.reserve!(Keys::VALID_RESERVATION_INFO) # We don't want to cache this
|
16
|
-
Suitcase::Configuration.cache.keys.count.should eq(4)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should retrieve from the cache if it's there" do
|
20
|
-
hotel = Suitcase::Hotel.find(id: 123904)
|
21
|
-
Suitcase::Hotel.find(location: "Boston, US")
|
22
|
-
hotel.rooms(arrival: "6/23/2012", departure: "6/30/2012")
|
23
|
-
Suitcase::PaymentOption.find currency_code: "USD"
|
24
|
-
lambda do
|
25
|
-
Net::HTTP.stub!(:get_response).and_return nil # disable access to the API
|
26
|
-
hotel = Suitcase::Hotel.find(id: 123904)
|
27
|
-
Suitcase::Hotel.find(location: "Boston, US")
|
28
|
-
hotel.rooms(arrival: "6/23/2012", departure: "6/30/2012")
|
29
|
-
Suitcase::PaymentOption.find currency_code: "USD"
|
30
|
-
end.should_not raise_error
|
31
|
-
end
|
32
|
-
end
|
data/spec/hotels/helpers_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Suitcase::Helpers do
|
4
|
-
before :each do
|
5
|
-
class Dummy; extend Suitcase::Helpers; end
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#url" do
|
9
|
-
it "should return a URI with the correct base URL" do
|
10
|
-
returned = Dummy.url(:method => "action", :params => {})
|
11
|
-
returned.should be_a(URI)
|
12
|
-
returned.host.should match(/api.ean.com/)
|
13
|
-
end
|
14
|
-
|
15
|
-
context "when using digital signature authentication" do
|
16
|
-
it "should add a 'sig' parameter" do
|
17
|
-
Suitcase::Configuration.stub(:use_signature_auth?) { true }
|
18
|
-
Dummy.stub(:generate_signature) { "test" }
|
19
|
-
|
20
|
-
returned = Dummy.url(:method => "action", :params => {})
|
21
|
-
returned.query.should match(/sig=test/)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "#parse_response should raise an exception when passed an invalid URI" do
|
27
|
-
lambda do
|
28
|
-
Dummy.parse_response(URI.parse "http://google.com")
|
29
|
-
end.should raise_error
|
30
|
-
end
|
31
|
-
|
32
|
-
it "#generate_signature should return the encrypted api key, shared secret, and timestamp" do
|
33
|
-
Suitcase::Configuration.stub(:hotel_api_key) { "abc" }
|
34
|
-
Suitcase::Configuration.stub(:hotel_shared_secret) { "123" }
|
35
|
-
Time.stub(:now) { "10" }
|
36
|
-
|
37
|
-
returned = Dummy.generate_signature
|
38
|
-
returned.should == Digest::MD5.hexdigest("abc12310")
|
39
|
-
end
|
40
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Suitcase::Hotel::Location do
|
4
|
-
describe '.find' do
|
5
|
-
it 'should return an array of Locations' do
|
6
|
-
locations = Suitcase::Hotel::Location.find(:destination_string => "Lond")
|
7
|
-
locations.should be_an(Array)
|
8
|
-
locations.first.should be_a(Suitcase::Hotel::Location)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
before :all do
|
13
|
-
@location = Suitcase::Hotel::Location.new({})
|
14
|
-
end
|
15
|
-
|
16
|
-
subject { @location }
|
17
|
-
|
18
|
-
[:destination_id, :province, :country, :country_code, :city, :type, :active].each do |attribute|
|
19
|
-
it { should respond_to attribute }
|
20
|
-
end
|
21
|
-
end
|
data/spec/hotels/hotels_spec.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Suitcase::Hotel do
|
4
|
-
before :all do
|
5
|
-
@hotel = Suitcase::Hotel.find(id: 123904)
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "::find" do
|
9
|
-
it "should locate a single Hotel if an id argument is passed" do
|
10
|
-
@hotel.should be_a(Suitcase::Hotel)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should locate an Array of Hotels if an id argument is not passed" do
|
14
|
-
hotels = Suitcase::Hotel.find(location: "London, UK")
|
15
|
-
hotels.should be_an(Array)
|
16
|
-
hotels.first.should be_a(Suitcase::Hotel)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should locate an Array of Hotels if an ids argument is passed" do
|
20
|
-
hotels = Suitcase::Hotel.find(:ids => [123904, 191937, 220166])
|
21
|
-
hotels.should be_an(Array)
|
22
|
-
hotels.first.should be_a(Suitcase::Hotel)
|
23
|
-
hotels.count.should eq(3)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should locate an Array of Hotels if an ids argument is passed with a single id" do
|
27
|
-
hotels = Suitcase::Hotel.find(:ids => [123904])
|
28
|
-
hotels.should be_an(Array)
|
29
|
-
hotels.first.should be_a(Suitcase::Hotel)
|
30
|
-
hotels.count.should eq(1)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
subject { @hotel }
|
35
|
-
|
36
|
-
it { should respond_to :id }
|
37
|
-
it { should respond_to :name }
|
38
|
-
it { should respond_to :address }
|
39
|
-
it { should respond_to :city }
|
40
|
-
it { should respond_to :amenities }
|
41
|
-
it { should respond_to :masked_amenities }
|
42
|
-
it { should respond_to :country_code }
|
43
|
-
it { should respond_to :high_rate }
|
44
|
-
it { should respond_to :low_rate }
|
45
|
-
it { should respond_to :longitude }
|
46
|
-
it { should respond_to :latitude }
|
47
|
-
it { should respond_to :rating }
|
48
|
-
it { should respond_to :postal_code }
|
49
|
-
it { should respond_to :images }
|
50
|
-
it { should respond_to :thumbnail_url }
|
51
|
-
it { should respond_to :nightly_rate_total }
|
52
|
-
it { should respond_to :property_description }
|
53
|
-
it { should respond_to :number_of_floors }
|
54
|
-
it { should respond_to :number_of_rooms }
|
55
|
-
it { should respond_to :deep_link }
|
56
|
-
it { should respond_to :tripadvisor_rating }
|
57
|
-
|
58
|
-
it "#images should return an Array of Suitcase::Image's" do
|
59
|
-
images = @hotel.images
|
60
|
-
images.should be_an(Array)
|
61
|
-
lambda do
|
62
|
-
images.map { |image| URI.parse image.url }
|
63
|
-
end.should_not raise_error
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#rooms" do
|
67
|
-
before :all do
|
68
|
-
@info = { arrival: "6/23/2012", departure: "6/30/2012" }
|
69
|
-
end
|
70
|
-
|
71
|
-
subject do
|
72
|
-
@hotel.rooms(@info)
|
73
|
-
end
|
74
|
-
|
75
|
-
it { should be_an(Array) }
|
76
|
-
end
|
77
|
-
end
|
data/spec/hotels/images_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Suitcase::Image do
|
4
|
-
before :all do
|
5
|
-
@image = Suitcase::Hotel.find(id: 123904).images.first
|
6
|
-
end
|
7
|
-
|
8
|
-
subject { @image }
|
9
|
-
|
10
|
-
it { should respond_to :url }
|
11
|
-
it { should respond_to :id }
|
12
|
-
it { should respond_to :caption }
|
13
|
-
it { should respond_to :height }
|
14
|
-
it { should respond_to :width }
|
15
|
-
it { should respond_to :thumbnail_url }
|
16
|
-
it { should respond_to :name }
|
17
|
-
|
18
|
-
it "#url should return a valid URL" do
|
19
|
-
lambda do
|
20
|
-
URI.parse @image.url
|
21
|
-
end.should_not raise_error
|
22
|
-
end
|
23
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Suitcase::PaymentOption do
|
4
|
-
before :all do
|
5
|
-
@info = { currency_code: "USD" }
|
6
|
-
end
|
7
|
-
|
8
|
-
it "::find should return an Array of PaymentOptions" do
|
9
|
-
options = Suitcase::PaymentOption.find(@info)
|
10
|
-
options.should be_an(Array)
|
11
|
-
options.find_all { |opt| opt.class == Suitcase::PaymentOption }.count.should eq(options.count) # It should be an Array of PaymentOption's
|
12
|
-
end
|
13
|
-
end
|