vast_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/test/helper.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'minitest/autorun'
11
+ require 'vcr'
12
+
13
+ VCR.config do |c|
14
+ c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
15
+ c.stub_with :webmock # or :fakeweb
16
+ end
17
+
18
+
19
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
20
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
21
+ require 'vast_api'
22
+
23
+ class MiniTest::Unit::TestCase
24
+ end
25
+
26
+ MiniTest::Unit.autorun
@@ -0,0 +1,97 @@
1
+ require 'helper'
2
+
3
+ describe VastApi do
4
+ before do
5
+ @vast = VastApi.new
6
+ end
7
+
8
+ describe 'Listings' do
9
+ before do
10
+ VCR.use_cassette('bike listings', :record => :new_episodes) do
11
+ @listing = @vast.category('item_vehicle/bike').listings
12
+ end
13
+ p @listing.url
14
+ end
15
+
16
+ it "should return a list of items" do
17
+ @listing.size.must_be(:>, 0)
18
+ end
19
+
20
+ it "should be able to get attributes from listings" do
21
+ id = @listing.attr('id')
22
+ id.wont_be_nil
23
+ #id.should == @listing.attr('id')
24
+ end
25
+
26
+ it "should be able to get query options for listings" do
27
+ @listing.query['category'].wont_be_nil
28
+ end
29
+
30
+ it "should be able to get options from listings" do
31
+ @listing.attr('startIndex').wont_be_nil
32
+ end
33
+
34
+ it "should be ablt to get vars" do
35
+ @listing.attr('site_count').wont_be_nil
36
+ end
37
+
38
+ it "should return an error if no category is set" do
39
+ lambda { VastApi.new.listings }.must_raise ArgumentError
40
+ end
41
+
42
+ it "should be able to filter items" do
43
+ VCR.use_cassette("filter items", :record => :new_episodes) do
44
+ filter = @vast.category('horses').where('pet-gen'=>'Male').listings
45
+ p filter.url
46
+ filter.size.must_be(:>, 0)
47
+ end
48
+ end
49
+
50
+ it "find should raise an error if there is no category" do
51
+ bike = @listing.first
52
+ lambda { @vast.find(bike.id) }.must_raise ArgumentError
53
+ end
54
+
55
+ it "find should get a single item" do
56
+ bike = @listing.first
57
+ VCR.use_cassette('find bike with category', :record => :new_episodes) do
58
+ find_bike_cat = @vast.find(bike.id, @listing.query['category'])
59
+ find_bike_cat.id.must_equal bike.id
60
+ end
61
+ end
62
+ end
63
+
64
+ describe 'Attributes' do
65
+ before do
66
+ VCR.use_cassette('find bike with attribute', :record => :new_episodes) do
67
+ @attributes = @vast.category('item_vehicle/bike').attributes
68
+ end
69
+ end
70
+
71
+ it "should be able to fetch attributes" do
72
+ p @attributes
73
+ @attributes.size.must_be(:>, 0)
74
+ end
75
+
76
+ it "each entry should be hash" do
77
+ @attributes.must_be_kind_of VastApi::Attributes
78
+ end
79
+ end
80
+
81
+ describe 'Categories' do
82
+ before do
83
+ VCR.use_cassette('find bike with category', :record => :new_episodes) do
84
+ @categories = @vast.categories
85
+ end
86
+ end
87
+
88
+ it "should be a kind of category" do
89
+ @categories.must_be_kind_of VastApi::Categories
90
+ end
91
+
92
+ it "should be able to fetch categories" do
93
+ @categories.size.must_be(:>, 0)
94
+ end
95
+ end
96
+
97
+ end
data/vast_api.gemspec ADDED
@@ -0,0 +1,89 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{vast_api}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Ong", "Mikhail Knyazev"]
12
+ s.date = %q{2011-03-18}
13
+ s.description = %q{A ruby wrapper for the http://www.vast.com/ api}
14
+ s.email = %q{ryanong@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/vast_api.rb",
28
+ "lib/vast_api/attributes.rb",
29
+ "lib/vast_api/attributes/entry.rb",
30
+ "lib/vast_api/base.rb",
31
+ "lib/vast_api/categories.rb",
32
+ "lib/vast_api/categories/category.rb",
33
+ "lib/vast_api/listings.rb",
34
+ "lib/vast_api/listings/entry.rb",
35
+ "test/fixtures/vcr_cassettes/bike_listings.yml",
36
+ "test/fixtures/vcr_cassettes/filter_items.yml",
37
+ "test/fixtures/vcr_cassettes/find_bike_with_attribute.yml",
38
+ "test/fixtures/vcr_cassettes/find_bike_with_category.yml",
39
+ "test/helper.rb",
40
+ "test/test_vast_api.rb",
41
+ "vast_api.gemspec"
42
+ ]
43
+ s.homepage = %q{http://github.com/ryanong/vast_api}
44
+ s.licenses = ["MIT"]
45
+ s.require_paths = ["lib"]
46
+ s.rubygems_version = %q{1.6.1}
47
+ s.summary = %q{A ruby wrapper for the http://www.vast.com/ api}
48
+ s.test_files = [
49
+ "test/helper.rb",
50
+ "test/test_vast_api.rb"
51
+ ]
52
+
53
+ if s.respond_to? :specification_version then
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
58
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
59
+ s.add_development_dependency(%q<minitest>, [">= 0"])
60
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
61
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
62
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
63
+ s.add_development_dependency(%q<rcov>, [">= 0"])
64
+ s.add_development_dependency(%q<webmock>, [">= 0"])
65
+ s.add_development_dependency(%q<vcr>, [">= 0"])
66
+ else
67
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
68
+ s.add_dependency(%q<nokogiri>, [">= 0"])
69
+ s.add_dependency(%q<minitest>, [">= 0"])
70
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
71
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
72
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
73
+ s.add_dependency(%q<rcov>, [">= 0"])
74
+ s.add_dependency(%q<webmock>, [">= 0"])
75
+ s.add_dependency(%q<vcr>, [">= 0"])
76
+ end
77
+ else
78
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
79
+ s.add_dependency(%q<nokogiri>, [">= 0"])
80
+ s.add_dependency(%q<minitest>, [">= 0"])
81
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
82
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
83
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
84
+ s.add_dependency(%q<rcov>, [">= 0"])
85
+ s.add_dependency(%q<webmock>, [">= 0"])
86
+ s.add_dependency(%q<vcr>, [">= 0"])
87
+ end
88
+ end
89
+
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vast_api
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Ong
9
+ - Mikhail Knyazev
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-03-18 00:00:00 -04:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: activesupport
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 2.3.5
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: *id001
28
+ - !ruby/object:Gem::Dependency
29
+ name: nokogiri
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: *id002
39
+ - !ruby/object:Gem::Dependency
40
+ name: minitest
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: *id003
50
+ - !ruby/object:Gem::Dependency
51
+ name: yard
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: 0.6.0
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: *id004
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.0
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: *id005
72
+ - !ruby/object:Gem::Dependency
73
+ name: jeweler
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: 1.5.2
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: *id006
83
+ - !ruby/object:Gem::Dependency
84
+ name: rcov
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: *id007
94
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: &id008 !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: *id008
105
+ - !ruby/object:Gem::Dependency
106
+ name: vcr
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: *id009
116
+ description: A ruby wrapper for the http://www.vast.com/ api
117
+ email: ryanong@gmail.com
118
+ executables: []
119
+
120
+ extensions: []
121
+
122
+ extra_rdoc_files:
123
+ - LICENSE.txt
124
+ - README.rdoc
125
+ files:
126
+ - .document
127
+ - Gemfile
128
+ - Gemfile.lock
129
+ - LICENSE.txt
130
+ - README.rdoc
131
+ - Rakefile
132
+ - VERSION
133
+ - lib/vast_api.rb
134
+ - lib/vast_api/attributes.rb
135
+ - lib/vast_api/attributes/entry.rb
136
+ - lib/vast_api/base.rb
137
+ - lib/vast_api/categories.rb
138
+ - lib/vast_api/categories/category.rb
139
+ - lib/vast_api/listings.rb
140
+ - lib/vast_api/listings/entry.rb
141
+ - test/fixtures/vcr_cassettes/bike_listings.yml
142
+ - test/fixtures/vcr_cassettes/filter_items.yml
143
+ - test/fixtures/vcr_cassettes/find_bike_with_attribute.yml
144
+ - test/fixtures/vcr_cassettes/find_bike_with_category.yml
145
+ - test/helper.rb
146
+ - test/test_vast_api.rb
147
+ - vast_api.gemspec
148
+ has_rdoc: true
149
+ homepage: http://github.com/ryanong/vast_api
150
+ licenses:
151
+ - MIT
152
+ post_install_message:
153
+ rdoc_options: []
154
+
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ none: false
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ hash: 3557780049682049951
163
+ segments:
164
+ - 0
165
+ version: "0"
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ none: false
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: "0"
172
+ requirements: []
173
+
174
+ rubyforge_project:
175
+ rubygems_version: 1.6.1
176
+ signing_key:
177
+ specification_version: 3
178
+ summary: A ruby wrapper for the http://www.vast.com/ api
179
+ test_files:
180
+ - test/helper.rb
181
+ - test/test_vast_api.rb