-
Notifications
You must be signed in to change notification settings - Fork 301
/
account_information_controller_test.rb
61 lines (49 loc) · 2.54 KB
/
account_information_controller_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require File.dirname(__FILE__) + '/test_helper'
class Twurl::AccountInformationController::DispatchWithNoAuthorizedAccountsTest < MiniTest::Unit::TestCase
attr_reader :options, :client, :controller
def setup
@options = Twurl::Options.new
@client = Twurl::OAuthClient.load_new_client_from_options(options)
@controller = Twurl::AccountInformationController.new(client, options)
mock(Twurl::OAuthClient.rcfile).empty? { true }
end
def test_message_indicates_when_no_accounts_are_authorized
mock(Twurl::CLI).puts(Twurl::AccountInformationController::NO_AUTHORIZED_ACCOUNTS_MESSAGE).times(1)
controller.dispatch
end
end
class Twurl::AccountInformationController::DispatchWithOneAuthorizedAccountTest < MiniTest::Unit::TestCase
attr_reader :options, :client, :controller
def setup
@options = Twurl::Options.test_exemplar
@client = Twurl::OAuthClient.load_new_client_from_options(options)
mock(Twurl::OAuthClient.rcfile).save.times(1)
Twurl::OAuthClient.rcfile << client
@controller = Twurl::AccountInformationController.new(client, options)
end
def test_authorized_account_is_displayed_and_marked_as_the_default
mock(Twurl::CLI).puts(client.username).times(1).ordered
mock(Twurl::CLI).puts(" #{client.consumer_key} (default)").times(1).ordered
controller.dispatch
end
end
class Twurl::AccountInformationController::DispatchWithOneUsernameThatHasAuthorizedMultipleAccountsTest < MiniTest::Unit::TestCase
attr_reader :default_client_options, :default_client, :other_client_options, :other_client, :controller
def setup
@default_client_options = Twurl::Options.test_exemplar
@default_client = Twurl::OAuthClient.load_new_client_from_options(default_client_options)
@other_client_options = Twurl::Options.test_exemplar
other_client_options.consumer_key = default_client_options.consumer_key.reverse
@other_client = Twurl::OAuthClient.load_new_client_from_options(other_client_options)
mock(Twurl::OAuthClient.rcfile).save.times(2)
Twurl::OAuthClient.rcfile << default_client
Twurl::OAuthClient.rcfile << other_client
@controller = Twurl::AccountInformationController.new(other_client, other_client_options)
end
def test_authorized_account_is_displayed_and_marked_as_the_default
mock(Twurl::CLI).puts(default_client.username).times(1)
mock(Twurl::CLI).puts(" #{default_client.consumer_key} (default)").times(1)
mock(Twurl::CLI).puts(" #{other_client.consumer_key}").times(1)
controller.dispatch
end
end