campgrounds 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ require_relative '../../spec_helper.rb'
2
+ describe Campgrounds::Base do
3
+
4
+ describe "default attributes" do
5
+
6
+ # it "must have the base url set to the Active.com Camping API" do
7
+ # Campgrounds::Base.base_uri.must_include 'http://api.amp.active.com/camping'
8
+ # end
9
+ end
10
+ end
@@ -0,0 +1,47 @@
1
+ require_relative '../../spec_helper.rb'
2
+ describe Campgrounds::CampgroundDetails do
3
+
4
+ describe "GET campground_details" do
5
+ # Using testing key provided on developer.active.com's documentation
6
+ let(:campground) { Campgrounds::Base.new('2chxq68efd4azrpygt5hh2qu') }
7
+
8
+
9
+ before do
10
+ VCR.insert_cassette 'campground_details', :record => :new_episodes
11
+ end
12
+
13
+ after do
14
+ VCR.eject_cassette
15
+ end
16
+
17
+ it "records the fixture" do
18
+ campground.campground_details.request({:contractCode => 'CO', :parkId => '50032'})
19
+ end
20
+
21
+ it "must have a request method" do
22
+ campground.campground_details.must_respond_to :request
23
+ end
24
+
25
+ it "must parse the api response from XML to Hash" do
26
+ details = campground.campground_details.request({:contractCode => 'CO', :parkId => '50032'})
27
+ details.must_be_instance_of Hash
28
+ end
29
+
30
+ it "must get the right campground" do
31
+ details = campground.campground_details.request({:contractCode => 'CO', :parkId => '50032'})
32
+ details['contractID'].must_equal 'CO'
33
+ details['facilityID'].must_equal '50032'
34
+ details['facility'].must_equal 'MUELLER STATE PARK'
35
+ end
36
+
37
+ it "must raise method missing if attribute is not present" do
38
+ details = campground.campground_details.request({:contractCode => 'CO', :parkId => '50032'})
39
+ lambda { details.foo_attribute }.must_raise NoMethodError
40
+ end
41
+
42
+ it "must have a find method" do
43
+ campground.campground_details.must_respond_to :find
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,127 @@
1
+ require_relative '../../spec_helper.rb'
2
+ describe Campgrounds::CampgroundSearch do
3
+
4
+ describe "GET campground_search" do
5
+ # Using testing key provided on developer.active.com's documentation
6
+ let(:campground) { Campgrounds::Base.new('2chxq68efd4azrpygt5hh2qu') }
7
+
8
+
9
+ before do
10
+ VCR.insert_cassette 'campground_search', :record => :new_episodes
11
+ end
12
+
13
+ after do
14
+ VCR.eject_cassette
15
+ end
16
+
17
+ it "records the fixture" do
18
+ campground.campground_search.request({:pstate => 'CO', :siteType => 2001, :amenity => 4005, :pets => 3010})
19
+ end
20
+
21
+ it "must have a request method" do
22
+ campground.campground_search.must_respond_to :request
23
+ end
24
+
25
+ it "must parse the api response from XML to Hash" do
26
+ results = campground.campground_search.request({:pstate => 'CO', :siteType => 2001, :amenity => 4005, :pets => 3010})
27
+ results.must_be_instance_of Hash
28
+ end
29
+
30
+ it "must get the right search results" do
31
+ results = campground.campground_search.request({:pstate => 'CO', :siteType => 2001, :amenity => 4005, :pets => 3010})
32
+ results['pstate'].must_equal 'CO'
33
+ results['result'].each do |r|
34
+ r['sitesWithPetsAllowed'].must_equal 'Y'
35
+ r['state'].must_equal 'CO'
36
+ end
37
+ end
38
+
39
+ it "must raise method missing if attribute is not present" do
40
+ results = campground.campground_search.request({:pstate => 'CO', :siteType => 2001, :amenity => 4005, :pets => 3010})
41
+ lambda { results.foo_attribute }.must_raise NoMethodError
42
+ end
43
+
44
+ end
45
+
46
+ describe "campground_search added methods" do
47
+ # Using testing key provided on developer.active.com's documentation
48
+ let(:campground) { Campgrounds::Base.new('2chxq68efd4azrpygt5hh2qu') }
49
+
50
+
51
+ before do
52
+ VCR.insert_cassette 'campground_search_added', :record => :new_episodes
53
+ end
54
+
55
+ after do
56
+ VCR.eject_cassette
57
+ end
58
+
59
+ it "lets you search by address" do
60
+ results = campground.campground_search.find_by_address('Denver, CO', 50)
61
+ results['count'].wont_be_empty
62
+ results['result'].each do |r|
63
+ r['state'].must_equal 'CO'
64
+ end
65
+ end
66
+
67
+ it "only returns results within the desired range" do
68
+ results = campground.campground_search.find_by_address('Denver, CO', 50)
69
+ results['result'].each do |r|
70
+ r['distance'].must_be :<=, 50
71
+ end
72
+ end
73
+
74
+ end
75
+
76
+ describe "campground_search find method" do
77
+ let(:campground) { Campgrounds::Base.new('2chxq68efd4azrpygt5hh2qu') }
78
+
79
+ before do
80
+ VCR.insert_cassette 'campground_search_find', :record => :new_episodes
81
+ end
82
+
83
+ after do
84
+ VCR.eject_cassette
85
+ end
86
+
87
+ it "must have a find method" do
88
+ campground.campground_search.must_respond_to :find
89
+ end
90
+
91
+ it "must allow use of string descriptions for site type" do
92
+ results = campground.campground_search.find({:pstate => 'CO', :siteType => 'rv'})
93
+ results.must_be_instance_of Hash
94
+ end
95
+
96
+ it "must allow use of string descriptions for amenities" do
97
+ results = campground.campground_search.find({:pstate => 'CO', :amenity => 'biking'})
98
+ results.must_be_instance_of Hash
99
+ end
100
+
101
+ it "must allow use of string descriptions for hookup amp size" do
102
+ results = campground.campground_search.find({:pState => 'CO', :hookup => '15+'})
103
+ results.must_be_instance_of Hash
104
+
105
+ # This doesn't work because some campgrounds don't have this param set, they just list amps in description field
106
+ # results['result'].each do |r|
107
+ # r['sitesWithAmps'].must_equal "Y"
108
+ # end
109
+ end
110
+
111
+ it "must allow use of booleans for the water option" do
112
+ results = campground.campground_search.find({:pState => 'CO', :water => true})
113
+ results.must_be_instance_of Hash
114
+ end
115
+
116
+ it "must allow use of booleans for the sewer option" do
117
+ results = campground.campground_search.find({:pState => 'CO', :sewer => true})
118
+ results.must_be_instance_of Hash
119
+ end
120
+
121
+ it "must allow use of booleans for the pull through option" do
122
+ results = campground.campground_search.find({:pState => 'CO', :pull => true})
123
+ results.must_be_instance_of Hash
124
+ end
125
+ end
126
+
127
+ end
@@ -0,0 +1,125 @@
1
+ require_relative '../../spec_helper.rb'
2
+ describe Campgrounds::CampsiteSearch do
3
+
4
+ describe "campsite_search raw request" do
5
+ # Using testing key provided on developer.active.com's documentation
6
+ let(:campsite) { Campgrounds::Base.new('2chxq68efd4azrpygt5hh2qu') }
7
+
8
+
9
+ before do
10
+ VCR.insert_cassette 'campsite_search', :record => :new_episodes
11
+ end
12
+
13
+ after do
14
+ VCR.eject_cassette
15
+ end
16
+
17
+ it "records the fixture" do
18
+ campsite.campsite_search.request({:contractCode => 'CO', :parkId => '50032'})
19
+ end
20
+
21
+ it "must have a request method" do
22
+ campsite.campsite_search.must_respond_to :request
23
+ end
24
+
25
+ it "must parse the api response from XML to Hash" do
26
+ results = campsite.campsite_search.request({:contractCode => 'CO', :parkId => '50032'})
27
+ results.must_be_instance_of Hash
28
+ end
29
+
30
+ it "must get the right search results" do
31
+ results = campsite.campsite_search.request({:contractCode => 'CO', :parkId => '50032', :siteType => '2002'})
32
+ results['contractCode'].must_equal 'CO'
33
+ results['parkId'].must_equal '50032'
34
+ results['resultType'].must_equal 'campsites'
35
+ results['result'].each do |r|
36
+ # An rv or trailer site will be described like "40 FT. ELECTRIC"
37
+ r['SiteType'].must_include 'FT.'
38
+ end
39
+ end
40
+
41
+ it "must raise method missing if attribute is not present" do
42
+ results = campsite.campsite_search.request({:contractCode => 'CO', :parkId => '50032'})
43
+ lambda { results.foo_attribute }.must_raise NoMethodError
44
+ end
45
+ end
46
+
47
+ describe "campsite_search find method" do
48
+
49
+ let(:campsite) { Campgrounds::Base.new('2chxq68efd4azrpygt5hh2qu') }
50
+
51
+ before do
52
+ VCR.insert_cassette 'campsite_search_find', :record => :new_episodes
53
+ end
54
+
55
+ after do
56
+ VCR.eject_cassette
57
+ end
58
+
59
+ it "must have a find method" do
60
+ campsite.campsite_search.must_respond_to :find
61
+ end
62
+
63
+ it "must allow use of string descriptions for site type" do
64
+ rv_results = campsite.campsite_search.find({:contractCode => 'CO', :parkId => '50032', :siteType => 'rv'})
65
+ rv_results['result'].each do |r|
66
+ r['SiteType'].must_include 'FT.'
67
+ end
68
+
69
+ cabin_results = campsite.campsite_search.find({:contractCode => 'CO', :parkId => '50032', :siteType => 'cabin'})
70
+ cabin_results['result'].each do |r|
71
+ r['SiteType'].must_include 'CABIN'
72
+ end
73
+ end
74
+
75
+ it "must allow use of string descriptions for hookup amp size" do
76
+ rv_results = campsite.campsite_search.find({:contractCode => 'CO', :parkId => '50032', :hookup => '15+'})
77
+ rv_results['result'].each do |r|
78
+ r['sitesWithAmps'].to_i.must_be :>=, 15
79
+ end
80
+
81
+ cabin_results = campsite.campsite_search.find({:contractCode => 'CO', :parkId => '50032', :hookup => '30+'})
82
+ cabin_results['result'].each do |r|
83
+ r['sitesWithAmps'].to_i.must_be :>=, 30
84
+ end
85
+ end
86
+
87
+ it "must allow use of booleans for the water option" do
88
+ results = campsite.campsite_search.find({:contractCode => 'CO', :parkId => '50022', :water => true})
89
+ results['result'].each do |r|
90
+ r['sitesWithWaterHookup'].must_equal "Y"
91
+ end
92
+ end
93
+
94
+ it "must allow use of booleans for the sewer option" do
95
+ results = campsite.campsite_search.find({:contractCode => 'CO', :parkId => '50022', :sewer => true})
96
+ results['result'].each do |r|
97
+ r['sitesWithWaterHookup'].must_equal "Y"
98
+ end
99
+ end
100
+
101
+ it "must allow use of booleans for the pull through option" do
102
+ results = campsite.campsite_search.find({:contractCode => 'CO', :parkId => '50022', :pull => true})
103
+ results['result'].each do |r|
104
+ r['Drivewayentry'].must_equal "Pull-Through"
105
+ end
106
+ end
107
+
108
+ it "must allow use of booleans for the pets option" do
109
+ results = campsite.campsite_search.find({:contractCode => 'CO', :parkId => '50022', :pets => true})
110
+ results['result'].each do |r|
111
+ r['sitesWithPetsAllowed'].must_equal "Y"
112
+ end
113
+ end
114
+
115
+ # Failing for forbidden error, not sure why?
116
+ # it "must allow use of booleans for the waterfront option" do
117
+ # results = campsite.campsite_search.find({:contractCode => 'CO', :parkId => '50022', :waterfront => true})
118
+ # results['result'].each do |r|
119
+ # r['sitesWithWaterfront'].wont_be_empty
120
+ # end
121
+ # end
122
+
123
+ end
124
+
125
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../lib/campgrounds'
2
+ require 'minitest/autorun'
3
+ require 'webmock/minitest'
4
+ require 'vcr'
5
+ require 'turn'
6
+ Turn.config do |c|
7
+ c.format = :outline
8
+ c.trace = true
9
+ c.natural = true
10
+ c.verbose = true
11
+ c.trace = 10
12
+ end
13
+ VCR.configure do |c|
14
+ c.cassette_library_dir = 'spec/fixtures/campgrounds_cassettes'
15
+ c.hook_into :webmock
16
+ end
metadata ADDED
@@ -0,0 +1,217 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: campgrounds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tami Mitchell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hashie
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rest-client
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: xml-simple
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
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: geokit
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: webmock
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: vcr
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: turn
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rake
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: Provide a wrapper for the Active Network campground API
143
+ email:
144
+ - mail@tamimitchell.com
145
+ executables: []
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - .rvmrc
150
+ - Gemfile
151
+ - Gemfile.lock
152
+ - LICENSE.txt
153
+ - README.md
154
+ - Rakefile
155
+ - campgrounds-0.0.1.gem
156
+ - campgrounds.gemspec
157
+ - lib/campgrounds.rb
158
+ - lib/campgrounds/base.rb
159
+ - lib/campgrounds/campground_details.rb
160
+ - lib/campgrounds/campground_search.rb
161
+ - lib/campgrounds/campsite_search.rb
162
+ - lib/campgrounds/version.rb
163
+ - pkg/campgrounds-0.0.1.gem
164
+ - spec/fixtures/campgrounds_cassettes/campground_details.yml
165
+ - spec/fixtures/campgrounds_cassettes/campground_search.yml
166
+ - spec/fixtures/campgrounds_cassettes/campground_search_added.yml
167
+ - spec/fixtures/campgrounds_cassettes/campground_search_find.yml
168
+ - spec/fixtures/campgrounds_cassettes/campsite_search.yml
169
+ - spec/fixtures/campgrounds_cassettes/campsite_search_find.yml
170
+ - spec/lib/campgrounds/base_spec.rb
171
+ - spec/lib/campgrounds/campground_details_spec.rb
172
+ - spec/lib/campgrounds/campground_search_spec.rb
173
+ - spec/lib/campgrounds/campsite_search_spec.rb
174
+ - spec/spec_helper.rb
175
+ homepage: ''
176
+ licenses: []
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ segments:
188
+ - 0
189
+ hash: -1639732289215519928
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ! '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ segments:
197
+ - 0
198
+ hash: -1639732289215519928
199
+ requirements: []
200
+ rubyforge_project:
201
+ rubygems_version: 1.8.24
202
+ signing_key:
203
+ specification_version: 3
204
+ summary: Provide data on campgrounds in Reserve America's database via the Active
205
+ Network campground API
206
+ test_files:
207
+ - spec/fixtures/campgrounds_cassettes/campground_details.yml
208
+ - spec/fixtures/campgrounds_cassettes/campground_search.yml
209
+ - spec/fixtures/campgrounds_cassettes/campground_search_added.yml
210
+ - spec/fixtures/campgrounds_cassettes/campground_search_find.yml
211
+ - spec/fixtures/campgrounds_cassettes/campsite_search.yml
212
+ - spec/fixtures/campgrounds_cassettes/campsite_search_find.yml
213
+ - spec/lib/campgrounds/base_spec.rb
214
+ - spec/lib/campgrounds/campground_details_spec.rb
215
+ - spec/lib/campgrounds/campground_search_spec.rb
216
+ - spec/lib/campgrounds/campsite_search_spec.rb
217
+ - spec/spec_helper.rb