Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions spec/common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,43 +66,49 @@ class TestClass
end
end

it "command ok exit ok" do
expect(subject.run("true")).to be_true
end

it "command ok exit bad" do
expect { subject.run("false") }.to raise_error
end

it "command bad" do
expect { subject.run("XXXXX") }.to raise_error
end
context "with real execution" do
before do
Kernel.should_receive(:spawn).and_call_original
end

context "with :return_exitstatus => true" do
it "command ok exit ok" do
expect(subject.run("true", :return_exitstatus => true)).to eq(0)
expect(subject.run("true")).to be_true
end

it "command ok exit bad" do
expect(subject.run("false", :return_exitstatus => true)).to eq(1)
expect { subject.run("false") }.to raise_error
end

it "command bad" do
expect(subject.run("XXXXX", :return_exitstatus => true)).to be_nil
expect { subject.run("XXXXX") }.to raise_error
end
end

context "with :return_output => true" do
it "command ok exit ok" do
expect(subject.run("echo \"Hello World\"", :return_output => true)).to eq("Hello World\n")
end
context "with :return_exitstatus => true" do
it "command ok exit ok" do
expect(subject.run("true", :return_exitstatus => true)).to eq(0)
end

it "command ok exit bad" do
expect { subject.run("false", :return_output => true) }.to raise_error
it "command ok exit bad" do
expect(subject.run("false", :return_exitstatus => true)).to eq(1)
end

it "command bad" do
expect(subject.run("XXXXX", :return_exitstatus => true)).to be_nil
end
end

it "command bad" do
expect { subject.run("XXXXX", :return_output => true) }.to raise_error
context "with :return_output => true" do
it "command ok exit ok" do
expect(subject.run("echo \"Hello World\"", :return_output => true)).to eq("Hello World\n")
end

it "command ok exit bad" do
expect { subject.run("false", :return_output => true) }.to raise_error
end

it "command bad" do
expect { subject.run("XXXXX", :return_output => true) }.to raise_error
end
end
end

Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'

config.before do
Kernel.stub(:spawn).and_raise("Spawning is not permitted in specs. Please change your spec to use expectations/stubs.")
end
end

def data_file_path(to)
Expand Down