spec/lib/baleen/spec_result_display.rb in baleen-0.2.3 vs spec/lib/baleen/spec_result_display.rb in baleen-0.2.4

- old
+ new

@@ -1,47 +1,76 @@ require_relative '../../spec_helper' describe Baleen::ResultDisplay do describe "#summary" do context "when all test passes" do - it "should display Pass" do - result = [ - { - "status_code" => 0, - "container_id" => "aaaaaa", - "log" => "brabrabra", - "file" => "feature/t1.feature" - }, - { - "status_code" => 0, - "container_id" => "bbbbbb", - "log" => "brabrabra", - "file" => "feature/t2.feature" - } - ] - displayer = Baleen::ResultDisplay.new(result, Time.now, Time.now+10) - capture(:stdout) { displayer.summary }.should include 'Pass' + result = [ + { + "status_code" => 0, + "container_id" => "aaaaaa", + "log" => "brabrabra", + "file" => "feature/t1.feature" + }, + { + "status_code" => 0, + "container_id" => "bbbbbb", + "log" => "brabrabra", + "file" => "feature/t2.feature" + } + ] + + context "when output is STDOUT" do + it "should display Pass" do + displayer = Baleen::ResultDisplay.new(result, Time.now, Time.now+10, Kernel) + capture(:stdout) { displayer.summary }.should include 'Pass' + end end + + context "when output is logger" do + it "should contain Pass" do + logger = Baleen::BL.instance + log_file = File.join(Baleen::Configuration.instance.dir, "log", "baleen.log") + + Baleen::ResultDisplay.new(result, Time.now, Time.now+10, logger).summary + expect(File.open(log_file).read).to include 'Pass' + end + end + end context "when some test fails" do - it "should display Fail" do - result = [ - { - "status_code" => 0, - "container_id" => "aaaaaa", - "log" => "brabrabra", - "file" => "feature/t1.feature" - }, - { - "status_code" => 1, - "container_id" => "bbbbbb", - "log" => "brabrabra", - "file" => "feature/t2.feature" - } - ] - displayer = Baleen::ResultDisplay.new(result, Time.now, Time.now+10) - capture(:stdout) { displayer.summary }.should include 'Fail' + result = [ + { + "status_code" => 0, + "container_id" => "aaaaaa", + "log" => "brabrabra", + "file" => "feature/t1.feature" + }, + { + "status_code" => 1, + "container_id" => "bbbbbb", + "log" => "brabrabra", + "file" => "feature/t2.feature" + } + ] + + context "when output is STDOUT" do + it "should display Fail" do + displayer = Baleen::ResultDisplay.new(result, Time.now, Time.now+10, Kernel) + capture(:stdout) { displayer.summary }.should include 'Fail' + end end + + context "when output is logger" do + it "should contain Pass" do + logger = Baleen::BL.instance + log_file = File.join(Baleen::Configuration.instance.dir, "log", "baleen.log") + + Baleen::ResultDisplay.new(result, Time.now, Time.now+10, logger).summary + expect(File.open(log_file).read).to include 'Fail' + end + end + end + end end \ No newline at end of file