|
11 | 11 |
|
12 | 12 | after { keys_file.unlink } |
13 | 13 |
|
14 | | - def cli |
15 | | - described_class.new.tap do |cli| |
16 | | - cli.stub( |
17 | | - github_hostname: hostname, |
18 | | - keys_file_path: keys_file.path |
19 | | - ) |
20 | | - end |
| 14 | + def cli(args = []) |
| 15 | + described_class.start \ |
| 16 | + args + [ |
| 17 | + "--path=#{keys_file.path}", |
| 18 | + "--host=#{hostname}" |
| 19 | + ] |
21 | 20 | end |
22 | 21 |
|
23 | 22 | it 'adds and removes keys from the keys file' do |
24 | | - cli.execute %w(--add chrishunt) |
| 23 | + cli %w(add --users=chrishunt) |
25 | 24 |
|
26 | 25 | keys_file.read.tap do |keys_file_content| |
27 | 26 | keys.each { |key| expect(keys_file_content).to include key.to_s } |
28 | 27 | end |
29 | 28 |
|
30 | | - cli.execute %w(--remove chrishunt) |
| 29 | + cli %w(remove --users=chrishunt) |
31 | 30 |
|
32 | 31 | expect(keys_file.read).to be_empty |
33 | 32 |
|
34 | 33 | keys_file.unlink |
35 | 34 | end |
36 | 35 |
|
37 | 36 | it 'lists users from the keys file' do |
38 | | - cli.execute %w(--add chrishunt) |
| 37 | + cli %w(add --users=chrishunt) |
39 | 38 |
|
40 | 39 | output = capture_stdout do |
41 | | - cli.execute %w(--list) |
| 40 | + cli %w(list) |
42 | 41 | end |
43 | 42 |
|
44 | 43 | expect(output).to include('chrishunt') |
45 | 44 | end |
46 | 45 |
|
47 | 46 | it 'supports ssh commands' do |
48 | | - cli.execute %w(--add chrishunt --command) << "tmux attach" |
| 47 | + cli %w(add --users=chrishunt) << '--command=tmux attach' |
49 | 48 |
|
50 | 49 | expect(keys_file.read).to include 'command="tmux attach"' |
51 | 50 |
|
52 | 51 | keys_file.rewind |
53 | | - cli.execute %w(--remove chrishunt) |
| 52 | + cli %w(remove --users=chrishunt) |
54 | 53 |
|
55 | 54 | expect(keys_file.read.strip).to be_empty |
56 | 55 | end |
57 | 56 |
|
58 | 57 | it 'prints version information' do |
59 | 58 | output = capture_stdout do |
60 | | - cli.execute %w(--version) |
| 59 | + cli %w(version) |
61 | 60 | end |
62 | 61 |
|
63 | 62 | expect(output).to include Github::Auth::VERSION |
64 | 63 | end |
65 | | - |
66 | | - it 'prints usage for invalid arguments' do |
67 | | - [[], %w(invalid), %w(--add)].each do |invalid_arguments| |
68 | | - expect( |
69 | | - capture_stdout { cli.execute invalid_arguments } |
70 | | - ).to include 'usage: gh-auth' |
71 | | - end |
72 | | - end |
73 | 64 | end |
74 | 65 | end |
0 commit comments