|
| 1 | +# encoding: utf-8 |
| 2 | + |
1 | 3 | require 'spec_helper' |
2 | 4 |
|
3 | 5 | describe Github::Authorization do |
4 | | - |
5 | 6 | let(:client_id) { '234jl23j4l23j4l' } |
6 | 7 | let(:client_secret) { 'asasd79sdf9a7asfd7sfd97s' } |
7 | 8 | let(:code) { 'c9798sdf97df98ds'} |
8 | | - let(:github) { Github.new } |
9 | | - |
10 | | - it "should instantiate oauth2 instance" do |
11 | | - github.client.should be_a OAuth2::Client |
12 | | - end |
13 | | - |
14 | | - it "should assign site from the options hash" do |
15 | | - github.client.site.should == 'https://github.com' |
16 | | - end |
17 | | - |
18 | | - it "should assign 'authorize_url" do |
19 | | - github.client.authorize_url.should == 'https://github.com/login/oauth/authorize' |
20 | | - end |
| 9 | + let(:github) { |
| 10 | + Github.new :client_id => client_id, :client_secret => client_secret |
| 11 | + } |
21 | 12 |
|
22 | | - it "should assign 'token_url" do |
23 | | - github.client.token_url.should == 'https://github.com/login/oauth/access_token' |
| 13 | + after do |
| 14 | + github.client_id, github.client_secret = nil, nil |
| 15 | + reset_authentication_for github |
24 | 16 | end |
25 | 17 |
|
26 | 18 | context '.client' do |
|
29 | 21 | it "should return OAuth2::Client instance" do |
30 | 22 | github.client.should be_a OAuth2::Client |
31 | 23 | end |
32 | | - end |
33 | 24 |
|
34 | | - context '.auth_code' do |
35 | | - let(:oauth) { OAuth2::Client.new(client_id, client_secret) } |
| 25 | + it "should assign site from the options hash" do |
| 26 | + github.client.site.should == 'https://github.com' |
| 27 | + end |
36 | 28 |
|
37 | | - before do |
38 | | - github = Github.new :client_id => client_id, :client_secret => client_secret |
| 29 | + it "should assign 'authorize_url" do |
| 30 | + github.client.authorize_url.should == 'https://github.com/login/oauth/authorize' |
39 | 31 | end |
40 | 32 |
|
41 | | - after do |
42 | | - github.client_id, github.client_secret = nil, nil |
| 33 | + it "should assign 'token_url" do |
| 34 | + github.client.token_url.should == 'https://github.com/login/oauth/access_token' |
43 | 35 | end |
| 36 | + end |
| 37 | + |
| 38 | + context '.auth_code' do |
| 39 | + let(:oauth) { OAuth2::Client.new(client_id, client_secret) } |
44 | 40 |
|
45 | 41 | it "should throw an error if no client_id" do |
46 | 42 | github.client_id = nil |
|
61 | 57 | end |
62 | 58 |
|
63 | 59 | context "authorize_url" do |
64 | | - before do |
65 | | - github = Github.new :client_id => client_id, :client_secret => client_secret |
66 | | - end |
67 | | - |
68 | 60 | it "should respond to 'authorize_url' " do |
69 | 61 | github.should respond_to :authorize_url |
70 | 62 | end |
|
84 | 76 |
|
85 | 77 | context "get_token" do |
86 | 78 | before do |
87 | | - github = Github.new :client_id => client_id, :client_secret => client_secret |
88 | 79 | stub_request(:post, 'https://github.com/login/oauth/access_token'). |
89 | 80 | to_return(:body => '', :status => 200, :headers => {}) |
90 | 81 | end |
|
0 commit comments