spec/cukeforker/worker_spec.rb in cukeforker-0.2.1 vs spec/cukeforker/worker_spec.rb in cukeforker-0.2.2

- old
+ new

@@ -23,10 +23,23 @@ it "has a stderr file that includes the line number in its name" do worker.stderr.should == "some/path/some_feature_51.stderr" end end + context "running a scenario with multiple report formats" do + formats = [ :json, :junit ] + path = "some/path" + let(:worker) { Worker.new("some/feature:51", formats, path) } + + it "has an output file for each format specified" do + expected_args = formats.flat_map do |f| + %W[--format #{f} --out #{path}/some_feature_51.#{f}] + end + worker.args.each_cons(expected_args.size).include?(expected_args).should be_true + end + end + it "creates an argument string based on the given parameters" do worker.args.should == %w{--format json --out some/path/some_feature.json --extra args some/feature } end it "has an output file" do @@ -113,7 +126,24 @@ worker.should be_finished Process.stub(:waitpid2).and_raise(Errno::ESRCH) worker.should be_finished end + + it "can kill the child process" do + worker.stub(:pid => $$) + + Process.should_receive(:kill) + Process.should_receive(:wait) + + worker.kill + end + + it "ignores failures when killing the child" do + worker.stub(:pid => $$) + + Process.should_receive(:kill).and_raise(Errno::ECHILD) + worker.kill.should be_nil + end + end # Worker end # CukeForker