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