Permalink
Browse files

Improved test coverage for Capistrano::ServerDefinition.default_user

  • Loading branch information...
1 parent 3fe29b7 commit 7b4cc3af720edeee1ce9bcbc1fc0d40396177e8f @rmm5t rmm5t committed May 10, 2008
Showing with 14 additions and 1 deletion.
  1. +14 −1 test/server_definition_test.rb
@@ -62,6 +62,19 @@ def test_new_with_options_should_keep_options
server = Capistrano::ServerDefinition.new("www.capistrano.test", :primary => true)
assert_equal true, server.options[:primary]
end
+
+ def test_default_user_should_try_to_guess_username
+ ENV.stubs(:[]).returns(nil)
+ assert_equal "not-specified", Capistrano::ServerDefinition.default_user
+
+ ENV.stubs(:[]).returns(nil)
+ ENV.stubs(:[]).with("USERNAME").returns("ryan")
+ assert_equal "ryan", Capistrano::ServerDefinition.default_user
+
+ ENV.stubs(:[]).returns(nil)
+ ENV.stubs(:[]).with("USER").returns("jamis")
+ assert_equal "jamis", Capistrano::ServerDefinition.default_user
+ end
def test_comparison_should_match_when_host_user_port_are_same
s1 = server("jamis@www.capistrano.test:8080")
@@ -105,4 +118,4 @@ def test_to_s
assert_equal "jamis@www.capistrano.test", server("jamis@www.capistrano.test").to_s
assert_equal "jamis@www.capistrano.test:1234", server("jamis@www.capistrano.test:1234").to_s
end
-end
+end

0 comments on commit 7b4cc3a

Please sign in to comment.