koala 3.0.0.beta2 → 3.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18d5d8c95bece65d5f4bab2640d75645dc5fb343
4
- data.tar.gz: 6ec125b20dea63584e6dd69fc02ecd08f0800ce2
3
+ metadata.gz: 2ed893e5254cc1e5b3007301dc847bd025b592c1
4
+ data.tar.gz: 3ad942cb33ac7e7a36304250dd3cc7c6b36712f8
5
5
  SHA512:
6
- metadata.gz: 31a10322d86c4c49bd877ad5891cde67db496e506c6b8936d8cf3e67b6bc82e6faed1fe1e93f02dcd123ea8aee77026adc681a3b197006335e7d2f8aac40d968
7
- data.tar.gz: f8d69365d42baf15acead1fcc5e38e334084dc49539358189aee046bf611d9c7761ec4ffeac690b07d3a647116ef81ac1e0fdfa2bc1d11010c5ae30dc239a189
6
+ metadata.gz: 6d4cac2752f9b72f7c1c1cf4632dfaf10b7ba9b72753699540587e3b636b35fde33ca2035b47e468d51d59c490ce9dcbc624618d5eb10e1da3b5fc4c2a11f034
7
+ data.tar.gz: 4728dfc6777f3e1b29d2dcab6608c9a40f24e8ee8a2136940ed2b463846ddcffa9c0f0afd96a1ab8d21b2d2c0203bdde5ddfe0c4a8ee1d250650921361343c90
@@ -0,0 +1,23 @@
1
+ Thanks for using Koala! Sorry you've run into an issue 😓 Here are some questions to help get things figured out as quickly as possible.
2
+
3
+ You don't have to fill this all out -- it's more of a guide. If in doubt, delete any sections that aren't relevant and open the issue. I want to help.
4
+
5
+ [ ] This is a Koala bug/issue/documentation problem.
6
+
7
+ Koala is a labor of love both from me and from the awesome community members who answer questions here. Much as we'd love to be able to help with everything, I have to focus my time on issues with the gem itself and can't help with questions on how to _use_ Facebook. (Plus, Facebook is huge!)
8
+
9
+ If you have questions about using the Facebook API, [facebook.stackoverflow.com](http://facebook.stackoverflow.com) is a great resource.
10
+
11
+ For code issues:
12
+
13
+ [ ] What I'm doing works on the [Graph API explorer](https://developers.facebook.com/tools/explorer/)/curl/another tool.
14
+
15
+ Seeing an example of what works helps diagnose what doesn't work.
16
+
17
+ [ ] I'm using the newest version
18
+
19
+ [ ] Here's code to replicate the issue:
20
+
21
+ Obviously not all code can be shared -- feel free to put variables in place of any sensitive information and describe what should be used to replicate it.
22
+
23
+ Thanks for submitting an issue! Looking forward to working with you to figure it out.
@@ -0,0 +1,9 @@
1
+ Thanks for submitting a pull request to Koala! A huge portion of the gem has been built by awesome people (like you) from the Ruby community.
2
+
3
+ Here are a few things that will help get your pull request merged in quickly. None of this is required -- you can delete anything not relevant. If in doubt, open the PR! I want to help.
4
+
5
+ [ ] My PR has tests and they pass!
6
+ [ ] The live tests pass for my changes (`LIVE=true rspec` -- unrelated failures are okay).
7
+ [ ] The PR is based on the most recent master commit and has no merge conflicts.
8
+
9
+ If you have any questions, feel free to open an issue or comment on your PR!
@@ -1,6 +1,11 @@
1
- v3.0.0
1
+ v3.0.0 (not released yet)
2
2
  ======
3
3
 
4
+ Most users should not see any difference upgrading from 2.x to 3.0. Most of the changes are
5
+ internal to how requests go from a graph method (like `get_connections`) through the API to the
6
+ HTTP layer and back. If you're not using API#api or HTTPService.make_request directly, upgrading
7
+ should (in theory) require no code changes. (Let me know if you run into any issues.)
8
+
4
9
  **Key breaking changes:**
5
10
 
6
11
  * Koala now requires Ruby 2.1+ (or equivalent for JRuby, etc.)
@@ -13,8 +18,15 @@ v3.0.0
13
18
  * API#search now requires a "type"/:type argument, matching Facebook's behavior (improving their
14
19
  cryptic error message)
15
20
 
