Permalink
Browse files

Test coverage for configuration controller.

  • Loading branch information...
1 parent 8162cd2 commit 40ae74504b1c51b5e24c9f97fe475d5ae12d683d Marcel Molina committed Nov 13, 2009
Showing with 27 additions and 0 deletions.
  1. +27 −0 test/configuration_controller_test.rb
@@ -1,2 +1,29 @@
require File.dirname(__FILE__) + '/test_helper'
+class Twurl::ConfigurationController::DispatchDefaultSettingTest < Test::Unit::TestCase
+ def test_setting_default_profile_just_by_username
+ options = Twurl::CLI::Options.test_exemplar
+ client = Twurl::OAuthClient.test_exemplar
+
+ options.subcommands = ['default', client.username]
+ mock(Twurl::OAuthClient).load_client_for_username(client.username).times(1) { client }
+ mock(Twurl::OAuthClient.rcfile).default_profile = client
+ mock(Twurl::OAuthClient.rcfile).save.times(1)
+
+ controller = Twurl::ConfigurationController.new(client, options)
+ controller.dispatch
+ end
+
+ def test_setting_default_profile_by_username_and_consumer_key
+ options = Twurl::CLI::Options.test_exemplar
+ client = Twurl::OAuthClient.test_exemplar
+
+ options.subcommands = ['default', client.username, client.consumer_key]
+ mock(Twurl::OAuthClient).load_client_for_username_and_consumer_key(client.username, client.consumer_key).times(1) { client }
+ mock(Twurl::OAuthClient.rcfile).default_profile = client
+ mock(Twurl::OAuthClient.rcfile).save.times(1)
+
+ controller = Twurl::ConfigurationController.new(client, options)
+ controller.dispatch
+ end
+end

0 comments on commit 40ae745

Please sign in to comment.