sinatra_auth_github 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/sinatra/auth/github/test/test_helper.rb +31 -0
- data/lib/sinatra/auth/github/version.rb +7 -0
- data/lib/sinatra/auth/github.rb +0 -2
- data/sinatra_auth_github.gemspec +4 -3
- data/spec/app.rb +1 -1
- data/spec/login_spec.rb +25 -0
- data/spec/spec_helper.rb +9 -3
- metadata +13 -12
- data/spec/quality_spec.rb +0 -41
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'warden/test/helpers'
|
2
|
+
require 'warden-github/user'
|
3
|
+
|
4
|
+
module Sinatra
|
5
|
+
module Auth
|
6
|
+
module Github
|
7
|
+
module Test
|
8
|
+
module Helper
|
9
|
+
include(Warden::Test::Helpers)
|
10
|
+
def make_user(attrs = {})
|
11
|
+
User.make(attrs)
|
12
|
+
end
|
13
|
+
|
14
|
+
class User < Warden::Github::Oauth::User
|
15
|
+
def self.make(attrs = {})
|
16
|
+
default_attrs = {
|
17
|
+
'login' => "test_user",
|
18
|
+
'name' => "Test User",
|
19
|
+
'email' => "test@example.com",
|
20
|
+
'company' => "GitHub",
|
21
|
+
'gravatar_id' => 'https://a249.e.akamai.net/assets.github.com/images/gravatars/gravatar-140.png'
|
22
|
+
}
|
23
|
+
default_attrs.merge! attrs
|
24
|
+
User.new(default_attrs)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/sinatra/auth/github.rb
CHANGED
data/sinatra_auth_github.gemspec
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sinatra/auth/github/version"
|
3
4
|
|
4
5
|
Gem::Specification.new do |s|
|
5
6
|
s.name = "sinatra_auth_github"
|
6
|
-
s.version =
|
7
|
+
s.version = Sinatra::Auth::Github::VERSION
|
7
8
|
s.platform = Gem::Platform::RUBY
|
8
9
|
s.authors = ["Corey Donohoe"]
|
9
10
|
s.email = ["atmos@atmos.org"]
|
@@ -16,10 +17,10 @@ Gem::Specification.new do |s|
|
|
16
17
|
s.add_dependency "sinatra", "~>1.0"
|
17
18
|
s.add_dependency "yajl-ruby", "~>1.1"
|
18
19
|
s.add_dependency "rest-client", "~>1.6.1"
|
19
|
-
s.add_dependency "warden-github", "~>0.4.
|
20
|
+
s.add_dependency "warden-github", "~>0.4.0"
|
20
21
|
|
21
22
|
s.add_development_dependency "rake"
|
22
|
-
s.add_development_dependency "rspec", "~>2.0
|
23
|
+
s.add_development_dependency "rspec", "~>2.0"
|
23
24
|
s.add_development_dependency "shotgun"
|
24
25
|
s.add_development_dependency "randexp", "~>0.1.5"
|
25
26
|
s.add_development_dependency "rack-test", "~>0.5.3"
|
data/spec/app.rb
CHANGED
data/spec/login_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Logged in users" do
|
4
|
+
before do
|
5
|
+
@user = make_user('login' => 'defunkt')
|
6
|
+
login_as @user
|
7
|
+
end
|
8
|
+
|
9
|
+
it "greets the user" do
|
10
|
+
get "/"
|
11
|
+
last_response.body.should eql("Hello there, defunkt!")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "logs the user out" do
|
15
|
+
get "/"
|
16
|
+
|
17
|
+
get "/logout"
|
18
|
+
last_response.status.should eql(302)
|
19
|
+
last_response.headers['Location'].should eql("https://github.com")
|
20
|
+
|
21
|
+
get "/"
|
22
|
+
last_response.status.should eql(302)
|
23
|
+
last_response.headers['Location'].should =~ %r{^https://github\.com/login/oauth/authorize}
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
require "bundler/setup"
|
2
2
|
|
3
|
-
|
3
|
+
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
|
4
4
|
|
5
5
|
require 'pp'
|
6
|
-
|
7
6
|
require 'rack/test'
|
7
|
+
require 'ruby-debug'
|
8
|
+
|
9
|
+
require 'sinatra/auth/github'
|
10
|
+
require 'sinatra/auth/github/test/test_helper'
|
11
|
+
|
12
|
+
require 'app'
|
8
13
|
|
9
14
|
RSpec.configure do |config|
|
10
15
|
config.include(Rack::Test::Methods)
|
16
|
+
config.include(Sinatra::Auth::Github::Test::Helper)
|
11
17
|
|
12
18
|
def app
|
13
|
-
Example
|
19
|
+
Example::App
|
14
20
|
end
|
15
21
|
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Corey Donohoe
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05-
|
18
|
+
date: 2012-05-17 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -72,12 +72,12 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
hash:
|
75
|
+
hash: 15
|
76
76
|
segments:
|
77
77
|
- 0
|
78
78
|
- 4
|
79
|
-
-
|
80
|
-
version: 0.4.
|
79
|
+
- 0
|
80
|
+
version: 0.4.0
|
81
81
|
type: :runtime
|
82
82
|
version_requirements: *id004
|
83
83
|
- !ruby/object:Gem::Dependency
|
@@ -102,12 +102,11 @@ dependencies:
|
|
102
102
|
requirements:
|
103
103
|
- - ~>
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
hash:
|
105
|
+
hash: 3
|
106
106
|
segments:
|
107
107
|
- 2
|
108
108
|
- 0
|
109
|
-
|
110
|
-
version: 2.0.0
|
109
|
+
version: "2.0"
|
111
110
|
type: :development
|
112
111
|
version_requirements: *id006
|
113
112
|
- !ruby/object:Gem::Dependency
|
@@ -187,12 +186,14 @@ files:
|
|
187
186
|
- Rakefile
|
188
187
|
- config.ru
|
189
188
|
- lib/sinatra/auth/github.rb
|
189
|
+
- lib/sinatra/auth/github/test/test_helper.rb
|
190
|
+
- lib/sinatra/auth/github/version.rb
|
190
191
|
- lib/sinatra/auth/views/401.html
|
191
192
|
- lib/sinatra/auth/views/securocat.png
|
192
193
|
- lib/sinatra_auth_github.rb
|
193
194
|
- sinatra_auth_github.gemspec
|
194
195
|
- spec/app.rb
|
195
|
-
- spec/
|
196
|
+
- spec/login_spec.rb
|
196
197
|
- spec/spec_helper.rb
|
197
198
|
has_rdoc: true
|
198
199
|
homepage: http://github.com/atmos/sinatra_auth_github
|
@@ -230,5 +231,5 @@ specification_version: 3
|
|
230
231
|
summary: A sinatra extension for easy oauth integration with github
|
231
232
|
test_files:
|
232
233
|
- spec/app.rb
|
233
|
-
- spec/
|
234
|
+
- spec/login_spec.rb
|
234
235
|
- spec/spec_helper.rb
|
data/spec/quality_spec.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe "The library itself" do
|
4
|
-
Rspec::Matchers.define :have_no_tab_characters do
|
5
|
-
match do |filename|
|
6
|
-
@failing_lines = []
|
7
|
-
File.readlines(filename).each_with_index do |line,number|
|
8
|
-
@failing_lines << number + 1 if line =~ /\t/
|
9
|
-
end
|
10
|
-
@failing_lines.empty?
|
11
|
-
end
|
12
|
-
|
13
|
-
failure_message_for_should do |filename|
|
14
|
-
"The file #{filename} has tab characters on lines #{@failing_lines.join(', ')}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Rspec::Matchers.define :have_no_extraneous_spaces do
|
19
|
-
match do |filename|
|
20
|
-
@failing_lines = []
|
21
|
-
File.readlines(filename).each_with_index do |line,number|
|
22
|
-
next if line =~ /^\s+#.*\s+\n$/
|
23
|
-
@failing_lines << number + 1 if line =~ /\s+\n$/
|
24
|
-
end
|
25
|
-
@failing_lines.empty?
|
26
|
-
end
|
27
|
-
|
28
|
-
failure_message_for_should do |filename|
|
29
|
-
"The file #{filename} has spaces on the EOL on lines #{@failing_lines.join(', ')}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it "has no tab characters" do
|
34
|
-
Dir.chdir(File.dirname(__FILE__) + '/..') do
|
35
|
-
Dir.glob("./lib/**/*.rb").each do |filename|
|
36
|
-
filename.should have_no_tab_characters
|
37
|
-
filename.should have_no_extraneous_spaces
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|