github-auth 1.2.0 → 2.0.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.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +72 -0
- data/README.md +32 -15
- data/Rakefile +1 -0
- data/bin/gh-auth +1 -1
- data/lib/github/auth.rb +1 -0
- data/lib/github/auth/cli.rb +22 -46
- data/lib/github/auth/keys_file.rb +6 -0
- data/lib/github/auth/options.rb +64 -0
- data/lib/github/auth/version.rb +1 -1
- data/spec/acceptance/github/auth/cli_spec.rb +31 -4
- data/spec/support/capture_stdout.rb +11 -0
- data/spec/unit/github/auth/keys_file_spec.rb +18 -0
- metadata +6 -4
- data/spec/unit/github/auth/cli_spec.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc5ca2cbe7d8acf279d3b54a335e34432cbce149
|
4
|
+
data.tar.gz: 24ecd142974160d3205ff3da30c823a179fe69d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa37238d36f4d2dc35ee8b51e9b09f34edea0012f00fa5dfe3bf0ac1d934d302d6ace5377f486b9c5ab692c48bf5432463fc6a9b661c71e0315cd60dfc4e26bf
|
7
|
+
data.tar.gz: a650e4290cfd5a0d53cc86896af98909dce3f4bdb5c1019f3331fadbce4e98b1d525ec34045863318f5cc33bff3f9e2fe514167f5c172f7a2e34efc62f13f703
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
##v2.0.0
|
4
|
+
*2013-10-22*
|
5
|
+
|
6
|
+
[\[22 commits\]](https://github.com/chrishunt/github-auth/compare/v1.2.0...v2.0.0)
|
7
|
+
|
8
|
+
*note:* Option syntax has changed in this release as a result of switching to
|
9
|
+
`OptionParser`. See the [`README`](https://github.com/chrishunt/github-auth/blob/master/README.md)
|
10
|
+
for usage instructions.
|
11
|
+
|
12
|
+
- [Add `--list` command](https://github.com/chrishunt/github-auth/pull/14)
|
13
|
+
- [Use `OptionParser` for parsing CLI options](https://github.com/chrishunt/github-auth/pull/16)
|
14
|
+
|
3
15
|
##v1.2.0
|
4
16
|
*2013-08-20*
|
5
17
|
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
github-auth (2.0.0)
|
5
|
+
httparty (~> 0.11.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
cane (2.6.0)
|
11
|
+
parallel
|
12
|
+
cane-hashcheck (1.2.0)
|
13
|
+
cane
|
14
|
+
colorize (0.5.8)
|
15
|
+
coveralls (0.6.7)
|
16
|
+
colorize
|
17
|
+
multi_json (~> 1.3)
|
18
|
+
rest-client
|
19
|
+
simplecov (>= 0.7)
|
20
|
+
thor
|
21
|
+
daemons (1.1.9)
|
22
|
+
diff-lcs (1.2.4)
|
23
|
+
eventmachine (1.0.3)
|
24
|
+
httparty (0.11.0)
|
25
|
+
multi_json (~> 1.0)
|
26
|
+
multi_xml (>= 0.5.2)
|
27
|
+
mime-types (1.24)
|
28
|
+
multi_json (1.7.9)
|
29
|
+
multi_xml (0.5.5)
|
30
|
+
parallel (0.9.0)
|
31
|
+
rack (1.5.2)
|
32
|
+
rack-protection (1.5.0)
|
33
|
+
rack
|
34
|
+
rake (10.1.0)
|
35
|
+
rest-client (1.6.7)
|
36
|
+
mime-types (>= 1.16)
|
37
|
+
rspec (2.14.1)
|
38
|
+
rspec-core (~> 2.14.0)
|
39
|
+
rspec-expectations (~> 2.14.0)
|
40
|
+
rspec-mocks (~> 2.14.0)
|
41
|
+
rspec-core (2.14.5)
|
42
|
+
rspec-expectations (2.14.2)
|
43
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
44
|
+
rspec-mocks (2.14.3)
|
45
|
+
simplecov (0.7.1)
|
46
|
+
multi_json (~> 1.0)
|
47
|
+
simplecov-html (~> 0.7.1)
|
48
|
+
simplecov-html (0.7.1)
|
49
|
+
sinatra (1.4.3)
|
50
|
+
rack (~> 1.4)
|
51
|
+
rack-protection (~> 1.4)
|
52
|
+
tilt (~> 1.3, >= 1.3.4)
|
53
|
+
thin (1.5.1)
|
54
|
+
daemons (>= 1.0.9)
|
55
|
+
eventmachine (>= 0.12.6)
|
56
|
+
rack (>= 1.0.0)
|
57
|
+
thor (0.18.1)
|
58
|
+
tilt (1.4.1)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
bundler (~> 1.3)
|
65
|
+
cane (~> 2.6.0)
|
66
|
+
cane-hashcheck (~> 1.2.0)
|
67
|
+
coveralls (~> 0.6.7)
|
68
|
+
github-auth!
|
69
|
+
rake (~> 10.1.0)
|
70
|
+
rspec (~> 2.14)
|
71
|
+
sinatra (~> 1.4.3)
|
72
|
+
thin (~> 1.5.1)
|
data/README.md
CHANGED
@@ -23,28 +23,37 @@ After you've [installed](#installation) `gh-auth`, you can give me ssh access
|
|
23
23
|
with:
|
24
24
|
|
25
25
|
```bash
|
26
|
-
$ gh-auth add chrishunt
|
26
|
+
$ gh-auth --add chrishunt
|
27
27
|
Adding 2 key(s) to '/Users/chris/.ssh/authorized_keys'
|
28
28
|
```
|
29
29
|
|
30
30
|
That was easy! When we're done working, you can revoke my access with:
|
31
31
|
|
32
32
|
```bash
|
33
|
-
$ gh-auth remove chrishunt
|
33
|
+
$ gh-auth --remove chrishunt
|
34
34
|
Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
35
35
|
```
|
36
36
|
|
37
37
|
You can add and remove any number of users at the same time.
|
38
38
|
|
39
39
|
```bash
|
40
|
-
$ gh-auth add chrishunt
|
40
|
+
$ gh-auth --add chrishunt,zachmargolis
|
41
41
|
Adding 4 key(s) to '/Users/chris/.ssh/authorized_keys'
|
42
42
|
|
43
|
-
$ gh-auth
|
43
|
+
$ gh-auth --list
|
44
|
+
Added users: chrishunt, zachmargolis
|
45
|
+
|
46
|
+
$ gh-auth --remove chrishunt
|
44
47
|
Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
45
48
|
|
46
|
-
$ gh-auth
|
49
|
+
$ gh-auth --list
|
50
|
+
Added users: zachmargolis
|
51
|
+
|
52
|
+
$ gh-auth --remove zachmargolis
|
47
53
|
Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
54
|
+
|
55
|
+
$ gh-auth --list
|
56
|
+
Added users:
|
48
57
|
```
|
49
58
|
|
50
59
|
## Sections
|
@@ -72,7 +81,13 @@ Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
|
72
81
|
`gh-auth` can be used from the command line after the gem has been installed.
|
73
82
|
|
74
83
|
```bash
|
75
|
-
usage: gh-auth [--version] [add
|
84
|
+
usage: gh-auth [--version] [--list] [--add|--remove] <username>
|
85
|
+
|
86
|
+
options:
|
87
|
+
--add doug,sally Add GitHub users
|
88
|
+
--remove doug,sally Remove GitHub users
|
89
|
+
--list List all GitHub users added
|
90
|
+
--version Show version
|
76
91
|
```
|
77
92
|
|
78
93
|
### In Your Project
|
@@ -84,14 +99,10 @@ too.
|
|
84
99
|
require 'github/auth'
|
85
100
|
|
86
101
|
# Add keys for GitHub user 'chrishunt'
|
87
|
-
Github::Auth::CLI.new
|
88
|
-
add chrishunt
|
89
|
-
)).execute
|
102
|
+
Github::Auth::CLI.new.execute %w(--add chrishunt)
|
90
103
|
|
91
104
|
# Remove keys for GitHub user 'chrishunt'
|
92
|
-
Github::Auth::CLI.new
|
93
|
-
remove chrishunt
|
94
|
-
)).execute
|
105
|
+
Github::Auth::CLI.new.execute %w(--remove chrishunt)
|
95
106
|
```
|
96
107
|
|
97
108
|
## Installation
|
@@ -102,7 +113,13 @@ Install the `github-auth` gem:
|
|
102
113
|
$ gem install github-auth
|
103
114
|
|
104
115
|
$ gh-auth
|
105
|
-
usage: gh-auth [--version] [add
|
116
|
+
usage: gh-auth [--version] [--list] [--add|--remove] <username>
|
117
|
+
|
118
|
+
options:
|
119
|
+
--add doug,sally Add GitHub users
|
120
|
+
--remove doug,sally Remove GitHub users
|
121
|
+
--list List all GitHub users added
|
122
|
+
--version Show version
|
106
123
|
```
|
107
124
|
|
108
125
|
### SSH Public Key Authentication (Mac OS X)
|
@@ -130,7 +147,7 @@ First, authorize yourself for ssh. (Make sure to replace 'chrishunt' with
|
|
130
147
|
*your* GitHub username)
|
131
148
|
|
132
149
|
```bash
|
133
|
-
$ gh-auth add chrishunt
|
150
|
+
$ gh-auth --add chrishunt
|
134
151
|
Adding 2 key(s) to '/Users/chris/.ssh/authorized_keys'
|
135
152
|
```
|
136
153
|
|
@@ -146,7 +163,7 @@ $ ssh -o PreferredAuthentications=publickey localhost
|
|
146
163
|
Next, remove your public keys from the keys file:
|
147
164
|
|
148
165
|
```bash
|
149
|
-
$ gh-auth remove chrishunt
|
166
|
+
$ gh-auth --remove chrishunt
|
150
167
|
Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
151
168
|
```
|
152
169
|
|
data/Rakefile
CHANGED
data/bin/gh-auth
CHANGED
data/lib/github/auth.rb
CHANGED
data/lib/github/auth/cli.rb
CHANGED
@@ -1,23 +1,11 @@
|
|
1
1
|
module Github::Auth
|
2
2
|
# Command Line Interface for parsing and executing commands
|
3
3
|
class CLI
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :options
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@command = argv.shift
|
10
|
-
@usernames = argv
|
11
|
-
end
|
12
|
-
|
13
|
-
def execute
|
14
|
-
if COMMANDS.include?(command) && !usernames.empty?
|
15
|
-
send command
|
16
|
-
elsif command == '--version'
|
17
|
-
print_version
|
18
|
-
else
|
19
|
-
print_usage
|
20
|
-
end
|
6
|
+
def execute(args)
|
7
|
+
@options = Options.new.parse(args)
|
8
|
+
send options.command
|
21
9
|
end
|
22
10
|
|
23
11
|
private
|
@@ -32,34 +20,30 @@ module Github::Auth
|
|
32
20
|
"Removing #{keys.count} key(s) from '#{keys_file.path}'"
|
33
21
|
end
|
34
22
|
|
35
|
-
def
|
36
|
-
puts
|
37
|
-
rescue_keys_file_errors { keys_file.send action, keys }
|
23
|
+
def list
|
24
|
+
puts "Added users: #{keys_file.github_users.join(', ')}"
|
38
25
|
end
|
39
26
|
|
40
|
-
def
|
41
|
-
|
42
|
-
rescue KeysFile::PermissionDeniedError
|
43
|
-
print_permission_denied
|
44
|
-
rescue KeysFile::FileDoesNotExistError
|
45
|
-
print_file_does_not_exist
|
27
|
+
def version
|
28
|
+
puts Github::Auth::VERSION
|
46
29
|
end
|
47
30
|
|
48
|
-
def
|
49
|
-
puts
|
31
|
+
def usage
|
32
|
+
puts options.usage
|
50
33
|
end
|
51
34
|
|
52
|
-
def
|
53
|
-
puts
|
35
|
+
def on_keys_file(action, message)
|
36
|
+
puts message
|
37
|
+
rescue_keys_file_errors { keys_file.send action, keys }
|
54
38
|
end
|
55
39
|
|
56
|
-
def
|
40
|
+
def rescue_keys_file_errors
|
41
|
+
yield
|
42
|
+
rescue KeysFile::PermissionDeniedError
|
57
43
|
puts 'Permission denied!'
|
58
44
|
puts
|
59
45
|
puts "Make sure you have write permissions for '#{keys_file.path}'"
|
60
|
-
|
61
|
-
|
62
|
-
def print_file_does_not_exist
|
46
|
+
rescue KeysFile::FileDoesNotExistError
|
63
47
|
puts "Keys file does not exist!"
|
64
48
|
puts
|
65
49
|
puts "Create one now and try again:"
|
@@ -67,18 +51,8 @@ module Github::Auth
|
|
67
51
|
puts " $ touch #{keys_file.path}"
|
68
52
|
end
|
69
53
|
|
70
|
-
def print_github_user_does_not_exist(username)
|
71
|
-
puts "Github user '#{username}' does not exist"
|
72
|
-
end
|
73
|
-
|
74
|
-
def print_github_unavailable
|
75
|
-
puts "Github appears to be unavailable :("
|
76
|
-
puts
|
77
|
-
puts "https://status.github.com"
|
78
|
-
end
|
79
|
-
|
80
54
|
def keys
|
81
|
-
@keys ||= usernames.map { |
|
55
|
+
@keys ||= options.usernames.map { |user| keys_for user }.flatten.compact
|
82
56
|
end
|
83
57
|
|
84
58
|
def keys_for(username)
|
@@ -87,9 +61,11 @@ module Github::Auth
|
|
87
61
|
username: username
|
88
62
|
).keys
|
89
63
|
rescue Github::Auth::KeysClient::GithubUserDoesNotExistError
|
90
|
-
|
64
|
+
puts "Github user '#{username}' does not exist"
|
91
65
|
rescue Github::Auth::KeysClient::GithubUnavailableError
|
92
|
-
|
66
|
+
puts "Github appears to be unavailable :("
|
67
|
+
puts
|
68
|
+
puts "https://status.github.com"
|
93
69
|
end
|
94
70
|
|
95
71
|
def keys_file
|
@@ -31,6 +31,12 @@ module Github::Auth
|
|
31
31
|
write_keys_file { |keys_file| keys_file.write new_content }
|
32
32
|
end
|
33
33
|
|
34
|
+
def github_users
|
35
|
+
# http://rubular.com/r/zXCkewmm0i
|
36
|
+
regex = %r{github\.com/(\S+)}
|
37
|
+
keys_file_content.scan(regex).flatten.uniq.sort
|
38
|
+
end
|
39
|
+
|
34
40
|
private
|
35
41
|
|
36
42
|
def append_keys_file(&block)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Github::Auth
|
4
|
+
# Parses command line options
|
5
|
+
class Options
|
6
|
+
attr_reader :parser
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@parser = OptionParser.new do |opts|
|
10
|
+
opts.banner = [
|
11
|
+
'usage: gh-auth',
|
12
|
+
'[--version]',
|
13
|
+
'[--list]',
|
14
|
+
'[--add|--remove]',
|
15
|
+
'<username>'
|
16
|
+
].join(' ')
|
17
|
+
|
18
|
+
opts.separator "\noptions:"
|
19
|
+
|
20
|
+
opts.on(
|
21
|
+
'--add doug,sally', Array, 'Add GitHub users'
|
22
|
+
) do |usernames|
|
23
|
+
raise OptionParser::MissingArgument if usernames.empty?
|
24
|
+
@command = 'add'
|
25
|
+
@usernames = usernames
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on(
|
29
|
+
'--remove doug,sally', Array, 'Remove GitHub users'
|
30
|
+
) do |usernames|
|
31
|
+
raise OptionParser::MissingArgument if usernames.empty?
|
32
|
+
@command = 'remove'
|
33
|
+
@usernames = usernames
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on('--list', 'List all GitHub users added') do
|
37
|
+
@command = 'list'
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on('--version', 'Show version') do
|
41
|
+
@command = 'version'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def command
|
47
|
+
@command ||= 'usage'
|
48
|
+
end
|
49
|
+
|
50
|
+
def usernames
|
51
|
+
@usernames ||= []
|
52
|
+
end
|
53
|
+
|
54
|
+
def usage
|
55
|
+
parser.help
|
56
|
+
end
|
57
|
+
|
58
|
+
def parse(args)
|
59
|
+
parser.parse(args)
|
60
|
+
ensure
|
61
|
+
return self
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/github/auth/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'support/capture_stdout'
|
2
3
|
require 'support/mock_github_server'
|
3
4
|
require 'github/auth'
|
4
5
|
|
@@ -10,8 +11,8 @@ describe Github::Auth::CLI do
|
|
10
11
|
|
11
12
|
after { keys_file.unlink }
|
12
13
|
|
13
|
-
def cli
|
14
|
-
described_class.new
|
14
|
+
def cli
|
15
|
+
described_class.new.tap do |cli|
|
15
16
|
cli.stub(
|
16
17
|
github_hostname: hostname,
|
17
18
|
keys_file_path: keys_file.path
|
@@ -20,17 +21,43 @@ describe Github::Auth::CLI do
|
|
20
21
|
end
|
21
22
|
|
22
23
|
it 'adds and removes keys from the keys file' do
|
23
|
-
cli
|
24
|
+
cli.execute %w(--add chrishunt)
|
24
25
|
|
25
26
|
keys_file.read.tap do |keys_file_content|
|
26
27
|
keys.each { |key| expect(keys_file_content).to include key.to_s }
|
27
28
|
end
|
28
29
|
|
29
|
-
cli
|
30
|
+
cli.execute %w(--remove chrishunt)
|
30
31
|
|
31
32
|
expect(keys_file.read).to be_empty
|
32
33
|
|
33
34
|
keys_file.unlink
|
34
35
|
end
|
36
|
+
|
37
|
+
it 'lists users from the keys file' do
|
38
|
+
cli.execute %w(--add chrishunt)
|
39
|
+
|
40
|
+
output = capture_stdout do
|
41
|
+
cli.execute %w(--list)
|
42
|
+
end
|
43
|
+
|
44
|
+
expect(output).to include('chrishunt')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'prints version information' do
|
48
|
+
output = capture_stdout do
|
49
|
+
cli.execute %w(--version)
|
50
|
+
end
|
51
|
+
|
52
|
+
expect(output).to include Github::Auth::VERSION
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'prints usage for invalid arguments' do
|
56
|
+
[[], %w(invalid), %w(--add)].each do |invalid_arguments|
|
57
|
+
expect(
|
58
|
+
capture_stdout { cli.execute invalid_arguments }
|
59
|
+
).to include 'usage: gh-auth'
|
60
|
+
end
|
61
|
+
end
|
35
62
|
end
|
36
63
|
end
|
@@ -197,4 +197,22 @@ describe Github::Auth::KeysFile do
|
|
197
197
|
end
|
198
198
|
end
|
199
199
|
end
|
200
|
+
|
201
|
+
describe '#github_users' do
|
202
|
+
let(:keys) {[
|
203
|
+
Github::Auth::Key.new('jay', 'abc123'),
|
204
|
+
Github::Auth::Key.new('chris', 'def456'),
|
205
|
+
Github::Auth::Key.new('chris', 'ghi789'),
|
206
|
+
]}
|
207
|
+
|
208
|
+
before do
|
209
|
+
keys_file.write keys.join("\n")
|
210
|
+
keys_file.write "\n"
|
211
|
+
keys_file.rewind
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'returns a uniq, ordered list of github users' do
|
215
|
+
expect(subject.github_users).to eq(%w(chris jay))
|
216
|
+
end
|
217
|
+
end
|
200
218
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- CHANGELOG.md
|
150
150
|
- CONTRIBUTING.md
|
151
151
|
- Gemfile
|
152
|
+
- Gemfile.lock
|
152
153
|
- LICENSE.txt
|
153
154
|
- README.md
|
154
155
|
- Rakefile
|
@@ -160,13 +161,14 @@ files:
|
|
160
161
|
- lib/github/auth/key.rb
|
161
162
|
- lib/github/auth/keys_client.rb
|
162
163
|
- lib/github/auth/keys_file.rb
|
164
|
+
- lib/github/auth/options.rb
|
163
165
|
- lib/github/auth/version.rb
|
164
166
|
- spec/acceptance/github/auth/cli_spec.rb
|
165
167
|
- spec/acceptance/github/auth/keys_client_spec.rb
|
166
168
|
- spec/acceptance/github/auth/keys_file_spec.rb
|
167
169
|
- spec/spec_helper.rb
|
170
|
+
- spec/support/capture_stdout.rb
|
168
171
|
- spec/support/mock_github_server.rb
|
169
|
-
- spec/unit/github/auth/cli_spec.rb
|
170
172
|
- spec/unit/github/auth/keys_client_spec.rb
|
171
173
|
- spec/unit/github/auth/keys_file_spec.rb
|
172
174
|
homepage: https://github.com/chrishunt/github-auth
|
@@ -198,7 +200,7 @@ test_files:
|
|
198
200
|
- spec/acceptance/github/auth/keys_client_spec.rb
|
199
201
|
- spec/acceptance/github/auth/keys_file_spec.rb
|
200
202
|
- spec/spec_helper.rb
|
203
|
+
- spec/support/capture_stdout.rb
|
201
204
|
- spec/support/mock_github_server.rb
|
202
|
-
- spec/unit/github/auth/cli_spec.rb
|
203
205
|
- spec/unit/github/auth/keys_client_spec.rb
|
204
206
|
- spec/unit/github/auth/keys_file_spec.rb
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'github/auth/cli'
|
3
|
-
|
4
|
-
describe Github::Auth::CLI do
|
5
|
-
let(:argv) { [] }
|
6
|
-
|
7
|
-
subject { described_class.new argv }
|
8
|
-
|
9
|
-
describe '#execute' do
|
10
|
-
shared_examples_for 'a method that prints usage' do
|
11
|
-
it 'prints the usage' do
|
12
|
-
subject.should_receive(:print_usage)
|
13
|
-
subject.execute
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when missing a command' do
|
18
|
-
let(:argv) { [] }
|
19
|
-
it_should_behave_like 'a method that prints usage'
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'with an invalid command' do
|
23
|
-
let(:argv) { ['invalid'] }
|
24
|
-
it_should_behave_like 'a method that prints usage'
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'when no usernames are provide' do
|
28
|
-
let(:argv) { ['add'] }
|
29
|
-
it_should_behave_like 'a method that prints usage'
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'with a valid action and usernames' do
|
33
|
-
let(:action) { 'add' }
|
34
|
-
let(:argv) { [action, 'chrishunt'] }
|
35
|
-
|
36
|
-
it 'calls the method matching the action name' do
|
37
|
-
subject.should_receive(action)
|
38
|
-
subject.execute
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'with the --version command' do
|
43
|
-
let(:argv) { ['--version'] }
|
44
|
-
|
45
|
-
it 'prints version information' do
|
46
|
-
subject.should_receive(:print_version)
|
47
|
-
subject.execute
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|