givey_ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- givey_ruby (0.0.1.alpha)
4
+ givey_ruby (0.0.3)
5
5
  httparty
6
6
  oauth2
7
7
 
@@ -29,20 +29,20 @@ GEM
29
29
  erubis (2.7.0)
30
30
  factory_girl (3.4.0)
31
31
  activesupport (>= 3.0.0)
32
- faraday (0.8.1)
32
+ faraday (0.8.5)
33
33
  multipart-post (~> 1.1)
34
34
  hike (1.2.1)
35
- httparty (0.8.3)
35
+ httparty (0.10.2)
36
36
  multi_json (~> 1.0)
37
- multi_xml
38
- httpauth (0.1)
37
+ multi_xml (>= 0.5.2)
38
+ httpauth (0.2.0)
39
39
  i18n (0.6.0)
40
40
  journey (1.0.4)
41
41
  jwt (0.1.5)
42
42
  multi_json (>= 1.0)
43
43
  log_buddy (0.7.0)
44
44
  multi_json (1.3.6)
45
- multi_xml (0.5.1)
45
+ multi_xml (0.5.2)
46
46
  multipart-post (1.1.5)
47
47
  oauth2 (0.8.0)
48
48
  faraday (~> 0.8)
@@ -5,9 +5,10 @@ module GiveyRuby
5
5
  def client(client_options = {})
6
6
  @client ||= begin
7
7
  # TODO: ensure consumer key and secret
8
- @api_site = client_options.include?(:api_site) ? client_options[:api_site] : "http://api.givey.com"
9
- opts = {:site => @api_site, :authorize_url => "/#{api_version}/oauth/authorize", :token_url => "/#{api_version}/oauth/token", :raise_errors => false}
10
- @token_file = client_options.include?(:token_file) ? client_options[:token_file] : "../tmp/givey_token_file"
8
+ @api_site = client_options.include?(:api_site) ? client_options[:api_site] : "http://api.givey.com"
9
+ @api_version = client_options.include?(:api_version) ? client_options[:api_version] : "v2"
10
+ opts = {:site => @api_site, :authorize_url => "/#{api_version}/oauth/authorize", :token_url => "/#{api_version}/oauth/token", :raise_errors => false}
11
+ @token_file = client_options.include?(:token_file) ? client_options[:token_file] : "../tmp/givey_token_file"
11
12
  OAuth2::Client.new(client_options[:consumer_key], client_options[:consumer_secret], opts) do |builder|
12
13
  # POST/PUT params encoders:
13
14
  builder.request :multipart
@@ -17,8 +18,8 @@ module GiveyRuby
17
18
  end
18
19
  end
19
20
 
20
- def api_version(version = "v1")
21
- @api_version ||= version
21
+ def api_version
22
+ @api_version
22
23
  end
23
24
 
24
25
  def api_site
@@ -1,3 +1,3 @@
1
1
  module GiveyRuby
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,30 +2,41 @@ require 'spec_helper'
2
2
 
3
3
  describe GiveyRuby::Configuration do
4
4
 
5
- describe "Client options" do
6
-
7
- it "GiveyRuby configure should set OAuth2 client correctly" do
5
+ context "api_site" do
6
+ before(:each) do
8
7
  GiveyRuby.configure do |config|
9
8
  config.client({api_site: "http://example.com"})
10
9
  end
10
+ end
11
11
 
12
- GiveyRuby.configuration.client.should be_kind_of(OAuth2::Client)
13
- GiveyRuby.configuration.client.site.should == "http://example.com"
12
+ describe "Client options" do
13
+ it "GiveyRuby configure should set OAuth2 client correctly" do
14
+ GiveyRuby.configuration.client.should be_kind_of(OAuth2::Client)
15
+ GiveyRuby.configuration.client.site.should == "http://example.com"
16
+ end
14
17
  end
15
18
 
19
+ describe "Session options" do
20
+ it "GiveyRuby configure should set OAuth2 client correctly" do
21
+ puts GiveyRuby.configuration.inspect
22
+ GiveyRuby.configuration.client.should be_kind_of(OAuth2::Client)
23
+ GiveyRuby.configuration.client.site.should == "http://example.com"
24
+ end
25
+ end
16
26
  end
17
27
 
18
- describe "Session options" do
28
+ describe "#api_version" do
29
+ let(:config) { GiveyRuby::Configuration.new }
30
+ let(:subject) { config.api_version }
19
31
 
20
- it "GiveyRuby configure should set OAuth2 client correctly" do
21
- GiveyRuby.configure do |config|
22
- config.client({api_site: "http://example.com"})
23
- end
24
-
25
- GiveyRuby.configuration.client.should be_kind_of(OAuth2::Client)
26
- GiveyRuby.configuration.client.site.should == "http://example.com"
32
+ context "default" do
33
+ before { config.client }
34
+ it { should == "v2" }
27
35
  end
28
36
 
37
+ context "specified" do
38
+ before { config.client({ api_version: "v1" }) }
39
+ it { should == "v1" }
40
+ end
29
41
  end
30
-
31
42
  end
@@ -3,12 +3,14 @@ require 'action_controller'
3
3
 
4
4
  describe GiveyRuby::Controller do
5
5
 
6
- class CharityController
7
- include GiveyRuby::Controller
8
- end
6
+ before(:all) do
7
+ class CharityController
8
+ include GiveyRuby::Controller
9
+ end
9
10
 
10
- GiveyRuby.configure do |config|
11
- config.client({token_file: "#{SPEC_ROOT}/tmp/givey_token_file"})
11
+ GiveyRuby.configure do |config|
12
+ config.client({token_file: "#{SPEC_ROOT}/tmp/givey_token_file"})
13
+ end
12
14
  end
13
15
 
14
16
  let(:charity_controller) { CharityController.new }
@@ -21,6 +23,7 @@ describe GiveyRuby::Controller do
21
23
  it "should get new token and update session if it doesn't exist" do
22
24
  charity_controller.stub(:session).and_return({})
23
25
  charity_controller.stub_chain(:api_client, :client_credentials, :get_token).and_return(api_token)
26
+ charity_controller.stub(:token_to_file) # Because token_to_file cannot find the file/folder in a full test run
24
27
  charity_controller.access_token.should == api_token
25
28
  charity_controller.session[:access_token].should == 'udhs7gf7ssg'
26
29
  end
@@ -2,12 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe GiveyRuby::Model do
4
4
 
5
- class Charity
6
- include GiveyRuby::Model
7
- end
5
+ before(:all) do
6
+ class Charity
7
+ include GiveyRuby::Model
8
+ end
8
9
 
9
- GiveyRuby.configure do |config|
10
- config.client({token_file: "#{SPEC_ROOT}/tmp/givey_token_file"})
10
+ GiveyRuby.configure do |config|
11
+ config.client({token_file: "#{SPEC_ROOT}/tmp/givey_token_file"})
12
+ end
11
13
  end
12
14
 
13
15
  let(:charity) { Charity.new }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: givey_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-18 00:00:00.000000000 Z
12
+ date: 2013-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  requirements: []
175
175
  rubyforge_project: givey_ruby
176
- rubygems_version: 1.8.24
176
+ rubygems_version: 1.8.25
177
177
  signing_key:
178
178
  specification_version: 3
179
179
  summary: Ruby API for accessing Givey API