spec/commnad_spec.rb in command_mapper-0.3.1 vs spec/commnad_spec.rb in command_mapper-0.3.2

- old
+ new

@@ -1414,18 +1414,55 @@ subject.popen_command(mode) end end end - describe "#sudo!" do + describe "#sudo_command" do subject { command_class.new({opt1: opt1, arg1: arg1}, command_env: env) } let(:expected_argv) { [command_class.command, "--opt1", opt1, arg1] } it "must pass the command's env and argv, and to IO.popen" do expect(Sudo).to receive(:run).with({command: subject.command_argv}, command_env: env) subject.sudo_command + end + + [ + :askpass, + :background, + :bell, + :close_from, + :chdir, + :preserve_env, + :group, + :set_home, + :host, + :login, + :remove_timestamp, + :reset_timestamp, + :non_interactive, + :preserve_groups, + :prompt, + :chroot, + :role, + :stdin, + :shell, + :type, + :command_timeout, + :other_user, + :user, + ].each do |option| + context "when given the #{option}: keyword argument" do + let(:option) { option } + let(:value) { true } + + it "must pass the #{option}: keyword argument to CommandMapper::Sudo" do + expect(Sudo).to receive(:run).with({option => value, :command => subject.command_argv}, :command_env => env) + + subject.sudo_command(option => value) + end + end end end describe "#to_s" do let(:opt1) { "foo bar" }