21
+ New features:
22
+
23
+ * Koala now supports global configuration for tokens, secrets, etc! See the readme.
24
+ * GraphCollection now exposes #headers, allowing access to etag/rate limiting/etc. info (thanks,
25
+ pawandubey and jessieay!) (#589)
26
+
16
27
  Updated features:
17
28
 
29
+ * Koala.config now uses a dedicated Koala::Configuration object
18
30
  * TestUser#befriend will provide the appsecret_proof if a secret is set (thanks, kwasimensah!)
19
31
  * API#search now requires an object type parameter to be included, matching Facebook's API (#575)
20
32
 
@@ -40,7 +52,11 @@ Testing improvements:
40
52
 
41
53
  * Fixed a bunch of failing mocked specs
42
54
 
43
- v2.5.0
55
+ Others:
56
+
57
+ * Added an issue and pull request template
58
+
59
+ v2.5.0 (2017-02-17)
44
60
  ======
45
61
 
46
62
  New features:
@@ -55,7 +71,7 @@ Internal improvements:
55
71
 
56
72
  * Remove MultiJson dependency (thanks, sakuro!)
57
73
 
58
- v2.4.0
74
+ v2.4.0 (2016-07-08)
59
75
  ======
60
76
 
61
77
  **Note:** Koala is no longer officially supported on Ruby 1.9.3 (which was [end-of-lifed back in
@@ -78,7 +94,7 @@ Testing improvements:
78
94
  * Test Koala against Ruby 2.3.0 (thanks, thedrow!)
79
95
 
80
96
 
81
- v2.3.0
97
+ v2.3.0 (2016-04-10)
82
98
  ======
83
99
 
84
100
  Updated features:
@@ -99,7 +115,7 @@ Testing improvements:
99
115
  * Removed pended specs that were no longer relevant
100
116
  * Improved https regex in test suite (thanks, lucaskds!)
101
117
 
102
- v2.2.0
118
+ v2.2.0 (2015-08-11)
103
119
  ======
104
120
 
105
121
  Updated features:
@@ -14,6 +14,7 @@ require 'koala/test_users'
14
14
  require 'koala/http_service'
15
15
 
16
16
  # miscellaneous
17
+ require 'koala/configuration'
17
18
  require 'koala/utils'
18
19
  require 'koala/version'
19
20
  require 'ostruct'
@@ -37,14 +38,10 @@ module Koala
37
38
  end
38
39
 
39
40
  # Allows you to control various Koala configuration options.
40
- # Notable options:
41
- # * server endpoints: you can override any or all the server endpoints
42
- # (see HTTPService::DEFAULT_SERVERS) if you want to run requests through
43
- # other servers.
44
- # * api_version: controls which Facebook API version to use (v1.0, v2.0,
45
- # etc)
41
+ # NOTE: this is not currently threadsafe.
42
+ # See Koala::Configuration.
46
43
  def config
47
- @config ||= OpenStruct.new(HTTPService::DEFAULT_SERVERS)
44
+ @config ||= Configuration.new
48
45
  end
49
46
 
50
47
  # Used for testing.
@@ -15,7 +15,7 @@ module Koala
15
15
  # https://developers.facebook.com/docs/graph-api/securing-requests/)
16
16
  # @note If no access token is provided, you can only access some public information.
17
17
  # @return [Koala::Facebook::API] the API client
18
- def initialize(access_token = nil, app_secret = nil)
18
+ def initialize(access_token = Koala.config.access_token, app_secret = Koala.config.app_secret)
19
19
  @access_token = access_token
20
20
  @app_secret = app_secret
21
21
  end
@@ -55,7 +55,7 @@ module Koala
55
55
  http_component == :response ? response : response.send(http_component)
56
56
  else
57
57
  # turn this into a GraphCollection if it's pageable
58
- API::GraphCollection.evaluate(response.data, self)
58
+ API::GraphCollection.evaluate(response, self)
59
59
  end
60
60
 
61
61
  # now process as appropriate for the given call (get picture header, etc.)
@@ -1,5 +1,5 @@
1
- require 'koala/api'
2
- require 'koala/api/batch_operation'
1
+ require "koala/api"
2
+ require "koala/api/batch_operation"
3
3
 
4
4
  module Koala
5
5
  module Facebook
@@ -19,7 +19,7 @@ module Koala
19
19
 
20
20
  # Enqueue a call into the batch for later processing.
21
21
  # See API#graph_call
22
- def graph_call(path, args = {}, verb = 'get', options = {}, &post_processing)
22
+ def graph_call(path, args = {}, verb = "get", options = {}, &post_processing)
23
23
  # normalize options for consistency
24
24
  options = Koala::Utils.symbolize_hash(options)
25
25
 
@@ -40,32 +40,26 @@ module Koala
40
40
  return [] if batch_calls.empty?
41
41
 
42
42
  # Turn the call args collected into what facebook expects
43
- args = { 'batch' => batch_args }
43
+ args = {"batch" => batch_args}
44
44
  batch_calls.each do |call|
45
45
  args.merge! call.files || {}
46
46
  end
47
47
 
48
- original_api.graph_call('/', args, 'post', http_options, &handle_response)
49
- end
50
-
51
- def handle_response
52
- lambda do |response|
48
+ original_api.graph_call("/", args, "post", http_options) do |response|
53
49
  raise bad_response if response.nil?
54
- response.map(&generate_results)
50
+ generate_results(response)
55
51
  end
56
52
  end
57
53
 
58
- def generate_results
54
+ def generate_results(response)
59
55
  index = 0
60
- lambda do |call_result|
61
- batch_op = batch_calls[index]; index += 1
56
+ response.map do |call_result|
57
+ batch_op = batch_calls[index]
58
+ index += 1
62
59
  post_process = batch_op.post_processing
63
60
 
64
61
  # turn any results that are pageable into GraphCollections
65
- result = GraphCollection.evaluate(
66
- result_from_response(call_result, batch_op),
67
- original_api
68
- )
62
+ result = result_from_response(call_result, batch_op)
69
63
 
70
64
  # and pass to post-processing callback if given
71
65
  if post_process
@@ -78,34 +72,34 @@ module Koala
78
72
 
79
73
  def bad_response
80
74
  # Facebook sometimes reportedly returns an empty body at times
81
- BadFacebookResponse.new(200, '', 'Facebook returned an empty body')
75
+ BadFacebookResponse.new(200, "", "Facebook returned an empty body")
82
76
  end
83
77
 
84
78
  def result_from_response(response, options)
85
79
  return nil if response.nil?
86
80
 
87
- headers = coerced_headers_from_response(response)
81
+ headers = headers_from_response(response)
88
82
  error = error_from_response(response, headers)
89
83
  component = options.http_options[:http_component]
90
84
 
91
- error || result_from_component({
92
- :component => component,
93
- :response => response,
94
- :headers => headers
95
- })
85
+ error || desired_component(
86
+ component: component,
87
+ response: response,
88
+ headers: headers
89
+ )
96
90
  end
97
91
 
98
- def coerced_headers_from_response(response)
99
- headers = response.fetch('headers', [])
92
+ def headers_from_response(response)
93
+ headers = response.fetch("headers", [])
100
94
 
101
- headers.each_with_object({}) do |h, memo|
102
- memo.merge! h.fetch('name') => h.fetch('value')
95
+ headers.inject({}) do |compiled_headers, header|
96
+ compiled_headers.merge(header.fetch("name") => header.fetch("value"))
103
97
  end
104
98
  end
105
99
 
106
100
  def error_from_response(response, headers)
107
- code = response['code']
108
- body = response['body'].to_s
101
+ code = response["code"]
102
+ body = response["body"].to_s
109
103
 
110
104
  GraphErrorChecker.new(code, body, headers).error_if_appropriate
111
105
  end
@@ -121,21 +115,19 @@ module Koala
121
115
  def json_body(response)
122
116
  # quirks_mode is needed because Facebook sometimes returns a raw true or false value --
123
117
  # in Ruby 2.4 we can drop that.
124
- JSON.parse(response.fetch('body'), quirks_mode: true)
118
+ JSON.parse(response.fetch("body"), quirks_mode: true)
125
119
  end
126
120
 
127
- def result_from_component(options)
128
- component = options.fetch(:component)
129
- response = options.fetch(:response)
130
- headers = options.fetch(:headers)
121
+ def desired_component(component:, response:, headers:)
122
+ result = Koala::HTTPService::Response.new(response['status'], response['body'], headers)
131
123
 
132
124
  # Get the HTTP component they want
133
125
  case component
134
- when :status then response['code'].to_i
126
+ when :status then response["code"].to_i
135
127
  # facebook returns the headers as an array of k/v pairs, but we want a regular hash
136
128
  when :headers then headers
137
129
  # (see note in regular api method about JSON parsing)
138
- else json_body(response)
130
+ else GraphCollection.evaluate(result, original_api)
139
131
  end
140
132
  end
141
133
 
@@ -16,30 +16,41 @@ module Koala
16
16
  attr_reader :api
17
17
  # The entire raw response from Facebook.
18
18
  attr_reader :raw_response
19
+ # The headers from the Facebook response
20
+ attr_reader :headers
19
21
 
20
22
  # Initialize the array of results and store various additional paging-related information.
21
23
  #
22
- # @param response the response from Facebook (a hash whose "data" key is an array)
24
+ # @param [Koala::HTTPService::Response] response object wrapping the raw Facebook response
23
25
  # @param api the Graph {Koala::Facebook::API API} instance to use to make calls
24
26
  # (usually the API that made the original call).
25
27
  #
26
28
  # @return [Koala::Facebook::API::GraphCollection] an initialized GraphCollection
27
29
  # whose paging, summary, raw_response, and api attributes are populated.
28
30
  def initialize(response, api)
29
- super response["data"]
30
- @paging = response["paging"]
31
- @summary = response["summary"]
32
- @raw_response = response
31
+ super response.data["data"]
32
+ @paging = response.data["paging"]
33
+ @summary = response.data["summary"]
34
+ @raw_response = response.data
33
35
  @api = api
36
+ @headers = response.headers
34
37
  end
35
38
 
36
39
  # @private
37
40
  # Turn the response into a GraphCollection if they're pageable;
38
- # if not, return the original response.
41
+ # if not, return the data of the original response.
39
42
  # The Ads API (uniquely so far) returns a hash rather than an array when queried
40
43
  # with get_connections.
41
44
  def self.evaluate(response, api)
42
- response.is_a?(Hash) && response["data"].is_a?(Array) ? self.new(response, api) : response
45
+ return nil if response.nil?
46
+
47
+ is_pageable?(response) ? self.new(response, api) : response.data
48
+ end
49
+
50
+ # response will always be an instance of Koala::HTTPService::Response
51
+ # since that is what we get from Koala::Facebook::API#api
52
+ def self.is_pageable?(response)
53
+ response.data.is_a?(Hash) && response.data["data"].is_a?(Array)
43
54
  end
44
55
 
45
56
  # Retrieve the next page of results.
@@ -0,0 +1,49 @@
1
+ # Global configuration for Koala.
2
+ class Koala::Configuration
3
+ # The default access token to be used if none is otherwise supplied.
4
+ attr_accessor :access_token
5
+
6
+ # The default app secret value to be used if none is otherwise supplied.
7
+ attr_accessor :app_secret
8
+
9
+ # The default application ID to use if none is otherwise supplied.
10
+ attr_accessor :app_id
11
+
12
+ # The default app access token to be used if none is otherwise supplied.
13
+ attr_accessor :app_access_token
14
+
15
+ # The default API version to use if none is otherwise specified.
16
+ attr_accessor :api_version
17
+
18
+ # The default value to use for the oauth_callback_url if no other is provided.
19
+ attr_accessor :oauth_callback_url
20
+
21
+ # Whether to preserve arrays in arguments, which are expected by certain FB APIs (see the ads API
22
+ # in particular, https://developers.facebook.com/docs/marketing-api/adgroup/v2.4)
23
+ attr_accessor :preserve_form_arguments
24
+
25
+ # The server to use for Graph API requests
26
+ attr_accessor :graph_server
27
+
28
+ # The server to use when constructing dialog URLs.
29
+ attr_accessor :dialog_host
30
+
31
+ # Certain Facebook services (beta, video) require you to access different
32
+ # servers. If you're using your own servers, for instance, for a proxy,
33
+ # you can change both the matcher (what value to change when updating the URL) and the
34
+ # replacement values (what to add).
35
+ #
36
+ # So, for instance, to use the beta stack, we match on .facebook and change it to .beta.facebook.
37
+ # If you're talking to fbproxy.mycompany.com, you could set up beta.fbproxy.mycompany.com for
38
+ # FB's beta tier, and set the matcher to /\.fbproxy/ and the beta_replace to '.beta.fbproxy'.
39
+ attr_accessor :host_path_matcher
40
+ attr_accessor :video_replace
41
+ attr_accessor :beta_replace
42
+
43
+ def initialize
44
+ # Default to our default values.
45
+ Koala::HTTPService::DEFAULT_SERVERS.each_pair do |key, value|
46
+ self.public_send("#{key}=", value)
47
+ end
48
+ end
49
+ end
@@ -24,17 +24,11 @@ module Koala
24
24
  builder.adapter Faraday.default_adapter
25
25
  end
26
26
 
27
- # Default servers for Facebook. These are read into the config OpenStruct,
28
- # and can be overridden via Koala.config.
27
+ # Default server information for Facebook. These can be overridden by setting config values.
28
+ # See Koala.config.
29
29
  DEFAULT_SERVERS = {
30
30
  :graph_server => 'graph.facebook.com',
31
31
  :dialog_host => 'www.facebook.com',
32
- # certain Facebook services (beta, video) require you to access different
33
- # servers. If you're using your own servers, for instance, for a proxy,
34
- # you can change both the matcher and the replacement values.
35
- # So for instance, if you're talking to fbproxy.mycompany.com, you could
36
- # set up beta.fbproxy.mycompany.com for FB's beta tier, and set the
37
- # matcher to /\.fbproxy/ and the beta_replace to '.beta.fbproxy'.
38
32
  :host_path_matcher => /\.facebook/,
39
33
  :video_replace => '-video.facebook',
40
34
  :beta_replace => '.beta.facebook'
@@ -12,10 +12,10 @@ module Koala
12
12
  # @param app_id [String, Integer] a Facebook application ID
13
13
  # @param app_secret a Facebook application secret
14
14
  # @param oauth_callback_url the URL in your app to which users authenticating with OAuth will be sent
15
- def initialize(app_id, app_secret, oauth_callback_url = nil)
16
- @app_id = app_id
17
- @app_secret = app_secret
18
- @oauth_callback_url = oauth_callback_url
15
+ def initialize(app_id = nil, app_secret = nil, oauth_callback_url = nil)
16
+ @app_id = app_id || Koala.config.app_id
17
+ @app_secret = app_secret || Koala.config.app_secret
18
+ @oauth_callback_url = oauth_callback_url || Koala.config.oauth_callback_url
19
19
  end
20
20
 
21
21
  # Parses the cookie set Facebook's JavaScript SDK.
@@ -23,9 +23,9 @@ module Koala
23
23
  #
24
24
  # @raise ArgumentError if the application ID and one of the app access token or the secret are not provided.
25
25
  def initialize(options = {})
26
- @app_id = options[:app_id]
27
- @app_access_token = options[:app_access_token]
28
- @secret = options[:secret]
26
+ @app_id = options[:app_id] || Koala.config.app_id
27
+ @app_access_token = options[:app_access_token] || Koala.config.app_access_token
28
+ @secret = options[:secret] || Koala.config.app_secret
29
29
  unless @app_id && (@app_access_token || @secret) # make sure we have what we need
30
30
  raise ArgumentError, "Initialize must receive a hash with :app_id and either :app_access_token or :secret! (received #{options.inspect})"
31
31
  end
@@ -14,7 +14,6 @@ module Koala
14
14
  #
15
15
  # See http://developers.facebook.com/docs/test_users/.
16
16
  class TestUsers
17
-
18
17
  # The application API interface used to communicate with Facebook.
19
18
  # @return [Koala::Facebook::API]
20
19
  attr_reader :api
@@ -31,9 +30,10 @@ module Koala
31
30
  #
32
31
  # @raise ArgumentError if the application ID and one of the app access token or the secret are not provided.
33
32
  def initialize(options = {})
34
- @app_id = options[:app_id]
35
- @app_access_token = options[:app_access_token]
36
- @secret = options[:secret]
33
+ @app_id = options[:app_id] || Koala.config.app_id
34
+ @app_access_token = options[:app_access_token] || Koala.config.app_access_token
35
+ @secret = options[:secret] || Koala.config.app_secret
36
+
37
37
  unless @app_id && (@app_access_token || @secret) # make sure we have what we need
38
38
  raise ArgumentError, "Initialize must receive a hash with :app_id and either :app_access_token or :secret! (received #{options.inspect})"
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module Koala
2
- VERSION = "3.0.0.beta2"
2
+ VERSION = "3.0.0.beta3"
3
3
  end
data/readme.md CHANGED
@@ -4,7 +4,7 @@ Koala [![Version](https://img.shields.io/gem/v/koala.svg)](https://rubygems.org/
4
4
 
5
5
  * Lightweight: Koala should be as light and simple as Facebook’s own libraries, providing API accessors and returning simple JSON.
6
6
  * Fast: Koala should, out of the box, be quick. Out of the box, we use Facebook's faster read-only servers when possible and if available, the Typhoeus gem to make snappy Facebook requests. Of course, that brings us to our next topic:
7
- * Flexible: Koala should be useful to everyone, regardless of their current configuration. We support JRuby, Rubinius, and REE as well as vanilla Ruby (1.8.7, 1.9.2, 1.9.3, and 2.0.0), and use the Faraday library to provide complete flexibility over how HTTP requests are made.
7
+ * Flexible: Koala should be useful to everyone, regardless of their current configuration. We support all currently-supported Ruby versions (MRI 2.1-2.4) and Koala should work on JRuby and Rubinius.
8
8
  * Tested: Koala should have complete test coverage, so you can rely on it. Our test coverage is complete and can be run against either mocked responses or the live Facebook servers; we're also on [Travis CI](http://travis-ci.org/arsduo/koala/).
9
9
 
10
10
  **Found a bug? Interested in contributing?** Check out the Maintenance section below!
@@ -12,35 +12,58 @@ Koala [![Version](https://img.shields.io/gem/v/koala.svg)](https://rubygems.org/
12
12
  Installation
13
13
  ------------
14
14
 
15
+ **Koala 3.0 is in beta! There should be no significant changes** for most users -- please check it
16
+ out!
17
+
15
18
  In Bundler:
16
19
  ```ruby
17
- gem "koala", "~> 2.2"
20
+ gem "koala", "~> 3.0.0.beta2"
21
+ # if you need the previous release
22
+ gem "koala", "~> 2.4"
18
23
  ```
19
24
 
20
25
  Otherwise:
21
26
  ```bash
27
+ [sudo|rvm] gem install koala --pre
28
+ # if you need the previous release
22
29
  [sudo|rvm] gem install koala
23
30
  ```
24
31
 
25
- Upgrading to 2.0+
26
- -----------------
32
+ Configuration
33
+ -------------
27
34
 
28
- Koala 2.0 is not a major refactor, but rather a set of small, mostly internal
29
- refactors, which should not require significant changes by users. See changelog.md for more
30
- details.
35
+ Most applications will only use one application configuration. Rather than having toprovide that
36
+ value every time, you can configure Koala to use global settings:
37
+
38
+ ```ruby
39
+ # In Rails, you could put this in config/initializers/koala.rb
40
+ Koala.configure do |config|
41
+ config.access_token = MY_TOKEN
42
+ config.app_access_token = MY_APP_ACCESS_TOKEN
43
+ config.app_id = MY_APP_ID
44
+ config.app_secret = MY_APP_SECRET
45
+ # See Koala::Configuration for more options, including details on how to send requests through
46
+ # your own proxy servers.
47
+ end
48
+ ```
49
+
50
+ **Note**: this is not currently threadsafe. (PRs welcome as long as they support both threaded and
51
+ non-threaded configuration.)
31
52
 
32
53
  Graph API
33
54
  ---------
34
55
 
35
- The Graph API is the simple, slick new interface to Facebook's data.
36
- Using it with Koala is quite straightforward. First, you'll need an access token, which you can get through
37
- Facebook's [Graph API Explorer](https://developers.facebook.com/tools/explorer) (click on 'Get Access Token').
56
+ The Graph API is the interface to Facebook's data. Using it with Koala is quite straightforward.
57
+ First, you'll need an access token, which you can get through Facebook's [Graph API
58
+ Explorer](https://developers.facebook.com/tools/explorer) (click on 'Get Access Token').
59
+
38
60
  Then, go exploring:
39
61
 
40
62
  ```ruby
41
63
  require 'koala'
42
64
 
43
- @graph = Koala::Facebook::API.new(oauth_access_token)
65
+ # access_token and other values aren't required if you set the defaults as described above
66
+ @graph = Koala::Facebook::API.new(access_token)
44
67
 
45
68
  profile = @graph.get_object("me")
46
69
  friends = @graph.get_connections("me", "friends")
@@ -56,14 +79,14 @@ friends = @graph.get_connections("me", "friends")
56
79
  # For extra security (recommended), you can provide an appsecret parameter,
57
80
  # tying your access tokens to your app secret.
58
81
  # (See https://developers.facebook.com/docs/reference/api/securing-graph-api/
59
- # You'll need to turn on 'Require proof on all calls' in the advanced section
82
+
83
+ # You may need to turn on 'Require proof on all calls' in the advanced section
60
84
  # of your app's settings when doing this.
61
- @graph = Koala::Facebook::API.new(oauth_access_token, app_secret)
85
+ @graph = Koala::Facebook::API.new(access_token, app_secret)
62
86
 
63
87
  # Facebook is now versioning their API. # If you don't specify a version, Facebook
64
- # will default to the oldest version your app is allowed to use. Note that apps
65
- # created after f8 2014 *cannot* use the v1.0 API. See
66
- # https://developers.facebook.com/docs/apps/versions for more information.
88
+ # will default to the oldest version your app is allowed to use.
89
+ # See https://developers.facebook.com/docs/apps/versions for more information.
67
90
  #
68
91
  # You can specify version either globally:
69
92
  Koala.config.api_version = "v2.0"
@@ -115,64 +138,20 @@ the results apart from a long list of array entries:
115
138
 
116
139
  Check out the wiki for more details and examples.
117
140
 
118
- Configuration
119
- -------------
120
-
121
- You can change the host that koala makes requests to (point to a mock server, apigee, runscope etc..)
122
- ```ruby
123
- # config/initializers/koala.rb
124
- require 'koala'
125
-
126
- Koala.configure do |config|
127
- config.graph_server = 'my-graph-mock.mysite.com'
128
- # another common option: `dialog_host`
129
- # see lib/koala/http_service.rb
130
- end
131
- ```
132
-
133
- Of course the defaults are the facebook endpoints and you can additionally configure the beta
134
- tier and video upload matching and replacement strings.
135
-
136
- OAuth
141
+ App Access Tokens
137
142
  -----
138
143
 
139
- You can use the Graph API without an OAuth access token, but the real magic happens when you provide Facebook an OAuth token to prove you're authenticated. Koala provides an OAuth class to make that process easy:
144
+ You get your application's own access token, which can be used without a user session for subscriptions and certain other requests:
140
145
  ```ruby
141
146
  @oauth = Koala::Facebook::OAuth.new(app_id, app_secret, callback_url)
142
- ```
143
-
144
- If your application uses Koala and the Facebook [JavaScript SDK](http://github.com/facebook/facebook-js-sdk) (formerly Facebook Connect), you can use the OAuth class to parse the cookies:
145
- ```ruby
146
- # parses and returns a hash including the token and the user id
147
- # NOTE: this method can only be called once per session, as the OAuth code
148
- # Facebook supplies can only be redeemed once. Your application must handle
149
- # cross-request storage of this information; you can no longer call this method
150
- # multiple times.
151
- @oauth.get_user_info_from_cookies(cookies)
152
- ```
153
- And if you have to use the more complicated [redirect-based OAuth process](http://developers.facebook.com/docs/authentication/), Koala helps out there, too:
154
-
155
- ```ruby
156
- # generate authenticating URL
157
- @oauth.url_for_oauth_code
158
- # fetch the access token once you have the code
159
- @oauth.get_access_token(code)
160
- ```
161
-
162
- You can also get your application's own access token, which can be used without a user session for subscriptions and certain other requests:
163
- ```ruby
164
147
  @oauth.get_app_access_token
165
148
  ```
166
149
  For those building apps on Facebook, parsing signed requests is simple:
167
150
  ```ruby
168
151
  @oauth.parse_signed_request(signed_request_string)
169
152
  ```
170
- Or, if for some horrible reason, you're still using session keys, despair not! It's easy to turn them into shiny, modern OAuth tokens:
171
- ```ruby
172
- @oauth.get_token_from_session_key(session_key)
173
- @oauth.get_tokens_from_session_keys(array_of_session_keys)
174
- ```
175
- That's it! It's pretty simple once you get the hang of it. If you're new to OAuth, though, check out the wiki and the OAuth Playground example site (see below).
153
+
154
+ The OAuth class has additional methods that may occasionally be useful.
176
155
 
177
156
  Real-time Updates
178
157
  -----------------
@@ -181,6 +160,7 @@ Sometimes, reaching out to Facebook is a pain -- let it reach out to you instead
181
160
 
182
161
  Koala makes it easy to interact with your applications using the RealtimeUpdates class:
183
162
  ```ruby
163
+ # This class also supports the defaults as described above
184
164
  @updates = Koala::Facebook::RealtimeUpdates.new(app_id: app_id, secret: secret)
185
165
  ```
186
166
  You can do just about anything with your real-time update subscriptions using the RealtimeUpdates class:
@@ -206,12 +186,14 @@ Test Users
206
186
 
207
187
  We also support the test users API, allowing you to conjure up fake users and command them to do your bidding using the Graph API:
208
188
  ```ruby
189
+ # This class also supports the defaults as described above
209
190
  @test_users = Koala::Facebook::TestUsers.new(app_id: id, secret: secret)
210
191
  user = @test_users.create(is_app_installed, desired_permissions)
211
192
  user_graph_api = Koala::Facebook::API.new(user["access_token"])
212
193
  # or, if you want to make a whole community:
213
194
  @test_users.create_network(network_size, is_app_installed, common_permissions)
214
195
  ```
196
+
215
197
  Talking to Facebook
216
198
  -------------------
217
199
 
@@ -234,14 +216,6 @@ Some resources to help you as you play with Koala and the Graph API:
234
216
  * Complete Koala documentation <a href="https://github.com/arsduo/koala/wiki">on the wiki</a>
235
217
  * Facebook's <a href="http://facebook.stackoverflow.com/">Stack Overflow site</a> is a stupendous place to ask questions, filled with people who will help you figure out what's up with the Facebook API.
236
218
  * Facebook's <a href="http://developers.facebook.com/tools/explorer/">Graph API Explorer</a>, where you can play with the Graph API in your browser
237
- * The Koala-powered <a href="http://oauth.twoalex.com" target="_blank">OAuth Playground</a>, where you can easily generate OAuth access tokens and any other data needed to test out the APIs or OAuth
238
- * Follow Koala on <a href="http://www.facebook.com/pages/Koala/315368291823667">Facebook</a> and <a href="https://twitter.com/#!/koala_fb">Twitter</a> for SDK updates and occasional news about Facebook API changes.
239
-
240
- *Note*: I use the Koala issues tracker on Github to triage and address issues
241
- with the gem itself; if you need help using the Facebook API, the above
242
- resources will be far more effective. Depending on how much time I have, Github
243
- issues filed about how to use the Facebook API may be closed with a reference
244
- to the Facebook Stack Overflow page.
245
219
 
246
220
  Testing
247
221
  -------
@@ -259,26 +233,18 @@ LIVE=true bundle exec rake spec
259
233
  # you can also test against Facebook's beta tier
260
234
  LIVE=true BETA=true bundle exec rake spec
261
235
  ```
236
+
262
237
  By default, the live tests are run against test users, so you can run them as frequently as you want. If you want to run them against a real user, however, you can fill in the OAuth token, code, and access\_token values in spec/fixtures/facebook_data.yml. See the wiki for more details.
263
238
 
264
239
  Maintenance
265
240
  -----------
266
241
 
267
242
  _Pull requests_: Koala exists as it does thanks to the amazing support and work of community members of all
268
- backgrounds and levels of experience. Pull requests are very welcome! If you have any questions,
269
- just open an issue.
243
+ backgrounds and levels of experience. Pull requests are very welcome!
244
+
245
+ _Issues_: If you have any questions about the gem, found an issue in the Ruby code or
246
+ documentation, or have another question that isn't right for StackOverflow, just open an issue and fill out the template.
270
247
 
271
248
  Please note that this project is released with a Contributor Code of Conduct. By participating in
272
249
  this project you agree to abide by its terms. See
273
250
  [code_of_conduct.md](https://github.com/arsduo/koala/blob/master/code_of_conduct.md) for more information.
274
-
275
- _Schedule_: In order to keep Koala moving forward on a regular and predictable schedule, I will
276
- address issues and pull requests at least three times a year: late July/early August, late
277
- December/early January, and late March/early April. I may respond to issues in between maintenance
278
- periods, but it'll depend on other life/work goings-on.
279
-
280
- Breaking/new Facebook changes and other urgent issues obviously will get addressed much more
281
- quickly. (We've never had a security issue, but obviously that would be priority 0.)
282
-
283
- Have questions? Found a breaking bug or urgent issue? [Tweet at me](http://twitter.com/arsduo) --
284
- I'm always happy to respond.
@@ -6,6 +6,26 @@ describe "Koala::Facebook::API" do
6
6
  end
7
7
  let(:dummy_response) { double("fake response", data: {}, status: 200, body: "", headers: {}) }
8
8
 
9
+ it "defaults to the globally configured token if one's provided" do
10
+ token = "Foo"
11
+
12
+ Koala.configure do |config|
13
+ config.access_token = token
14
+ end
15
+
16
+ expect(Koala::Facebook::API.new.access_token).to eq(token)
17
+ end
18
+
19
+ it "defaults to the globally configured app_secret if one's provided" do
20
+ app_secret = "Foo"
21
+
22
+ Koala.configure do |config|
23
+ config.app_secret = app_secret
24
+ end
25
+
26
+ expect(Koala::Facebook::API.new.app_secret).to eq(app_secret)
27
+ end
28
+
9
29
  it "doesn't include an access token if none was given" do
10
30
  expect(Koala).to receive(:make_request).with(
11
31
  anything,
@@ -46,18 +66,6 @@ describe "Koala::Facebook::API" do
46
66
  service.api('anything', args)
47
67
  end
48
68
 
49
- it "has an attr_reader for access token" do
50
- token = 'adfadf'
51
- service = Koala::Facebook::API.new token
52
- expect(service.access_token).to eq(token)
53
- end
54
-
55
- it "has an attr_reader for app_secret" do
56
- secret = double
57
- service = Koala::Facebook::API.new(@token, secret)
58
- expect(service.app_secret).to eq(secret)
59
- end
60
-
61
69
  it "turns arrays of non-enumerables into comma-separated arguments by default" do
62
70
  args = [12345, {:foo => [1, 2, "3", :four]}]
63
71
  expected = ["/12345", {:foo => "1,2,3,four"}, "get", {}]
@@ -218,7 +226,7 @@ describe "Koala::Facebook::API" do
218
226
 
219
227
  it "passes the results through GraphCollection.evaluate" do
220
228
  allow(@service).to receive(:api).and_return(dummy_response)
221
- expect(Koala::Facebook::API::GraphCollection).to receive(:evaluate).with(dummy_response.data, @service)
229
+ expect(Koala::Facebook::API::GraphCollection).to receive(:evaluate).with(dummy_response, @service)
222
230
  @service.graph_call("/me")
223
231
  end
224
232
 
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Koala::Configuration do
4
+ let(:config) { Koala::Configuration.new }
5
+
6
+ it "defaults the HTTPService's DEFAULT_SERVERS" do
7
+ Koala::HTTPService::DEFAULT_SERVERS.each_pair do |key, value|
8
+ expect(config.public_send(key)).to eq(value)
9
+ end
10
+ end
11
+ end
@@ -1,14 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Koala::Facebook::API::GraphCollection do
4
- let(:paging){ {:paging => true} }
4
+ let(:paging){ {"paging" => true} }
5
5
 
6
6
  before(:each) do
7
- @result = {
8
- "data" => [1, 2, :three],
7
+ @headers = {'Content-Type' => 'application/json'}
8
+ @data = {
9
+ "data" => [1, 2, 'three'],
9
10
  "paging" => paging,
10
11
  "summary" => [3]
11
12
  }
13
+ @result = Koala::HTTPService::Response.new(200, @data.to_json, @headers)
12
14
  @api = Koala::Facebook::API.new("123")
13
15
  @collection = Koala::Facebook::API::GraphCollection.new(@result, @api)
14
16
  end
@@ -22,7 +24,7 @@ describe Koala::Facebook::API::GraphCollection do
22
24
  end
23
25
 
24
26
  it "contains the result data" do
25
- @result["data"].each_with_index {|r, i| expect(@collection[i]).to eq(r)}
27
+ @data["data"].each_with_index {|r, i| expect(@collection[i]).to eq(r)}
26
28
  end
27
29
 
28
30
  it "has a read-only paging attribute" do
@@ -31,21 +33,25 @@ describe Koala::Facebook::API::GraphCollection do
31
33
  end
32
34
 
33
35
  it "sets paging to results['paging']" do
34
- expect(@collection.paging).to eq(@result["paging"])
36
+ expect(@collection.paging).to eq(@data["paging"])
35
37
  end
36
38
 
37
39
  it "sets summary to results['summary']" do
38
- expect(@collection.summary).to eq(@result["summary"])
40
+ expect(@collection.summary).to eq(@data["summary"])
39
41
  end
40
42
 
41
43
  it "sets raw_response to the original results" do
42
- expect(@collection.raw_response).to eq(@result)
44
+ expect(@collection.raw_response).to eq(@result.data)
43
45
  end
44
46
 
45
47
  it "sets the API to the provided API" do
46
48
  expect(@collection.api).to eq(@api)
47
49
  end
48
50
 
51
+ it "sets the headers correctly" do
52
+ expect(@collection.headers).to eq(@headers)
53
+ end
54
+
49
55
  describe "when getting a whole page" do
50
56
  before(:each) do
51
57
  @second_page = {
@@ -55,19 +61,21 @@ describe Koala::Facebook::API::GraphCollection do
55
61
  @base = double("base")
56
62
  @args = {"a" => 1}
57
63
  @page_of_results = double("page of results")
64
+ @result = Koala::HTTPService::Response.new(200, @second_page.to_json, {})
65
+ @result.data
58
66
  end
59
67
 
60
68
  it "should return the previous page of results" do
61
69
  expect(@collection).to receive(:previous_page_params).and_return([@base, @args])
62
- expect(@api).to receive(:api).with(@base, @args, anything, anything).and_return(Koala::HTTPService::Response.new(200, @second_page.to_json, {}))
63
- expect(Koala::Facebook::API::GraphCollection).to receive(:new).with(@second_page, @api).and_return(@page_of_results)
70
+ expect(@api).to receive(:api).with(@base, @args, anything, anything).and_return(@result)
71
+ expect(Koala::Facebook::API::GraphCollection).to receive(:new).with(@result, @api).and_return(@page_of_results)
64
72
  expect(@collection.previous_page).to eq(@page_of_results)
65
73
  end
66
74
 
67
75
  it "should return the next page of results" do
68
76
  expect(@collection).to receive(:next_page_params).and_return([@base, @args])
69
- expect(@api).to receive(:api).with(@base, @args, anything, anything).and_return(Koala::HTTPService::Response.new(200, @second_page.to_json, {}))
70
- expect(Koala::Facebook::API::GraphCollection).to receive(:new).with(@second_page, @api).and_return(@page_of_results)
77
+ expect(@api).to receive(:api).with(@base, @args, anything, anything).and_return(@result)
78
+ expect(Koala::Facebook::API::GraphCollection).to receive(:new).with(@result, @api).and_return(@page_of_results)
71
79
 
72
80
  expect(@collection.next_page).to eq(@page_of_results)
73
81
  end
@@ -121,9 +129,11 @@ describe Koala::Facebook::API::GraphCollection do
121
129
  end
122
130
 
123
131
  describe ".evaluate" do
124
- it "returns the original result if it's provided a non-hash result" do
125
- result = []
126
- expect(Koala::Facebook::API::GraphCollection.evaluate(result, @api)).to eq(result)
132
+ it "returns the body of the original response if it's provided a Response with a non-hash data key" do
133
+ result = double('fake response')
134
+ allow(result).to receive(:is_a?).with(Hash).and_return(false)
135
+ allow(result).to receive(:data).and_return([])
136
+ expect(Koala::Facebook::API::GraphCollection.evaluate(result, @api)).to eq([])
127
137
  end
128
138
 
129
139
  it "returns the original result if it's provided a nil result" do
@@ -131,18 +141,21 @@ describe Koala::Facebook::API::GraphCollection do
131
141
  expect(Koala::Facebook::API::GraphCollection.evaluate(result, @api)).to eq(result)
132
142
  end
133
143
 
134
- it "returns the original result if the result doesn't have a data key" do
135
- result = {"paging" => {}}
136
- expect(Koala::Facebook::API::GraphCollection.evaluate(result, @api)).to eq(result)
144
+ it "returns the original result body if the result doesn't have a data key" do
145
+ paging = {"paging" => {}}
146
+ result = Koala::HTTPService::Response.new(200, paging.to_json, {})
147
+ expect(Koala::Facebook::API::GraphCollection.evaluate(result, @api)).to eq(paging)
137
148
  end
138
149
 
139
150
  it "returns the original result if the result's data key isn't an array" do
140
- result = {"data" => {}, "paging" => {}}
141
- expect(Koala::Facebook::API::GraphCollection.evaluate(result, @api)).to eq(result)
151
+ body = {"data" => {}, "paging" => {}}
152
+ result = Koala::HTTPService::Response.new(200, body.to_json, {})
153
+ expect(Koala::Facebook::API::GraphCollection.evaluate(result, @api)).to eq(body)
142
154
  end
143
155
 
144
156
  it "returns a new GraphCollection of the result if it has an array data key and a paging key" do
145
- result = {"data" => [], "paging" => {}}
157
+ body = {"data" => [], "paging" => {}}
158
+ result = Koala::HTTPService::Response.new(200, body.to_json, {})
146
159
  expected = :foo
147
160
  expect(Koala::Facebook::API::GraphCollection).to receive(:new).with(result, @api).and_return(expected)
148
161
  expect(Koala::Facebook::API::GraphCollection.evaluate(result, @api)).to eq(expected)
@@ -66,17 +66,19 @@ module Koala
66
66
  end
67
67
 
68
68
  context "set by Koala.config" do
69
- let(:version) { "v2.1" }
69
+ let(:version) { "v2.7" }
70
70
 
71
71
  before :each do
72
- allow(Koala.config).to receive(:api_version).and_return(version)
72
+ Koala.configure do |config|
73
+ config.api_version = version
74
+ end
73
75
  end
74
76
 
75
77
  it_should_behave_like :including_the_version
76
78
  end
77
79
 
78
80
  context "set in options" do
79
- let(:version) { "v2.1" }
81
+ let(:version) { "v2.8" }
80
82
 
81
83
  let(:options) { {api_version: version} }
82
84
 
@@ -31,9 +31,7 @@ describe Koala do
31
31
 
32
32
  describe ".configure" do
33
33
  it "yields a configurable object" do
34
- expect {
35
- Koala.configure {|c| c.foo = "bar"}
36
- }.not_to raise_exception
34
+ Koala.configure {|c| expect(c).to be_a(Koala::Configuration)}
37
35
  end
38
36
 
39
37
  it "caches the config (singleton)" do
@@ -56,5 +54,4 @@ describe Koala do
56
54
  expect(Koala.config.graph_server).to eq("some-new.graph_server.com")
57
55
  end
58
56
  end
59
-
60
57
  end
@@ -53,6 +53,45 @@ describe "Koala::Facebook::OAuth" do
53
53
  @oauth.app_secret == @secret &&
54
54
  @oauth.oauth_callback_url == nil).to be_truthy
55
55
  end
56
+
57
+ context "with global defaults" do
58
+ let(:app_id) { :app_id }
59
+ let(:app_secret) { :app_secret }
60
+ let(:oauth_callback_url) { :oauth_callback_url }
61
+
62
+ before :each do
63
+ Koala.configure do |config|
64
+ config.app_id = app_id
65
+ config.app_secret = app_secret
66
+ config.oauth_callback_url = oauth_callback_url
67
+ end
68
+ end
69
+
70
+ it "defaults to the configured data if not otherwise provided" do
71
+ oauth = Koala::Facebook::OAuth.new
72
+ expect(oauth.app_id).to eq(app_id)
73
+ expect(oauth.app_secret).to eq(app_secret)
74
+ expect(oauth.oauth_callback_url).to eq(oauth_callback_url)
75
+ end
76
+
77
+ it "lets you override app_id" do
78
+ other_value = :another_id
79
+ oauth = Koala::Facebook::OAuth.new(other_value)
80
+ expect(oauth.app_id).to eq(other_value)
81
+ end
82
+
83
+ it "lets you override secret" do
84
+ other_value = :another_secret
85
+ oauth = Koala::Facebook::OAuth.new(nil, other_value)
86
+ expect(oauth.app_secret).to eq(other_value)
87
+ end
88
+
89
+ it "lets you override app_id" do
90
+ other_value = :another_token
91
+ oauth = Koala::Facebook::OAuth.new(nil, nil, other_value)
92
+ expect(oauth.oauth_callback_url).to eq(other_value)
93
+ end
94
+ end
56
95
  end
57
96
 
58
97
  describe "for cookie parsing" do
@@ -36,6 +36,45 @@ describe "Koala::Facebook::RealtimeUpdates" do
36
36
  expect(updates).to be_a(Koala::Facebook::RealtimeUpdates)
37
37
  end
38
38
 
39
+ context "with global defaults" do
40
+ let(:app_id) { :app_id }
41
+ let(:app_secret) { :app_secret }
42
+ let(:app_access_token) { :app_access_token }
43
+
44
+ before :each do
45
+ Koala.configure do |config|
46
+ config.app_id = app_id
47
+ config.app_secret = app_secret
48
+ config.app_access_token = app_access_token
49
+ end
50
+ end
51
+
52
+ it "defaults to the configured data if not otherwise provided" do
53
+ rtu = Koala::Facebook::RealtimeUpdates.new
54
+ expect(rtu.app_id).to eq(app_id)
55
+ expect(rtu.secret).to eq(app_secret)
56
+ expect(rtu.app_access_token).to eq(app_access_token)
57
+ end
58
+
59
+ it "lets you override app_id" do
60
+ other_value = :another_id
61
+ rtu = Koala::Facebook::RealtimeUpdates.new(app_id: other_value)
62
+ expect(rtu.app_id).to eq(other_value)
63
+ end
64
+
65
+ it "lets you override secret" do
66
+ other_value = :another_secret
67
+ rtu = Koala::Facebook::RealtimeUpdates.new(secret: other_value)
68
+ expect(rtu.secret).to eq(other_value)
69
+ end
70
+
71
+ it "lets you override app_id" do
72
+ other_value = :another_token
73
+ rtu = Koala::Facebook::RealtimeUpdates.new(app_access_token: other_value)
74
+ expect(rtu.app_access_token).to eq(other_value)
75
+ end
76
+ end
77
+
39
78
  # attributes
40
79
  it "allows read access to app_id" do
41
80
  # in Ruby 1.9, .method returns symbols
@@ -40,12 +40,52 @@ describe "Koala::Facebook::TestUsers" do
40
40
  expect(test_users).to be_a(Koala::Facebook::TestUsers)
41
41
  end
42
42
 
43
+ context "with global defaults" do
44
+ let(:app_id) { :app_id }
45
+ let(:app_secret) { :app_secret }
46
+ let(:app_access_token) { :app_access_token }
47
+
48
+ before :each do
49
+ Koala.configure do |config|
50
+ config.app_id = app_id
51
+ config.app_secret = app_secret
52
+ config.app_access_token = app_access_token
53
+ end
54
+ end
55
+
56
+ it "defaults to the configured data if not otherwise provided" do
57
+ test_users = Koala::Facebook::TestUsers.new
58
+ expect(test_users.app_id).to eq(app_id)
59
+ expect(test_users.secret).to eq(app_secret)
60
+ expect(test_users.app_access_token).to eq(app_access_token)
61
+ end
62
+
63
+ it "lets you override app_id" do
64
+ other_value = :another_id
65
+ test_users = Koala::Facebook::TestUsers.new(app_id: other_value)
66
+ expect(test_users.app_id).to eq(other_value)
67
+ end
68
+
69
+ it "lets you override secret" do
70
+ other_value = :another_secret
71
+ test_users = Koala::Facebook::TestUsers.new(secret: other_value)
72
+ expect(test_users.secret).to eq(other_value)
73
+ end
74
+
75
+ it "lets you override app_id" do
76
+ other_value = :another_token
77
+ test_users = Koala::Facebook::TestUsers.new(app_access_token: other_value)
78
+ expect(test_users.app_access_token).to eq(other_value)
79
+ end
80
+ end
81
+
82
+
43
83
  it "uses the OAuth class to fetch a token when provided an app_id and a secret" do
44
84
  oauth = Koala::Facebook::OAuth.new(@app_id, @secret)
45
85
  token = oauth.get_app_access_token
46
86
  expect(oauth).to receive(:get_app_access_token).and_return(token)
47
87
  expect(Koala::Facebook::OAuth).to receive(:new).with(@app_id, @secret).and_return(oauth)
48
- test_users = Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
88
+ Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
49
89
  end
50
90
 
51
91
  # attributes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koala
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta2
4
+ version: 3.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Koppel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -71,8 +71,10 @@ files:
71
71
  - ".yardopts"
72
72
  - Gemfile
73
73
  - Guardfile
74
+ - ISSUE_TEMPLATE
74
75
  - LICENSE
75
76
  - Manifest
77
+ - PULL_REQUEST_TEMPLATE
76
78
  - Rakefile
77
79
  - autotest/discover.rb
78
80
  - changelog.md
@@ -85,6 +87,7 @@ files:
85
87
  - lib/koala/api/graph_batch_api.rb
86
88
  - lib/koala/api/graph_collection.rb
87
89
  - lib/koala/api/graph_error_checker.rb
90
+ - lib/koala/configuration.rb
88
91
  - lib/koala/errors.rb
89
92
  - lib/koala/http_service.rb
90
93
  - lib/koala/http_service/multipart_request.rb
@@ -98,6 +101,7 @@ files:
98
101
  - lib/koala/version.rb
99
102
  - readme.md
100
103
  - spec/cases/api_spec.rb
104
+ - spec/cases/configuration_spec.rb
101
105
  - spec/cases/error_spec.rb
102
106
  - spec/cases/graph_api_batch_spec.rb
103
107
  - spec/cases/graph_api_spec.rb
@@ -158,6 +162,7 @@ summary: A lightweight, flexible library for Facebook with support for the Graph
158
162
  the REST API, realtime updates, and OAuth authentication.
159
163
  test_files:
160
164
  - spec/cases/api_spec.rb
165
+ - spec/cases/configuration_spec.rb
161
166
  - spec/cases/error_spec.rb
162
167
  - spec/cases/graph_api_batch_spec.rb
163
168
  - spec/cases/graph_api_spec.rb