spec/foreman/cli_spec.rb in foreman-0.31.0 vs spec/foreman/cli_spec.rb in foreman-0.32.0

- old
+ new

@@ -87,7 +87,56 @@ subject.check end end end end + + describe "run" do + describe "with a valid Procfile" do + before { write_procfile } + + describe "and a command" do + let(:command) { ["ls", "-l"] } + + before(:each) do + stub(subject).exec + end + + it "should load the environment file" do + write_env + preserving_env do + subject.run *command + ENV["FOO"].should == "bar" + end + + ENV["FOO"].should be_nil + end + + it "should runute the command as a string" do + mock(subject).exec(command.join(" ")) + subject.run *command + end + end + + describe "and a non-existent command" do + let(:command) { "iuhtngrglhulhdfg" } + + it "should print an error" do + mock_error(subject, "command not found: #{command}") do + subject.run command + end + end + end + + describe "and a non-executable command" do + let(:command) { __FILE__ } + + it "should print an error" do + mock_error(subject, "not executable: #{command}") do + subject.run command + end + end + end + end + end end