oodler 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class ImageTest < Test::Unit::TestCase
4
+
5
+ should "parse image correctly from xml" do
6
+ image = Oodler::Image.from_xml('<element>
7
+ <src>http://i.oodleimg.com/item/1900074984_1s?1271160266</src>
8
+ <width>112</width>
9
+ <height>84</height>
10
+ <alt>2010 Chrysler Town &amp; Country T</alt>
11
+ </element>')
12
+
13
+ image.src.should == "http://i.oodleimg.com/item/1900074984_1s?1271160266"
14
+ image.width.should == "112"
15
+ image.height.should == "84"
16
+
17
+
18
+
19
+ end
20
+ end
@@ -0,0 +1,42 @@
1
+ require 'test/unit'
2
+ require 'pathname'
3
+ require 'rubygems'
4
+
5
+ gem 'shoulda', '>= 2.10.1'
6
+ gem 'jnunemaker-matchy', '0.4.0'
7
+ gem 'mocha', '0.9.4'
8
+ gem 'fakeweb', '>= 1.2.5'
9
+ gem 'httparty', '>= 0.5.2'
10
+
11
+ require 'shoulda'
12
+ require 'matchy'
13
+ require 'mocha'
14
+ require 'fakeweb'
15
+ require 'httparty'
16
+
17
+ FakeWeb.allow_net_connect = false
18
+
19
+ dir = (Pathname(__FILE__).dirname + '../lib').expand_path
20
+ require dir + 'oodler'
21
+
22
+ class Test::Unit::TestCase
23
+ end
24
+
25
+ def fixture_file(filename)
26
+ return '' if filename == ''
27
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
28
+ File.read(file_path)
29
+ end
30
+
31
+ def oodle_url(url)
32
+ url =~ /^http/ ? url : "http://api.oodle.com#{url}"
33
+ end
34
+
35
+ def stub_get(url, filename, status=nil)
36
+ options = {:body => fixture_file(filename)}
37
+ options.merge!({:status => status}) unless status.nil?
38
+
39
+ FakeWeb.register_uri(:get, oodle_url(url), options)
40
+ end
41
+
42
+
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ class WebClientTest < Test::Unit::TestCase
4
+ context "when hitting the Oodle API" do
5
+ setup do
6
+ @wc = Oodler::WebClient.new('key')
7
+ end
8
+
9
+ should "throw an error if key is nil" do
10
+ @wc = Oodler::WebClient.new
11
+ stub_get("/api/v2/listings?region=chicago&category=vehicle%2Fcar&key=key", "listings.xml")
12
+ assert_raise(Oodler::OodleArgumentError) do
13
+ @wc.get("/listings",{:query => {:region => "chicago", :category=>"vehicle/car"}})
14
+ end
15
+
16
+ end
17
+
18
+ should "add the key param to the url" do
19
+ stub_get("/api/v2/listings?region=chicago&category=vehicle%2Fcar&key=key", "listings.xml")
20
+ @wc.get("/listings",{:query => {:region => "chicago", :category=>"vehicle/car"}})
21
+ end
22
+
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oodler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mike Hagedorn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-04-15 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: roxml
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 3.1.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: crack
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.4
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: shoulda
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.10.1
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: jnunemaker-matchy
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.4.0
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: mocha
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "="
62
+ - !ruby/object:Gem::Version
63
+ version: 0.9.4
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: fakeweb
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 1.2.5
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: httparty
77
+ type: :development
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 0.5.2
84
+ version:
85
+ description: Ruby wrapper for the Oodle API
86
+ email: mike@silverchairsolutions.com
87
+ executables: []
88
+
89
+ extensions: []
90
+
91
+ extra_rdoc_files:
92
+ - LICENSE
93
+ - README.markdown
94
+ files:
95
+ - LICENSE
96
+ - README.markdown
97
+ - Rakefile
98
+ - VERSION
99
+ - lib/oodler.rb
100
+ - lib/oodler/category.rb
101
+ - lib/oodler/client.rb
102
+ - lib/oodler/element.rb
103
+ - lib/oodler/image.rb
104
+ - lib/oodler/location.rb
105
+ - lib/oodler/oodle_response.rb
106
+ - lib/oodler/region.rb
107
+ - lib/oodler/source.rb
108
+ - lib/oodler/web_client.rb
109
+ - test/client_test.rb
110
+ - test/element_test.rb
111
+ - test/fixtures/blank.xml
112
+ - test/fixtures/fail.xml
113
+ - test/fixtures/listings.xml
114
+ - test/image_test.rb
115
+ - test/test_helper.rb
116
+ - test/web_client_test.rb
117
+ has_rdoc: true
118
+ homepage: http://github.com/mwhagedorn/oodler
119
+ licenses: []
120
+
121
+ post_install_message:
122
+ rdoc_options:
123
+ - --charset=UTF-8
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: "0"
131
+ version:
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: "0"
137
+ version:
138
+ requirements: []
139
+
140
+ rubyforge_project:
141
+ rubygems_version: 1.3.5
142
+ signing_key:
143
+ specification_version: 3
144
+ summary: Ruby wrapper for the Oodle API
145
+ test_files:
146
+ - test/client_test.rb
147
+ - test/element_test.rb
148
+ - test/image_test.rb
149
+ - test/test_helper.rb
150
+ - test/web_client_test.rb
151
+ - examples/listings.rb