you_got_listed 0.2.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.
Files changed (39) hide show
  1. data/.document +5 -0
  2. data/.gitignore +25 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE +20 -0
  5. data/README.rdoc +226 -0
  6. data/Rakefile +18 -0
  7. data/lib/you_got_listed.rb +17 -0
  8. data/lib/you_got_listed/accounts.rb +9 -0
  9. data/lib/you_got_listed/agent.rb +24 -0
  10. data/lib/you_got_listed/client.rb +25 -0
  11. data/lib/you_got_listed/complex.rb +42 -0
  12. data/lib/you_got_listed/complexes.rb +53 -0
  13. data/lib/you_got_listed/error.rb +17 -0
  14. data/lib/you_got_listed/lead.rb +13 -0
  15. data/lib/you_got_listed/listing.rb +73 -0
  16. data/lib/you_got_listed/listings.rb +110 -0
  17. data/lib/you_got_listed/resource.rb +19 -0
  18. data/lib/you_got_listed/response.rb +25 -0
  19. data/lib/you_got_listed/version.rb +3 -0
  20. data/spec/fixtures/responses/error.xml +2 -0
  21. data/spec/spec.opts +1 -0
  22. data/spec/spec_helper.rb +18 -0
  23. data/spec/support/complex_helper.rb +82 -0
  24. data/spec/support/listing_helper.rb +59 -0
  25. data/spec/support/webmock_helper.rb +26 -0
  26. data/spec/you_got_listed/accounts_spec.rb +26 -0
  27. data/spec/you_got_listed/agent_spec.rb +94 -0
  28. data/spec/you_got_listed/client_spec.rb +17 -0
  29. data/spec/you_got_listed/complex_spec.rb +26 -0
  30. data/spec/you_got_listed/complexes_spec.rb +80 -0
  31. data/spec/you_got_listed/error_spec.rb +10 -0
  32. data/spec/you_got_listed/lead_spec.rb +56 -0
  33. data/spec/you_got_listed/listing_spec.rb +110 -0
  34. data/spec/you_got_listed/listings_spec.rb +229 -0
  35. data/spec/you_got_listed/resource_spec.rb +17 -0
  36. data/spec/you_got_listed/response_spec.rb +119 -0
  37. data/spec/you_got_listed_api_key.yml.example +1 -0
  38. data/you_got_listed.gemspec +31 -0
  39. metadata +231 -0
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe YouGotListed::Resource do
4
+
5
+ before do
6
+ @ygl = new_ygl
7
+ @resource = YouGotListed::Resource.new(@ygl)
8
+ end
9
+
10
+ context "initialize" do
11
+ it "should instantiate with a client" do
12
+ @resource.client.should_not be_nil
13
+ @resource.client.should be_kind_of(YouGotListed::Client)
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,119 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe YouGotListed::Response do
4
+
5
+ context "should not raise errors" do
6
+ before do
7
+ @ygl = new_ygl
8
+ @accounts = YouGotListed::Accounts.new(@ygl)
9
+ end
10
+
11
+ it "should not raise an exception" do
12
+ lambda {
13
+ VCR.use_cassette('accounts.search') do
14
+ @response = @accounts.search
15
+ end
16
+ }.should_not raise_exception
17
+ end
18
+ end
19
+
20
+ context "should return a response" do
21
+ before do
22
+ @ygl = new_ygl
23
+ @accounts = YouGotListed::Accounts.new(@ygl)
24
+ end
25
+
26
+ it "should not raise an exception" do
27
+ lambda {
28
+ VCR.use_cassette('accounts.search') do
29
+ @response = @accounts.search
30
+ end
31
+ }.should_not raise_exception
32
+ end
33
+
34
+ it "should be a success" do
35
+ VCR.use_cassette('accounts.search') do
36
+ @response = @accounts.search
37
+ end
38
+ @response.success?.should be_true
39
+ @response.ygl_response.should_not be_nil
40
+ @response.ygl_response.should be_kind_of(Hashie::Rash)
41
+ end
42
+ end
43
+
44
+ context "method missing" do
45
+ before do
46
+ @ygl = new_ygl
47
+ @accounts = YouGotListed::Accounts.new(@ygl)
48
+ VCR.use_cassette('accounts.search') do
49
+ @response = @accounts.search
50
+ end
51
+ end
52
+
53
+ it "should allow response.ygl_response methods to be called on response" do
54
+ body = stub(:total_count => 25)
55
+ @response.ygl_response = body
56
+ @response.total_count.should == 25
57
+ end
58
+
59
+ it "should call super if ygl_response does not respond to the method" do
60
+ lambda { @response.bad_method }.should raise_error(NoMethodError, /undefined method `bad_method'/)
61
+ end
62
+ end
63
+
64
+ context "passing raise_errors = true" do
65
+ before do
66
+ @ygl = new_ygl
67
+ @mocked_response = httparty_get(@ygl.class.base_uri, '/accounts/search.php', 'error.xml', @ygl.class.default_params)
68
+ end
69
+
70
+ it "should raise errors when raise_errors is true" do
71
+ lambda {
72
+ YouGotListed::Response.new(@mocked_response, true)
73
+ }.should raise_exception(YouGotListed::Error, "YouGotListed Error: Invalid key. (code: 998)")
74
+ end
75
+ end
76
+
77
+ context "client timeout error" do
78
+ before do
79
+ @ygl = new_ygl
80
+ YouGotListed::Client.stub!(:get).and_raise(Timeout::Error)
81
+ @accounts = YouGotListed::Accounts.new(@ygl)
82
+ end
83
+
84
+ it "should not raise errors" do
85
+ lambda {
86
+ @response = @accounts.search
87
+ }.should_not raise_exception
88
+ end
89
+
90
+ it "should not be a success" do
91
+ @response = @accounts.search
92
+ @response.success?.should be_false
93
+ @response.response_code.should == "996"
94
+ @response.error.should == "Timeout"
95
+ end
96
+ end
97
+
98
+ context "client exception" do
99
+ before do
100
+ @ygl = new_ygl
101
+ YouGotListed::Client.stub!(:get).and_raise(Exception)
102
+ @accounts = YouGotListed::Accounts.new(@ygl)
103
+ end
104
+
105
+ it "should not raise errors" do
106
+ lambda {
107
+ @response = @accounts.search
108
+ }.should_not raise_exception
109
+ end
110
+
111
+ it "should not be a success" do
112
+ @response = @accounts.search
113
+ @response.success?.should be_false
114
+ @response.response_code.should == "999"
115
+ @response.error.should == "Unknown Error"
116
+ end
117
+ end
118
+
119
+ end
@@ -0,0 +1 @@
1
+ api_key: your_key_here
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "you_got_listed/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{you_got_listed}
7
+ s.authors = ["Tom Cocca"]
8
+ s.date = %q{2011-04-11}
9
+ s.description = %q{Ruby API wrapper for yougotlistings.com built with httparty}
10
+ s.email = %q{tom.cocca@gmail.com}
11
+ s.homepage = %q{http://github.com/tcocca/you_got_listed}
12
+ s.rdoc_options = ["--charset=UTF-8"]
13
+ s.rubygems_version = %q{1.3.5}
14
+ s.summary = %q{ruby api wrapper for you got listings}
15
+
16
+ s.version = YouGotListed::VERSION
17
+ s.platform = Gem::Platform::RUBY
18
+
19
+ s.add_dependency "httparty", ">= 0.6.1"
20
+ s.add_dependency "rash", ">= 0.3.0"
21
+ s.add_dependency "will_paginate", ">= 2.3.4"
22
+ s.add_dependency "activesupport", "~> 2.3"
23
+ s.add_development_dependency "rspec", ">= 2.5.0"
24
+ s.add_development_dependency "webmock", ">= 1.6.2"
25
+ s.add_development_dependency "vcr", ">= 1.8.0"
26
+
27
+ s.require_paths = ['lib']
28
+ s.files = `git ls-files`.split("\n")
29
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
30
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
31
+ end
metadata ADDED
@@ -0,0 +1,231 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: you_got_listed
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
+ platform: ruby
12
+ authors:
13
+ - Tom Cocca
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-11 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: httparty
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 0
32
+ - 6
33
+ - 1
34
+ version: 0.6.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rash
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 0
48
+ - 3
49
+ - 0
50
+ version: 0.3.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: will_paginate
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 11
62
+ segments:
63
+ - 2
64
+ - 3
65
+ - 4
66
+ version: 2.3.4
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 5
78
+ segments:
79
+ - 2
80
+ - 3
81
+ version: "2.3"
82
+ type: :runtime
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 27
93
+ segments:
94
+ - 2
95
+ - 5
96
+ - 0
97
+ version: 2.5.0
98
+ type: :development
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ name: webmock
102
+ prerelease: false
103
+ requirement: &id006 !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 11
109
+ segments:
110
+ - 1
111
+ - 6
112
+ - 2
113
+ version: 1.6.2
114
+ type: :development
115
+ version_requirements: *id006
116
+ - !ruby/object:Gem::Dependency
117
+ name: vcr
118
+ prerelease: false
119
+ requirement: &id007 !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ hash: 55
125
+ segments:
126
+ - 1
127
+ - 8
128
+ - 0
129
+ version: 1.8.0
130
+ type: :development
131
+ version_requirements: *id007
132
+ description: Ruby API wrapper for yougotlistings.com built with httparty
133
+ email: tom.cocca@gmail.com
134
+ executables: []
135
+
136
+ extensions: []
137
+
138
+ extra_rdoc_files: []
139
+
140
+ files:
141
+ - .document
142
+ - .gitignore
143
+ - Gemfile
144
+ - LICENSE
145
+ - README.rdoc
146
+ - Rakefile
147
+ - lib/you_got_listed.rb
148
+ - lib/you_got_listed/accounts.rb
149
+ - lib/you_got_listed/agent.rb
150
+ - lib/you_got_listed/client.rb
151
+ - lib/you_got_listed/complex.rb
152
+ - lib/you_got_listed/complexes.rb
153
+ - lib/you_got_listed/error.rb
154
+ - lib/you_got_listed/lead.rb
155
+ - lib/you_got_listed/listing.rb
156
+ - lib/you_got_listed/listings.rb
157
+ - lib/you_got_listed/resource.rb
158
+ - lib/you_got_listed/response.rb
159
+ - lib/you_got_listed/version.rb
160
+ - spec/fixtures/responses/error.xml
161
+ - spec/spec.opts
162
+ - spec/spec_helper.rb
163
+ - spec/support/complex_helper.rb
164
+ - spec/support/listing_helper.rb
165
+ - spec/support/webmock_helper.rb
166
+ - spec/you_got_listed/accounts_spec.rb
167
+ - spec/you_got_listed/agent_spec.rb
168
+ - spec/you_got_listed/client_spec.rb
169
+ - spec/you_got_listed/complex_spec.rb
170
+ - spec/you_got_listed/complexes_spec.rb
171
+ - spec/you_got_listed/error_spec.rb
172
+ - spec/you_got_listed/lead_spec.rb
173
+ - spec/you_got_listed/listing_spec.rb
174
+ - spec/you_got_listed/listings_spec.rb
175
+ - spec/you_got_listed/resource_spec.rb
176
+ - spec/you_got_listed/response_spec.rb
177
+ - spec/you_got_listed_api_key.yml.example
178
+ - you_got_listed.gemspec
179
+ has_rdoc: true
180
+ homepage: http://github.com/tcocca/you_got_listed
181
+ licenses: []
182
+
183
+ post_install_message:
184
+ rdoc_options:
185
+ - --charset=UTF-8
186
+ require_paths:
187
+ - lib
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ hash: 3
194
+ segments:
195
+ - 0
196
+ version: "0"
197
+ required_rubygems_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ hash: 3
203
+ segments:
204
+ - 0
205
+ version: "0"
206
+ requirements: []
207
+
208
+ rubyforge_project:
209
+ rubygems_version: 1.4.2
210
+ signing_key:
211
+ specification_version: 3
212
+ summary: ruby api wrapper for you got listings
213
+ test_files:
214
+ - spec/fixtures/responses/error.xml
215
+ - spec/spec.opts
216
+ - spec/spec_helper.rb
217
+ - spec/support/complex_helper.rb
218
+ - spec/support/listing_helper.rb
219
+ - spec/support/webmock_helper.rb
220
+ - spec/you_got_listed/accounts_spec.rb
221
+ - spec/you_got_listed/agent_spec.rb
222
+ - spec/you_got_listed/client_spec.rb
223
+ - spec/you_got_listed/complex_spec.rb
224
+ - spec/you_got_listed/complexes_spec.rb
225
+ - spec/you_got_listed/error_spec.rb
226
+ - spec/you_got_listed/lead_spec.rb
227
+ - spec/you_got_listed/listing_spec.rb
228
+ - spec/you_got_listed/listings_spec.rb
229
+ - spec/you_got_listed/resource_spec.rb
230
+ - spec/you_got_listed/response_spec.rb
231
+ - spec/you_got_listed_api_key.yml.example