hostelify 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,85 @@
1
+ require 'spec/_helper'
2
+
3
+ describe "find hostel by id, no options" do
4
+
5
+ before(:all) do
6
+ @h = Hostelworld.find_hostel_by_id(:id => 7113)
7
+ @h = Hostelworld.find_hostel_by_id(:id => 20763)
8
+ end
9
+
10
+ it "should query hostelworld and return the correct name" do
11
+ @h.name.should match(/^.*(Hostel).*$/)
12
+ end
13
+
14
+ it "address" do
15
+ @h.address.should match(/^.*(Krakow|Lviv).*$/)
16
+ end
17
+
18
+ it "description" do
19
+ @h.address.should_not be nil
20
+ end
21
+
22
+ it "facilities" do
23
+ @h.should have_at_least(15).facilities
24
+ end
25
+
26
+ it "ratings" do
27
+ @h.should have(6).ratings
28
+ end
29
+
30
+ end
31
+
32
+ describe "youtube" do
33
+
34
+ before(:all) do
35
+ @h3 = Hostelworld.find_hostel_by_id(:id => 7113)
36
+ end
37
+
38
+ it "video" do
39
+ @h3.video.should match(/^.*(youtube.com).*$/)
40
+ end
41
+ end
42
+
43
+ describe "find hostel with all options" do
44
+ before(:all) do
45
+ @h2 = Hostelworld.find_hostel_by_id(:id => 7113, :all => true)
46
+ @h2 = Hostelworld.find_hostel_by_id(:id => 20763, :all => true)
47
+ end
48
+
49
+ it "geo" do
50
+ @h2.geo[0].to_f.round.should eql 50
51
+ end
52
+
53
+ it "directions" do
54
+ @h2.directions.should_not be nil
55
+ end
56
+
57
+ it "images at least 6" do
58
+ @h2.should have_at_least(6).images
59
+ end
60
+ end
61
+
62
+ describe "with dates to get availabilty and verify output!" do
63
+ before(:all) do
64
+ #@h = Hostelworld.find_hostel_by_id(:id => 20763, :date => (Date.today+20).to_s)
65
+ @h = Hostelworld.find_hostel_by_id(:id => 7113, :date => (Date.today+20).to_s)
66
+ end
67
+
68
+ it "get first availability and check it merit" do
69
+ @h.availability.first.name =~ /bed/
70
+ end
71
+
72
+ it "check number of avail beds" do
73
+ @h.availability.last.spots.to_i.should be >= 1
74
+ end
75
+
76
+ it "last avail has a price > 5 US" do
77
+ @h.availability.last.price.to_i.should be > 5
78
+ end
79
+
80
+ it "book date eq today + 10" do
81
+ @h.availability.last.bookdate.should_not be nil
82
+ end
83
+
84
+
85
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec/_helper'
2
+
3
+ describe "finds list of hostels" do
4
+
5
+ before(:all) do
6
+ @h = Hostelworld.find_hostels_by_location(:location => 'krakow,poland')
7
+ end
8
+
9
+ it "should get a list with name and brief desc" do
10
+ names = []
11
+ @h.each do |e|
12
+ names << e.name
13
+ end
14
+ names.should include("Mama's Hostel Main Market Square")
15
+ end
16
+
17
+
18
+ it "rating should be high for first choices" do
19
+ @h.first.rating.to_i.should be > 50
20
+ end
21
+
22
+ it "desc should have a certain length <" do
23
+ @h.first.description.length.should be > 80
24
+ end
25
+
26
+ it "has a hostel number" do
27
+ @h.first.hostel_id.to_i.should_not be nil
28
+ end
29
+
30
+ end
31
+
32
+ describe "find hostels with dates" do
33
+
34
+ before(:all) do
35
+ @h = Hostelworld.find_hostels_by_location(:location => 'krakow,poland', :date => (Date.today + 10).to_s)
36
+ end
37
+
38
+ it "rating should be high for first choices" do
39
+ @h.first.rating.to_i.should be > 50
40
+ end
41
+
42
+ it "desc should have a certain length <" do
43
+ @h.first.description.length.should be > 90
44
+ end
45
+
46
+ it "has a hostel number" do
47
+ @h.first.hostel_id.to_i.should_not be nil
48
+ end
49
+
50
+ it "has dorm rooms for greater than $5" do
51
+ @h.first.dorm.to_i.should be > 5
52
+ end
53
+
54
+ it "has available rooms!" do
55
+ @h.first.unavailable.first.should be nil
56
+ end
57
+
58
+ it "has unavailable rooms!" do
59
+ @h.last.unavailable.first.should_not be nil
60
+ end
61
+
62
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hostelify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.7
5
+ platform: ruby
6
+ authors:
7
+ - Holden Thomas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-19 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Simple Hostel Webscrapper.
17
+ email: holden.thomas@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - lib/hostelify.rb
25
+ - lib/hostelify/gomio.rb
26
+ - lib/hostelify/hostelbookers.rb
27
+ - lib/hostelify/hostelify.rb
28
+ - lib/hostelify/hostelworld.rb
29
+ files:
30
+ - Manifest
31
+ - README.rdoc
32
+ - Rakefile
33
+ - hostelify.gemspec
34
+ - lib/hostelify.rb
35
+ - lib/hostelify/gomio.rb
36
+ - lib/hostelify/hostelbookers.rb
37
+ - lib/hostelify/hostelify.rb
38
+ - lib/hostelify/hostelworld.rb
39
+ - pkg/hostelify-0.3.6.gem
40
+ - pkg/hostelify-0.3.6.tar.gz
41
+ - pkg/hostelify-0.3.6/Manifest
42
+ - pkg/hostelify-0.3.6/README.rdoc
43
+ - pkg/hostelify-0.3.6/Rakefile
44
+ - pkg/hostelify-0.3.6/hostelify.gemspec
45
+ - pkg/hostelify-0.3.6/lib/hostelify.rb
46
+ - pkg/hostelify-0.3.6/lib/hostelify/gomio.rb
47
+ - pkg/hostelify-0.3.6/lib/hostelify/hostelbookers.rb
48
+ - pkg/hostelify-0.3.6/lib/hostelify/hostelify.rb
49
+ - pkg/hostelify-0.3.6/lib/hostelify/hostelworld.rb
50
+ - pkg/hostelify-0.3.6/spec/_helper.rb
51
+ - pkg/hostelify-0.3.6/spec/hb_find_by_hostel.spec
52
+ - pkg/hostelify-0.3.6/spec/hb_find_hostels.spec
53
+ - pkg/hostelify-0.3.6/spec/hw_find_by_hostel.spec
54
+ - pkg/hostelify-0.3.6/spec/hw_find_hostels.spec
55
+ - spec/_helper.rb
56
+ - spec/hb_find_by_hostel.spec
57
+ - spec/hb_find_hostels.spec
58
+ - spec/hw_find_by_hostel.spec
59
+ - spec/hw_find_hostels.spec
60
+ has_rdoc: true
61
+ homepage: http://github.com/holden/hostelify
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options:
66
+ - --line-numbers
67
+ - --inline-source
68
+ - --title
69
+ - Hostelify
70
+ - --main
71
+ - README.rdoc
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "1.2"
85
+ version:
86
+ requirements: []
87
+
88
+ rubyforge_project: hostelify
89
+ rubygems_version: 1.3.5
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Simple Hostel Webscrapper.
93
+ test_files: []
94
+