foursquared 0.0.4 → 0.0.5

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.
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ spec/reports
8
8
  yardoc/
9
9
  *~
10
10
  Gemfile.lock
11
+ tmp/
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  # Foursquared
2
- [![Build Status](https://travis-ci.org/ronyv89/foursquared.png)](https://travis-ci.org/ronyv89/foursquared)
3
2
 
4
3
  Simple client library for Foursquare API V2 with OAuth2 authentication
5
4
  ## Installation
@@ -18,8 +17,63 @@ Or install it yourself as:
18
17
 
19
18
  ## Usage
20
19
 
21
- TODO: Write usage instructions here
20
+ ### OAuth2 Authentication
22
21
 
22
+ Foursquare OAuth2 authentication is integrated here.
23
+ First you will have to initialize a Foursquared::OAuth::Client object with the client id, client secret and the callback url
24
+
25
+ oauth_client = Foursquared::OAuth::Client.new("your_client_id", "your_client_secret", "http://yourcallbackurl")
26
+
27
+ Obtain the authentication url
28
+
29
+ auth_url = oauth_client.authorize_url
30
+
31
+ Redirect the user to the above obtained auth_url. After user gives access to your app, they will be redirected to the callback url with a 'code' parameter. Extract this code and get the access token by invoking the following method
32
+
33
+ access_token = oauth_client.get_access_token("the_extracted_code")
34
+
35
+ ### Instantiate a client
36
+
37
+ After getting the access token instantiate the Foursquared client
38
+
39
+ client = Foursquared::Client.new(:access_token => "your_acess_token")
40
+
41
+ For userless access you can skip the above step and instantiate the client with your client id and client secret.
42
+
43
+ client = Foursquared::Client.new(:client_id => "your_client_id", :client_secret => "your_client_secret")
44
+
45
+ ## Features
46
+
47
+ 1. Every response item is an object. For example, every user will be a Foursquared::Response::User.
48
+ 2. Each object will have its own actions. For example you can friend, unfriend or deny the request from a user after retrieving the user object.
49
+
50
+ ## Examples
51
+
52
+ You can always navigate to [the documentation](http://rubydoc.info/gems/foursquared/frames) for a list of all supported methods and available options.
53
+
54
+ ### Get user details
55
+
56
+ client.user(10230)
57
+
58
+ ### Get a venue details
59
+
60
+ venue = client.venue("4b2afcaaf964a5205bb324e3")
61
+
62
+ ### Checkin at a venue
63
+
64
+ You can use the above obtained Foursquared::Response::Venue object to checkin
65
+
66
+ venue.checkin(:broadcast => 'public', :ll => '36.142064,-86.816086', :shout => 'zomg coffee!1!')
67
+
68
+ You can also directly checkin at a venue providing its venue id.
69
+
70
+ client.add_checkin(:venueId => "4b2afcaaf964a5205bb324e3", :broadcast => 'public', :ll => '36.142064,-86.816086', :shout => 'zomg coffee!1!')
71
+
72
+ ## Todo
73
+
74
+ * Add more tests
75
+ * Improve documentation
76
+ * Integrate more endpoints
23
77
  ## Contributing
24
78
 
25
79
  1. Fork it
@@ -1,18 +1,11 @@
1
1
  require 'httmultiparty'
2
2
  require 'json'
3
3
  directory = File.expand_path(File.dirname(__FILE__))
4
- require 'core_ext/symbol'
5
4
  module Foursquared
6
5
  class << self
7
6
 
8
-
9
7
  attr_accessor :client_id, :client_secret, :api_version, :ssl, :access_token, :locale
10
-
11
-
12
- def configure
13
- yield self
14
- true
15
- end
8
+
16
9
  end
17
10
 
18
11
  # require 'foursquare2/campaigns'
@@ -25,6 +18,7 @@ module Foursquared
25
18
  require 'foursquared/events'
26
19
  require 'foursquared/pages'
27
20
  require 'foursquared/specials'
21
+ require 'foursquared/settings'
28
22
  require 'foursquared/tips'
29
23
  require 'foursquared/oauth/client'
30
24
  require 'foursquared/client'
@@ -24,10 +24,10 @@ module Foursquared
24
24
  # @option options [String] :llAcc Accuracy of the user's latitude and longitude, in meters
25
25
  # @option options [String] :alt Altitude of the user's location, in meters.
26
26
  # @option options [String] :altAcc Vertical accuracy of the user's location, in meters.
27
- # @return [Foursquared::Response::Checkin] A checkin object
27
+ # @return [Hash] A checkin object and the post checkin notifications
28
28
  def add_checkin options={}
29
29
  response = post("/checkins/add", options)["response"]
30
- {:checkin => Foursquared::Response::Checkin.new(self, response["checkin"]), :notifications => Foursquared::Response::Notifications.new(self, response["notifications"])}
30
+ {:checkin => Foursquared::Response::Checkin.new(self, response["checkin"]), :notifications => response["notifications"]}
31
31
  end
32
32
 
33
33
  # Recent checkins by friends
@@ -45,9 +45,10 @@ module Foursquared
45
45
  # @param [String] checkin_id The ID of the checkin to get likes for.
46
46
  # @return [Hash] A count and groups of users who like this checkin
47
47
  def checkin_likes checkin_id
48
- response = get("/checkins/#{checkin_id}/likes")["response"]
49
- @likes = response["likes"]
50
- @likes.groups.each{|group| group["items"].map!{|item|Foursquared::Response::User.new(self, item)}}
48
+ @likes = get("/checkins/#{checkin_id}/likes")["response"]["likes"]
49
+ @likes["groups"].each do |group|
50
+ group["items"].map!{|item|Foursquared::Response::User.new(self, item)}
51
+ end
51
52
  @likes
52
53
  end
53
54
 
@@ -13,16 +13,22 @@ module Foursquared
13
13
  include Badges
14
14
  include Events
15
15
  include Pages
16
+ include Specials
17
+ include Settings
18
+ include Tips
16
19
  base_uri 'https://api.foursquare.com/v2/'
17
20
  format :json
18
-
21
+
22
+ attr_accessor :client_id, :client_secret, :access_token
19
23
  def initialize credentials={}
20
-
21
- if credentials[:access_token]
22
- self.class.default_params :oauth_token => credentials[:access_token]
23
- elsif credentials[:client_id] and credentials[:client_secret]
24
- self.class.default_params :client_id => credentials[:client_id]
25
- self.class.default_params :client_secret => credentials[:client_secret]
24
+ @client_id = credentials[:client_id]
25
+ @client_secret = credentials[:client_secret]
26
+ @access_token = credentials[:access_token]
27
+ if @access_token
28
+ self.class.default_params :oauth_token => @access_token
29
+ elsif @client_id and @client_secret
30
+ self.class.default_params :client_id => @client_id
31
+ self.class.default_params :client_secret => @client_secret
26
32
  else
27
33
  raise "Must provide access_token or client_id and client_secret"
28
34
  end
@@ -14,5 +14,17 @@ module Foursquared
14
14
  response = get("/events/categories")["response"]
15
15
  response["categories"].collect{|category| Foursquared::Response::Category.new(self, category)}
16
16
  end
17
+
18
+ # Create an event for a venue that you manage.
19
+ # @param [Hash] options
20
+ # @option options [String] :venueId The id of the venue where the event is being held.
21
+ # @option options [String] :name The name of the event
22
+ # @option options [String] :start Time when the event is scheduled to start, in seconds since Unix epoch.
23
+ # @option options [String] :end Time when the event is scheduled to end, in seconds since Unix epoch.
24
+ def add_event
25
+ response = post("/events/categories")["response"]
26
+ Foursquared::Response::Event.new(self, response["event"])
27
+ end
28
+
17
29
  end
18
30
  end
@@ -28,6 +28,7 @@ module Foursquared
28
28
 
29
29
  # Step 2: Get access token after authorizing user
30
30
  # @param [String] code The value extracted from the callback url param 'code'
31
+ # @return [String] the access token
31
32
  def get_access_token code
32
33
  token = oauth_client.auth_code.get_token(code, :redirect_uri => callback_url)
33
34
  @access_token = token.token
@@ -3,21 +3,73 @@ module Foursquared
3
3
  # Event response
4
4
  class Event
5
5
  attr_reader :client, :response
6
+
6
7
  def initialize client, response
7
8
  @client = client
8
9
  @response = response
9
10
  end
10
11
 
11
- [:id, :name, :url, :stats].each do |method_name|
12
- define_method method_name do
13
- response[method_name.to_s] if response
14
- end
12
+
13
+ # The ID of the event
14
+ # @return [String]
15
+ def id
16
+ response["id"]
15
17
  end
16
18
 
17
- [:venueId, :foreignIds, :categories, :allDay, :timeZone, :unlockMessage].each do |method_name|
18
- define_method method_name.to_usym do
19
- response[method_name.to_s] if response[method_name.to_s]
20
- end
19
+ # The name of the event
20
+ # @return [String]
21
+ def name
22
+ response["name"]
23
+ end
24
+
25
+ # The website for the event
26
+ # @return [String]
27
+ def url
28
+ response["url"]
29
+ end
30
+
31
+ # The stats for the event
32
+ # @return [String]
33
+ def stats
34
+ response["stats"]
35
+ end
36
+
37
+ # The ID of the venue of the event
38
+ # @return [String]
39
+ def venue_id
40
+ response["venueId"]
41
+ end
42
+
43
+ # The count of ids of this event in third-party services, plus items, an array of domain, the third party provider, and id, the id in their system.
44
+ # @return [Hash]
45
+ def foreign_ids
46
+ response["foreignIds"]
47
+ end
48
+
49
+ # The categories that have been applied to this event
50
+ # @return [Array<Foursquared::Response::Category>]
51
+ def categories
52
+ @categories = response["categories"]
53
+ @categories.map!{|category| Foursquared::Response::Category.new(client, category)} if @categories
54
+ @categories
55
+ end
56
+
57
+ # Whether the event happens throughout the day
58
+ # @return [Boolean]
59
+ def all_day?
60
+ response["allDay"]
61
+ end
62
+
63
+ # The time zone for the event
64
+ # @return [String]
65
+ def time_zone
66
+ response["timeZone"]
67
+ end
68
+
69
+ # The unlock message for the checkin at the event
70
+ # @return [String]
71
+ def unlock_message
72
+ response["unlockMessage"]
21
73
  end
22
74
 
23
75
  # The time at which the event starts
@@ -247,6 +247,22 @@ module Foursquared
247
247
  response["specialsNearby"].map{|special| Foursquared::Response::Special.new(client, special)} if response["specialsNearby"]
248
248
  end
249
249
 
250
+ # Checkin at this venue
251
+ # @param [Hash] options
252
+ # @option options [String] :eventId The event the user is checking in to.
253
+ # @option options [String] :shout A message about your check-in
254
+ # @option options [String] :mentions Semicolon-delimited list of mentions
255
+ # @option options [String] :broadcast Who to broadcast this check-in to
256
+ # @option options [String] :ll Latitude and longitude of the user's location.
257
+ # @option options [String] :llAcc Accuracy of the user's latitude and longitude, in meters
258
+ # @option options [String] :alt Altitude of the user's location, in meters.
259
+ # @option options [String] :altAcc Vertical accuracy of the user's location, in meters.
260
+ # @return [Hash] A checkin object and the post checkin notifications
261
+ def checkin options={}
262
+ options.merge!({:venueId => id})
263
+ checkin_response = post("/checkins/add", options)["response"]
264
+ {:checkin => Foursquared::Response::Checkin.new(self, checkin_response["checkin"]), :notifications => response["notifications"]}
265
+ end
250
266
  end
251
267
  end
252
268
  end
@@ -1,4 +1,4 @@
1
1
  module Foursquared
2
2
  # The gem version
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
@@ -57,26 +57,11 @@ describe Foursquared::Badges do
57
57
 
58
58
  subject { foursquared_test_client }
59
59
 
60
- before(:each) do
61
- stub_request(:get, "https://api.foursquare.com/v2/users/self/badges?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").to_return(:status => 200, :body => user_badges.to_json, :headers => {})
62
- stub_request(:get, "https://api.foursquare.com/v2/badges/4f7a7d3ae4b02f1b2c869efb?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").
60
+ describe "#badge" do
61
+ it "should return the badge with the given badge ID" do
62
+ stub_request(:get, "https://api.foursquare.com/v2/badges/4f7a7d3ae4b02f1b2c869efb?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").
63
63
  to_return(:status => 200, :body => badge.to_json, :headers => {})
64
- @user_badges = subject.user_badges("self")
65
- end
66
- describe "#user_badges" do
67
- describe "sets" do
68
- it "should give the sets of badge types" do
69
- @user_badges["sets"]["groups"].should each { |group|
70
- group.should be_a(Foursquared::Response::BadgeGroup)
71
- }
72
- end
73
- end
74
- describe "badges" do
75
- it "should give the badges' details" do
76
- @user_badges["badges"].keys.should each {|badge_id|
77
- @user_badges["badges"][badge_id].should be_a(Foursquared::Response::Badge)
78
- }
79
- end
64
+ subject.badge("4f7a7d3ae4b02f1b2c869efb").should be_a(Foursquared::Response::Badge)
80
65
  end
81
66
  end
82
67
  end
@@ -0,0 +1,113 @@
1
+ require 'spec_helper'
2
+ describe Foursquared::Checkins do
3
+
4
+ let(:checkin) do
5
+ YAML.load(%{
6
+ meta:
7
+ code: 200
8
+ notifications: []
9
+ response:
10
+ checkin:
11
+ id: "4d627f6814963704dc28ff94"
12
+ createdAt: 1298300776
13
+ type: "checkin"
14
+ shout: "Another one of these days. #snow"
15
+ timeZoneOffset: -300
16
+ user:
17
+ id: "32"
18
+ firstName: "Dens"
19
+ gender: "male"
20
+ photo:
21
+ prefix: "https://irs0.4sqi.net/img/user/"
22
+ suffix: "/32_1239135232.jpg"
23
+ venue:
24
+ id: "408c5100f964a520c6f21ee3"
25
+ name: "Tompkins Square Park"
26
+
27
+ })
28
+ end
29
+
30
+ let(:recent_checkins) do
31
+ YAML.load(%{
32
+ meta:
33
+ code: 200
34
+ response:
35
+ recent:
36
+ - id: "50ec9b33e4b0b63dc59108bb"
37
+ createdAt: 1357683507
38
+ type: "checkin"
39
+ shout: "Shadow's photoshoot"
40
+ timeZoneOffset: 330
41
+ - id: "50ec7ad7e4b0beb130e3c6fb"
42
+ createdAt: 1357675223
43
+ type: "checkin"
44
+ timeZoneOffset: 330
45
+ })
46
+ end
47
+
48
+ let(:checkin_likes) do
49
+ YAML.load(%{
50
+ meta:
51
+ code: 200
52
+ response:
53
+ likes:
54
+ count: 2
55
+ groups:
56
+ - type: "others"
57
+ count: 2
58
+ items:
59
+ - id: "4006236"
60
+ firstName: "Shane"
61
+ lastName: "O."
62
+ gender: "male"
63
+ photo:
64
+ prefix: "https://irs3.4sqi.net/img/user/"
65
+ suffix: "/OHXZCLCMRAGXPV3S.jpg"
66
+ - id: "591008"
67
+ firstName: "mi1ky"
68
+ lastName: "L."
69
+ gender: "female"
70
+ photo:
71
+ prefix: "https://irs1.4sqi.net/img/user/"
72
+ suffix: "/UX1JTWSNWY5YV1PS.jpg"
73
+ summary: "2 likes"
74
+ })
75
+ end
76
+ subject { foursquared_test_client }
77
+
78
+ describe "#add_checkin" do
79
+ it "should add a new checkin" do
80
+ stub_request(:post, "https://api.foursquare.com/v2/checkins/add?oauth_token=TestToken").
81
+ with(:body => "venueId=408c5100f964a520c6f21ee3&v=#{Time.now.strftime("%Y%m%d")}").to_return(:status => 200, :body => checkin.to_json, :headers => {})
82
+ subject.add_checkin({:venueId => "408c5100f964a520c6f21ee3"})[:checkin].should be_a(Foursquared::Response::Checkin)
83
+ end
84
+ end
85
+
86
+ describe "#recent_checkins" do
87
+ it "should return the recent checkins for the acting user" do
88
+ stub_request(:get, "https://api.foursquare.com/v2/checkins/recent?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").to_return(:status => 200, :body => recent_checkins.to_json, :headers => {})
89
+ subject.recent_checkins.should each {|checkin|
90
+ checkin.should be_a Foursquared::Response::Checkin
91
+ }
92
+ end
93
+ end
94
+
95
+ describe "#checkin_likes" do
96
+ before :each do
97
+ stub_request(:get, "https://api.foursquare.com/v2/checkins/502bcde16de4146b7f104ac6/likes?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").to_return(:status => 200, :body => checkin_likes.to_json, :headers => {})
98
+ end
99
+
100
+ it "should have count, groups and a summary" do
101
+ subject.checkin_likes("502bcde16de4146b7f104ac6").keys.should ~ ["summary", "count", "groups"]
102
+ end
103
+
104
+ it "should have give groups of users" do
105
+ subject.checkin_likes("502bcde16de4146b7f104ac6")["groups"].should each { |group|
106
+ group["items"].should each {|item|
107
+ item.should be_a Foursquared::Response::User
108
+ }
109
+ }
110
+ end
111
+ end
112
+
113
+ end
@@ -31,8 +31,14 @@ describe Foursquared::Response::Checkin do
31
31
  prefix: "https://irs3.4sqi.net/img/general/"
32
32
  suffix: "/UBTEFRRMLYOHHX4RWHFTGQKSDMY14A1JLHURUTG5VUJ02KQ0.jpg"
33
33
  likes:
34
- count: 0
35
- groups: []
34
+ count: 1
35
+ groups:
36
+ - type: "others"
37
+ count: 1
38
+ items:
39
+ - id: "141623"
40
+ firstName: "chad"
41
+ lastName: "g."
36
42
  like: false
37
43
  score:
38
44
  - total: 1
@@ -74,8 +80,6 @@ describe Foursquared::Response::Checkin do
74
80
 
75
81
  stub_request(:get, "https://api.foursquare.com/v2/checkins/4d627f6814963704dc28ff94?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").
76
82
  to_return(:status => 200, :body => checkin.to_json, :headers => {})
77
- stub_request(:get, "https://api.foursquare.com/v2/checkins/4d627f6814963704dc28ff94/likes?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").
78
- to_return(:status => 200, :body => likes.to_json, :headers => {})
79
83
  end
80
84
 
81
85
  it "should get checkin id" do
@@ -86,14 +90,31 @@ describe Foursquared::Response::Checkin do
86
90
  subject.venue.should be_a(Foursquared::Response::Venue)
87
91
  end
88
92
 
89
- it "should return the likes for the checkin" do
90
- subject.likes["groups"].should each { |group|
91
- group["items"].should be_empty_or_array_of_users
92
- }
93
+ describe "likes for the checkin" do
94
+ describe "#full_likes" do
95
+ it "should get the full likes for the checkin" do
96
+ stub_request(:get, "https://api.foursquare.com/v2/checkins/4d627f6814963704dc28ff94/likes?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").to_return(:status => 200, :body => likes.to_json, :headers => {})
97
+ subject.full_likes["groups"].should each { |group|
98
+ group["items"].should each { |item|
99
+ item.should be_a(Foursquared::Response::User)
100
+ }
101
+ }
102
+ end
103
+ end
104
+
105
+ describe "#likes" do
106
+ it "should return the likes as specified in the checkin response" do
107
+ subject.likes["groups"].should each { |group|
108
+ group["items"].should each { |item|
109
+ item.should be_a(Foursquared::Response::User)
110
+ }
111
+ }
112
+ end
113
+ end
93
114
  end
94
115
 
95
116
  it "should return the photos for the checkin" do
96
- subject.photos.should each { |item|
117
+ subject.photos["items"].should each { |item|
97
118
  item.should be_a Foursquared::Response::Photo
98
119
  }
99
120
  end
@@ -3,7 +3,6 @@ require 'foursquared/response/user'
3
3
  require 'foursquared/response/list'
4
4
 
5
5
  require 'foursquared/client'
6
- require 'core_ext/symbol'
7
6
  describe Foursquared::Response::User do
8
7
  let(:me) do
9
8
  YAML.load(%{
@@ -3,7 +3,6 @@ require 'foursquared/response/user'
3
3
  require 'foursquared/response/list'
4
4
 
5
5
  require 'foursquared/client'
6
- require 'core_ext/symbol'
7
6
 
8
7
  describe Foursquared::Response::Venue do
9
8
  let(:venue) do
@@ -1,8 +1,4 @@
1
- # require 'foursquared/users'
2
- # require 'foursquared/lists'
3
- # require 'foursquared/venues'
4
- # require 'foursquared/photos'
5
- # require 'foursquared/client'
1
+
6
2
  require 'spec_helper'
7
3
  require 'pp'
8
4
  describe Foursquared::Users do
@@ -1,6 +1,6 @@
1
1
  require "simplecov"
2
2
  require "simplecov-rcov"
3
- require 'foursquared'
3
+
4
4
  require 'webmock/rspec'
5
5
  require 'rspec_multi_matchers'
6
6
 
@@ -10,8 +10,9 @@ SimpleCov.start do
10
10
  add_filter "spec"
11
11
  end if ENV["COVERAGE"]
12
12
 
13
+ require 'foursquared'
13
14
  def foursquared_test_client
14
- Foursquared::Client.new("TestToken")
15
+ Foursquared::Client.new({:access_token => "TestToken"})
15
16
  end
16
17
 
17
18
  class Array
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foursquared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-07 00:00:00.000000000 Z
12
+ date: 2013-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httmultiparty
@@ -250,7 +250,6 @@ files:
250
250
  - README.md
251
251
  - Rakefile
252
252
  - foursquared.gemspec
253
- - lib/core_ext/symbol.rb
254
253
  - lib/foursquared.rb
255
254
  - lib/foursquared/badges.rb
256
255
  - lib/foursquared/checkins.rb
@@ -288,7 +287,6 @@ files:
288
287
  - spec/foursquared/response/badge_spec.rb
289
288
  - spec/foursquared/response/category_spec.rb
290
289
  - spec/foursquared/response/checkin_spec.rb
291
- - spec/foursquared/response/event_category_spec.rb
292
290
  - spec/foursquared/response/event_spec.rb
293
291
  - spec/foursquared/response/list_spec.rb
294
292
  - spec/foursquared/response/photo_spec.rb
@@ -332,7 +330,6 @@ test_files:
332
330
  - spec/foursquared/response/badge_spec.rb
333
331
  - spec/foursquared/response/category_spec.rb
334
332
  - spec/foursquared/response/checkin_spec.rb
335
- - spec/foursquared/response/event_category_spec.rb
336
333
  - spec/foursquared/response/event_spec.rb
337
334
  - spec/foursquared/response/list_spec.rb
338
335
  - spec/foursquared/response/photo_spec.rb
@@ -1,7 +0,0 @@
1
- # Ruby's builtin Symbol class
2
- class Symbol
3
- # Convert camel case symbol to snake case symbol
4
- def to_usym
5
- to_s.gsub(/(.)([A-Z])/,'\1_\2').downcase.to_sym
6
- end
7
- end
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
- require 'foursquared/response/event_category'
3
-
4
- describe Foursquared::Response::EventCategory do
5
-
6
- let(:event_category) do
7
- YAML.load(%{
8
- id: "4dfb90c6bd413dd705e8f897"
9
- name: "Movies"
10
- pluralName: "Movies"
11
- shortName: "Movie"
12
- icon:
13
- prefix: "https://foursquare.com/img/categories_v2/arts_entertainment/movietheater_"
14
- suffix: ".png"
15
- categories:
16
- - id: "4e132f48bd41026cd50e8f8e"
17
- name: "Baseball Games"
18
- pluralName: "Baseball Games"
19
- shortName: "Baseball"
20
- icon:
21
- prefix: "https://foursquare.com/img/categories_v2/arts_entertainment/stadium_baseball_"
22
- suffix: ".png"
23
- categories: []
24
- }
25
- )
26
- end
27
-
28
- subject {Foursquared::Response::EventCategory.new(event_category)}
29
-
30
- describe "#icon" do
31
- it "should have prefix, suffix and urls" do
32
- subject.icon.keys.should ~ ["urls", "prefix", "suffix", ]
33
- end
34
-
35
- describe "urls" do
36
- it "should have urls for 32x32, 64x64 and 256x256 icons" do
37
- subject.icon["urls"].keys.should ~ ["32x32", "64x64", "256x256"]
38
- end
39
- end
40
-
41
- end
42
-
43
- it "should give the sub categories of the category" do
44
- subject.categories.should each { |category|
45
- category.should be_a(Foursquared::Response::EventCategory)
46
- }
47
- end
48
- end