Skip to content

Commit

Permalink
Fix test (random failure)
Browse files Browse the repository at this point in the history
Since the Minitest run tests concurrently, sometimes the "DispatchWithOneAuthorizedAccountTest" class runs after the "DispatchWithOneUsernameThatHasAuthorizedMultipleAccountsTest" run. In this case, "Twurl::OAuthClient.rcfile" has multiple profiles data in there and hence it fails with its mock checks.
  • Loading branch information
smaeda-ks committed Dec 9, 2019
1 parent d2b4884 commit b22bd20
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/account_information_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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.profiles.clear
Twurl::OAuthClient.rcfile << client
@controller = Twurl::AccountInformationController.new(client, options)
end
Expand Down Expand Up @@ -51,10 +52,14 @@ def setup
@controller = Twurl::AccountInformationController.new(other_client, other_client_options)
end

def teardown
Twurl::OAuthClient.rcfile.profiles[default_client.username][other_client.consumer_key].clear
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)
mock(Twurl::CLI).puts(default_client.username).times(1).ordered
mock(Twurl::CLI).puts(" #{default_client.consumer_key} (default)").times(1).ordered
mock(Twurl::CLI).puts(" #{other_client.consumer_key}").times(1).ordered

controller.dispatch
end
Expand Down

0 comments on commit b22bd20

Please sign in to comment.