This repository has been archived by the owner on Nov 10, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
Conflicts: lib/sinatra/auth/github.rb sinatra_auth_github.gemspec spec/spec_helper.rb
- Loading branch information
Showing
7 changed files
with
76 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
require 'warden/test/helpers' | |||
require 'warden-github/user' | |||
|
|||
module Sinatra | |||
module Auth | |||
module Github | |||
module Test | |||
module Helper | |||
include(Warden::Test::Helpers) | |||
def make_user(attrs = {}) | |||
User.make(attrs) | |||
end | |||
|
|||
class User < Warden::Github::Oauth::User | |||
def self.make(attrs = {}) | |||
default_attrs = { | |||
'login' => "test_user", | |||
'name' => "Test User", | |||
'email' => "test@example.com", | |||
'company' => "GitHub", | |||
'gravatar_id' => 'https://a249.e.akamai.net/assets.github.com/images/gravatars/gravatar-140.png' | |||
} | |||
default_attrs.merge! attrs | |||
User.new(default_attrs) | |||
end | |||
end | |||
end | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
module Sinatra | |||
module Auth | |||
module Github | |||
VERSION = "0.5.0" | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,25 @@ | |||
require "spec_helper" | |||
|
|||
describe "Logged in users" do | |||
before do | |||
@user = make_user('login' => 'defunkt') | |||
login_as @user | |||
end | |||
|
|||
it "greets the user" do | |||
get "/" | |||
last_response.body.should eql("Hello there, defunkt!") | |||
end | |||
|
|||
it "logs the user out" do | |||
get "/" | |||
|
|||
get "/logout" | |||
last_response.status.should eql(302) | |||
last_response.headers['Location'].should eql("https://github.com") | |||
|
|||
get "/" | |||
last_response.status.should eql(302) | |||
last_response.headers['Location'].should =~ %r{^https://github\.com/login/oauth/authorize} | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,15 +1,23 @@ | |||
require "bundler/setup" | require "bundler/setup" | ||
|
|
||
require File.join(File.dirname(__FILE__), '..', 'lib', 'sinatra', 'auth', 'github') | $:.push File.join(File.dirname(__FILE__), '..', 'lib') | ||
|
|
||
require 'pp' | require 'pp' | ||
require 'rack/test' | |||
require 'ruby-debug' | |||
|
|
||
require 'rack/test' | require 'rack/test' | ||
|
|
||
require 'sinatra/auth/github' | |||
require 'sinatra/auth/github/test/test_helper' | |||
|
|||
require 'app' | |||
|
|||
RSpec.configure do |config| | RSpec.configure do |config| | ||
config.include(Rack::Test::Methods) | config.include(Rack::Test::Methods) | ||
config.include(Sinatra::Auth::Github::Test::Helper) | |||
|
|
||
def app | def app | ||
Example.app | Example::App | ||
end | end | ||
end | end |