File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ def delete!(keys)
3131 write_keys_file { |keys_file | keys_file . write new_content }
3232 end
3333
34+ def github_users
35+ # http://rubular.com/r/2LjIGaKObz
36+ regex = %r{github\. com/(.+)}
37+ keys_file_content . scan ( regex ) . flatten . uniq . sort
38+ end
39+
3440 private
3541
3642 def append_keys_file ( &block )
Original file line number Diff line number Diff line change 197197 end
198198 end
199199 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
200218end
You can’t perform that action at this time.
0 commit comments