Skip to content

Commit

Permalink
Only stub host user for SSHKit version <= 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
robd committed Jul 15, 2015
1 parent 9fa384f commit 2599b1c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/airbrussh/formatter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def setup
@user = "test_user"

# Hack to allow SSHKit's local backend to work on Windows
Etc.stubs(:getpwuid => stub(:name => "user"))
Etc.stubs(:getpwuid => stub(:name => @user))

# Force SSHKit to use ANSI color (CI $stdout may not be a TTY)
@sshkit_color_orig = ENV["SSHKIT_COLOR"]
Expand Down Expand Up @@ -125,7 +125,7 @@ def test_formats_failing_execute_with_color
expected_output = [
" 01 \e[0;33;49mecho hi\e[0m\n",
" 01 hi\n",
/ \e\[0;32;49m✔ 01 test_user@localhost\e\[0m \e\[0;90;49m\d.\d+s\e\[0m\n/,
/ \e\[0;32;49m✔ 01 #{@user}@localhost\e\[0m \e\[0;90;49m\d.\d+s\e\[0m\n/,
" 02 \e[0;33;49mls _file_does_not_exist\e[0m\n"
]

Expand Down Expand Up @@ -336,7 +336,10 @@ def on_local(task_name=nil, &block)
local_backend = SSHKit::Backend::Local.new(&block)
# Note: The Local backend default log changed to include the user name around version 1.7.1
# Therefore we inject a user in order to make the logging consistent in old versions (i.e. 1.6.1)
local_backend.instance_variable_get(:@host).user = @user
unless sshkit_after?("1.6.1")
local_backend.instance_variable_get(:@host).stubs(:user => @user)
end

local_backend.run
end
end
Expand Down

0 comments on commit 2599b1c

Please sign in to comment.