squeejee-upcoming-events 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: squeejee-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 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Find cool events and things to do.
17
+ email: wynn@squeejee.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.markdown
25
+ files:
26
+ - .autotest
27
+ - .document
28
+ - .gitignore
29
+ - LICENSE
30
+ - README.markdown
31
+ - Rakefile
32
+ - VERSION.yml
33
+ - lib/upcoming.rb
34
+ - lib/upcoming/auth.rb
35
+ - lib/upcoming/category.rb
36
+ - lib/upcoming/country.rb
37
+ - lib/upcoming/event.rb
38
+ - lib/upcoming/group.rb
39
+ - lib/upcoming/metro.rb
40
+ - lib/upcoming/state.rb
41
+ - lib/upcoming/user.rb
42
+ - lib/upcoming/venue.rb
43
+ - lib/upcoming/watchlist.rb
44
+ - test/fixtures/categories.json
45
+ - test/fixtures/countries.json
46
+ - test/fixtures/event.json
47
+ - test/fixtures/events.json
48
+ - test/fixtures/new_event.json
49
+ - test/fixtures/new_event.xml
50
+ - test/fixtures/saved_event.json
51
+ - test/fixtures/tagged_event.json
52
+ - test/fixtures/token.json
53
+ - test/test_helper.rb
54
+ - test/upcoming/auth_test.rb
55
+ - test/upcoming/category_test.rb
56
+ - test/upcoming/country_test.rb
57
+ - test/upcoming/event_test.rb
58
+ has_rdoc: false
59
+ homepage: http://github.com/pengwynn/upcoming-events
60
+ licenses:
61
+ post_install_message:
62
+ rdoc_options:
63
+ - --charset=UTF-8
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ version:
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ version:
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.3.5
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Ruby wrapper for the Yahoo! Upcoming API
85
+ test_files:
86
+ - test/test_helper.rb
87
+ - test/upcoming/auth_test.rb
88
+ - test/upcoming/category_test.rb
89
+ - test/upcoming/country_test.rb
90
+ - test/upcoming/event_test.rb