omniauth-plangrade 0.1.0 → 0.1.1

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: 3d523a80b7f14c752d07284bff285f756588fe17
4
- data.tar.gz: b22c3073713a4410dab81e8b18b5a7f1dfdfc085
3
+ metadata.gz: 3174239bb8b6b7b3c24cd69bbc2391976bfb2095
4
+ data.tar.gz: 3b7ea023d9b1c54c8b485c1971f4adaa4a670d22
5
5
  SHA512:
6
- metadata.gz: ab52cc22f976648fedc20d209799ac578c7c8306d7ebbe5488f8a653cf2369469694beb591978eaa832fc233536c1d398ff540968da6817888865428d69f3fac
7
- data.tar.gz: ea400ef43125b12f0c973ec2af46bf746d372128f207349e770ba964cd5927c7ffe8084c99d7821fec92e8a75ef4bc0b120118ecbcb5f0480651b7f6b5b45354
6
+ metadata.gz: ea9c296465dc5fdc58653a8e5e0aa18c4029f121b34ce0358b4f5e5f5b1c01d4093f96940f79b1d80fe95016a4dc3cce322fd73860e797f6d7232bef66ff5fdf
7
+ data.tar.gz: 76b6f7288d675b6a24fbaa7f2273c162f4e73cef5ad57ab87b6de8aa23180fce243708a62ddc4a8642771c3855744a27e1edbdb079c5418b1daa3e3495976660
data/Gemfile CHANGED
@@ -2,5 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gem 'rake'
4
4
 
5
+ group :test do
6
+ gem 'rspec', '>= 2.11'
7
+ gem 'simplecov', :require => false
8
+ gem 'coveralls', :require => false
9
+ gem 'webmock', '>= 1.10.1'
10
+ end
11
+
5
12
  # Specify your gem's dependencies in omniauth-twitter.gemspec
6
13
  gemspec
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # OmniAuth plangrade
2
2
  [![Gem Version](https://badge.fury.io/rb/omniauth-plangrade.svg)](http://badge.fury.io/rb/omniauth-plangrade)
3
3
  [![Code Climate](https://codeclimate.com/github/topherreynoso/omniauth-plangrade/badges/gpa.svg)](https://codeclimate.com/github/topherreynoso/omniauth-plangrade)
4
+ [![Build Status](https://travis-ci.org/topherreynoso/omniauth-plangrade.svg?branch=master)](https://travis-ci.org/topherreynoso/omniauth-plangrade)
5
+ [![Coverage Status](https://coveralls.io/repos/topherreynoso/omniauth-plangrade/badge.png?branch=master)](https://coveralls.io/r/topherreynoso/omniauth-plangrade?branch=master)
4
6
 
5
7
  plangrade OAuth2 strategy for OmniAuth.
6
8
  Supports the OAuth 2.0 server-side and client-side flows. Read the plangrade docs for more details: [docs.plangrade.com](https://docs.plangrade.com/#authentication). Additionally, this may be used in conjunction with [plangrade-ruby](https://github.com/topherreynoso/plangrade-ruby) in order to refresh tokens and access plangrade API endpoints.
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Plangrade
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -1,24 +1,74 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Plangrade do
4
- let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
4
+ subject { OmniAuth::Strategies::Plangrade.new(nil) }
5
5
 
6
- subject do
7
- args = ['appid', 'secret', @options || {}].compact
8
- OmniAuth::Strategies::Plangrade.new(*args).tap do |strategy|
9
- allow(strategy).to receive(:request) {
10
- request
11
- }
6
+ it 'should add a camelization for itself' do
7
+ expect(OmniAuth::Utils.camelize('plangrade')).to eq('Plangrade')
8
+ end
9
+
10
+ describe '#client' do
11
+ it 'has correct Plangrade site' do
12
+ expect(subject.client.site).to eq('https://plangrade.com')
13
+ end
14
+
15
+ it 'has correct authorize url' do
16
+ expect(subject.client.options[:authorize_url]).to eq('/oauth/authorize')
17
+ end
18
+
19
+ it 'has correct token url' do
20
+ expect(subject.client.options[:token_url]).to eq('/oauth/token')
21
+ end
22
+ end
23
+
24
+ describe '#callback_path' do
25
+ it 'has the correct callback path' do
26
+ expect(subject.callback_path).to eq('/auth/plangrade/callback')
27
+ end
28
+ end
29
+
30
+ describe '#uid' do
31
+ before :each do
32
+ allow(subject).to receive(:raw_info) { { 'id' => 'uid' } }
33
+ end
34
+
35
+ it 'returns the id from raw_info' do
36
+ expect(subject.uid).to eq('uid')
37
+ end
38
+ end
39
+
40
+ describe '#info' do
41
+ context 'and therefore has all the necessary fields' do
42
+ before :each do
43
+ allow(subject).to receive(:raw_info) {
44
+ {
45
+ 'name' => 'John Doe',
46
+ 'email' => 'compliance@plangrade.com'
47
+ }
48
+ }
49
+ end
50
+
51
+ it { expect(subject.info).to have_key :name }
52
+ it { expect(subject.info).to have_key :email }
53
+ end
54
+
55
+ context 'and does not fail with empty response' do
56
+ before :each do
57
+ allow(subject).to receive(:raw_info) { {} }
58
+ end
59
+
60
+ it { expect { subject.info }.not_to raise_error }
12
61
  end
13
62
  end
14
63
 
15
- describe 'client options' do
16
- it 'should have correct name' do
17
- expect(subject.options.name).to eq(:plangrade)
64
+ describe '#raw_info' do
65
+ before :each do
66
+ response = double('response', :parsed => { 'foo' => 'bar' })
67
+ allow(subject).to receive(:access_token) { double('access token', :get => response) }
18
68
  end
19
69
 
20
- it 'should have correct site' do
21
- expect(subject.options.client_options.site).to eq('https://plangrade.com')
70
+ it 'returns parsed response from access token' do
71
+ expect(subject.raw_info).to eq({ 'foo' => 'bar' })
22
72
  end
23
73
  end
24
74
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,14 @@
1
1
  $:.unshift File.expand_path('..', __FILE__)
2
2
  $:.unshift File.expand_path('../../lib', __FILE__)
3
3
  require 'simplecov'
4
+ require 'coveralls'
5
+
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
4
10
  SimpleCov.start
11
+
5
12
  require 'rspec'
6
13
  require 'rack/test'
7
14
  require 'webmock/rspec'
@@ -10,6 +17,8 @@ require 'omniauth'
10
17
  require 'omniauth-oauth2'
11
18
  require 'omniauth/plangrade'
12
19
 
20
+ WebMock.disable_net_connect!(:allow => 'coveralls.io')
21
+
13
22
  RSpec.configure do |config|
14
23
  config.include WebMock::API
15
24
  config.include Rack::Test::Methods
@@ -17,4 +26,4 @@ RSpec.configure do |config|
17
26
  config.expect_with :rspec do |c|
18
27
  c.syntax = :expect
19
28
  end
20
- end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-plangrade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Reynoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json