require 'spec_helper' describe RspecLogFormatter::Formatter do def make_example(opts={}) @count ||= 0; @count += 1 double({ full_description: "description_#{@count}", file_path: "path_#{@count}" }.merge(opts)) end def formatter_for_build(build) RspecLogFormatter::Formatter.new(double(now: Time.at(0)), keep_builds: 2, build_number: build) end it "can truncate the log file" do the_example = make_example formatter = formatter_for_build(1) formatter.example_started(the_example) formatter.example_passed(the_example) formatter.dump_summary(1,2,3,4) formatter = formatter_for_build(2) formatter.example_started(the_example) formatter.example_passed(the_example) formatter.dump_summary(1,2,3,4) File.open(RspecLogFormatter::Formatter::FILENAME, 'r').read.should == <