upcoming-events 0.0.1

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.
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'matchy'
5
+ require 'mocha'
6
+ require 'fakeweb'
7
+
8
+ FakeWeb.allow_net_connect = false
9
+
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
12
+ require 'upcoming'
13
+
14
+ class Test::Unit::TestCase
15
+ end
16
+
17
+ def fixture_file(filename)
18
+ return '' if filename == ''
19
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
20
+ File.read(file_path)
21
+ end
22
+
23
+ def upcoming_url(url)
24
+ url =~ /^http/ ? url : "upcoming.yahooapis.com:80/services/rest#{url}"
25
+ end
26
+
27
+ def stub_get(url, filename, status=nil)
28
+ options = {:body => fixture_file(filename)}
29
+ options.merge!({:status => status}) unless status.nil?
30
+
31
+ FakeWeb.register_uri(:get, upcoming_url(url), options)
32
+ end
33
+
34
+ def stub_post(url, filename)
35
+ FakeWeb.register_uri(:post, upcoming_url(url), :body => fixture_file(filename))
36
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class AuthTest < Test::Unit::TestCase
4
+ include Upcoming
5
+
6
+ context "when using the authentication API" do
7
+ setup do
8
+ Upcoming.api_key = 'OU812'
9
+ end
10
+
11
+ should "retrieve a token from the site" do
12
+ stub_get "http://upcoming.yahooapis.com/services/rest/?method=auth.getToken&frob=123456&api_key=OU812&format=json", 'token.json'
13
+ token = Upcoming::Auth.token(123456)
14
+ token.token.should == "1234567890123456789012345678901234467890"
15
+ token.user_id.should == 674
16
+ end
17
+
18
+ should "check a token based on the 40-digit token code" do
19
+ stub_get "http://upcoming.yahooapis.com/services/rest/?method=auth.checkToken&token=123456&api_key=OU812&format=json", 'token.json'
20
+ token = Upcoming::Auth.check_token(123456)
21
+ token.token.should == "1234567890123456789012345678901234467890"
22
+ token.user_id.should == 674
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CategoryTest < Test::Unit::TestCase
4
+ include Upcoming
5
+
6
+ context "when using the category API" do
7
+ setup do
8
+ Upcoming.api_key = 'OU812'
9
+ end
10
+
11
+ should "retrieve a list of valid event categories" do
12
+ stub_get "http://upcoming.yahooapis.com/services/rest/?method=category.getList&api_key=OU812&format=json", 'categories.json'
13
+ categories = Upcoming::Category.list
14
+ categories.first.name.should == 'Music'
15
+ categories.last.id.should == 13
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CountryTest < Test::Unit::TestCase
4
+ include Upcoming
5
+
6
+ context "when using the country API" do
7
+ setup do
8
+ Upcoming.api_key = 'OU812'
9
+ end
10
+
11
+ should "retrieve the details about a country" do
12
+ stub_get "http://upcoming.yahooapis.com/services/rest/?method=country.getInfo&country_id=1%2C2%2C3%2C4&api_key=OU812&format=json", 'countries.json'
13
+ countries = Upcoming::Country.info([1,2,3,4])
14
+ countries.first.code.should == 'us'
15
+ countries.last.code.should == 'de'
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,93 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class EventTest < Test::Unit::TestCase
4
+ include Upcoming
5
+
6
+ context "when using the events API" do
7
+ setup do
8
+ Upcoming.api_key = 'OU812'
9
+ end
10
+
11
+ should "retrieve info for a single event" do
12
+ stub_get "http://upcoming.yahooapis.com/services/rest/?method=event.getInfo&event_id=123456&api_key=OU812&format=json", 'event.json'
13
+ event = Upcoming::Event.info(123456).first
14
+ event.name.should == "Def Leppard Dallas TX"
15
+ event.venue_id.should == 115339
16
+ event.latitude.should == 32.7743
17
+ end
18
+
19
+ should "retrieve info for multiple events" do
20
+ stub_get "http://upcoming.yahooapis.com/services/rest/?method=event.getInfo&event_id=123456%2C654321&api_key=OU812&format=json", 'events.json'
21
+ event = Upcoming::Event.info([123456, 654321]).last
22
+ event.name.should == "Disney&#39;s A CHRISTMAS CAROL Train Tour"
23
+ event.venue_name.should == "Union Station - Amtrak"
24
+ event.ticket_free.should == 1
25
+ end
26
+
27
+ context "when authenticated" do
28
+ setup do
29
+ stub_get "http://upcoming.yahooapis.com/services/rest/?method=auth.getToken&frob=123456&api_key=OU812&format=json", 'token.json'
30
+ @token = Upcoming::Auth.token(123456)
31
+ end
32
+
33
+ should "add an event" do
34
+ stub_post "http://upcoming.yahooapis.com/services/rest/?", 'new_event.xml'
35
+ stub_get "http://upcoming.yahooapis.com/services/rest/?method=event.getInfo&event_id=1&token=1234567890123456789012345678901234467890&api_key=OU812&format=json", 'new_event.json'
36
+
37
+ event_info = Mash.new
38
+ event_info.name = "Tori Amos, Ben Folds"
39
+ event_info.venue_id = 1
40
+ event_info.category_id = 1
41
+ event_info.start_date = '2003-08-01'
42
+
43
+ event = Upcoming::Event.add(event_info, @token)
44
+ event.name.should == "Tori Amos, Ben Folds"
45
+ event.venue_id.should == 1
46
+ event.category_id.should == 1
47
+ event.start_date.year.should == 2003
48
+ end
49
+
50
+ should "add an event" do
51
+ stub_post "http://upcoming.yahooapis.com/services/rest/?", 'new_event.xml'
52
+ stub_get "http://upcoming.yahooapis.com/services/rest/?method=event.getInfo&event_id=1&token=1234567890123456789012345678901234467890&api_key=OU812&format=json", 'saved_event.json'
53
+
54
+ event_info = Mash.new
55
+ event_info.name = "Tori Amos, Ben Folds"
56
+ event_info.venue_id = 1
57
+ event_info.category_id = 1
58
+ event_info.start_date = '2003-08-01'
59
+
60
+ event = Upcoming::Event.edit(event_info, @token)
61
+ event.name.should == "Tori Amos, Ben Folds"
62
+ event.venue_id.should == 1
63
+ event.category_id.should == 1
64
+ event.start_date.year.should == 2003
65
+ event.photo_url.should == 'http://flickr.com'
66
+ end
67
+
68
+ should_eventually "tag an event" do
69
+ end
70
+
71
+ should_eventually "remove tag from an event" do
72
+
73
+ end
74
+
75
+ should_eventually "search for public events by multiple facets" do
76
+
77
+ end
78
+
79
+ should_eventually "get a watchlist for an event" do
80
+
81
+ end
82
+
83
+ should_eventually "retrieve groups watching an event " do
84
+
85
+ end
86
+
87
+ should_eventually "search for featured or popular events in a specified place" do
88
+
89
+ end
90
+ end
91
+ end
92
+
93
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: upcoming-events
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Wynn Netherland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-18 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mash
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: httparty
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.3
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: thoughtbot-shoulda
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: jeremymcanally-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"
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"
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: "0"
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: mash
77
+ type: :development
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ description: Find cool events and things to do.
86
+ email: wynn@squeejee.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.yml
99
+ - lib/upcoming.rb
100
+ - lib/upcoming/auth.rb
101
+ - lib/upcoming/category.rb
102
+ - lib/upcoming/country.rb
103
+ - lib/upcoming/event.rb
104
+ - lib/upcoming/group.rb
105
+ - lib/upcoming/metro.rb
106
+ - lib/upcoming/state.rb
107
+ - lib/upcoming/user.rb
108
+ - lib/upcoming/venue.rb
109
+ - lib/upcoming/watchlist.rb
110
+ - test/fixtures/categories.json
111
+ - test/fixtures/countries.json
112
+ - test/fixtures/event.json
113
+ - test/fixtures/events.json
114
+ - test/fixtures/new_event.json
115
+ - test/fixtures/new_event.xml
116
+ - test/fixtures/saved_event.json
117
+ - test/fixtures/tagged_event.json
118
+ - test/fixtures/token.json
119
+ - test/test_helper.rb
120
+ - test/upcoming/auth_test.rb
121
+ - test/upcoming/category_test.rb
122
+ - test/upcoming/country_test.rb
123
+ - test/upcoming/event_test.rb
124
+ has_rdoc: true
125
+ homepage: http://github.com/pengwynn/upcoming-events
126
+ licenses: []
127
+
128
+ post_install_message:
129
+ rdoc_options:
130
+ - --charset=UTF-8
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: "0"
138
+ version:
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: "0"
144
+ version:
145
+ requirements: []
146
+
147
+ rubyforge_project: upcoming-events
148
+ rubygems_version: 1.3.3
149
+ signing_key:
150
+ specification_version: 3
151
+ summary: Ruby wrapper for the Yahoo! Upcoming API
152
+ test_files:
153
+ - test/test_helper.rb
154
+ - test/upcoming/auth_test.rb
155
+ - test/upcoming/category_test.rb
156
+ - test/upcoming/country_test.rb
157
+ - test/upcoming/event_test.rb