Commandクラスにby_user
メソッドを追加する。
module Serverspec
module Type
class Command
def by_user(user)
self.class.new("su -l #{user.shellescape} -c #{@name.shellescape}")
end
end
end
end
require "type/command"
特定ユーザーでログイン後のコマンド実行がテストできる.
describe command('echo $HOME').by_user("www") do
it { should return_stdout "/home/www" }
end