Skip to content

Commit

Permalink
remove_account
Browse files Browse the repository at this point in the history
  • Loading branch information
autodidacticon committed Oct 30, 2014
1 parent 44e6c41 commit d77998c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/t/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,11 @@ def reach(tweet_id)
say number_with_delimiter(reach.size)
end

desc 'remove_account SCREEN_NAME', 'remove account from t'
def remove_account(account)
@rcfile.remove_profile(account)
end

desc 'reply TWEET_ID MESSAGE', 'Post your Tweet as a reply directed at another person.'
method_option 'all', :aliases => '-a', :type => :boolean, :desc => 'Reply to all users mentioned in the Tweet.'
method_option 'location', :aliases => '-l', :type => :string, :default => nil, :desc => "Add location information. If the optional 'latitude,longitude' parameter is not supplied, looks up location by IP address."
Expand Down
5 changes: 5 additions & 0 deletions lib/t/rcfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def reset
send(:initialize)
end

def remove_profile(profile)
profiles.delete(profile)
write
end

private

def active_profile?
Expand Down
28 changes: 28 additions & 0 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2510,6 +2510,34 @@
end
end

describe '#remove_account' do
before do
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
delete_cli = {
'delete_cli' => {
'dw123' => {
'consumer_key' => 'abc123',
'secret' => 'epzrjvxtumoc',
'token' => '428004849-cebdct6bwobn',
'username' => 'deletecli',
'consumer_secret' => 'asdfasd223sd2'
}
}
}
rcfile = @cli.instance_variable_get(:@rcfile)
rcfile.profiles.merge!(delete_cli)
rcfile.send(:write)
end
it 'has the correct output' do
@cli.remove_account('delete_cli')
@cli.accounts
expect($stdout.string).to eq <<-eos
testcli
abc123 (active)
eos
end
end

describe '#reply' do
before do
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc', 'location' => nil)
Expand Down

0 comments on commit d77998c

Please sign in to comment.