Module: Cucumber::Formatter::Io::ClassMethods

Defined in:
lib/cucumber/formatter/io.rb

Instance Method Summary collapse

Instance Method Details

#new(*args, &block) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cucumber/formatter/io.rb', line 29

def new(*args, &block)
  instance = super

  config = args[0]
  if config.respond_to? :on_event
    config.on_event :test_run_finished do
      ios = instance.instance_variable_get(:@io_objects_to_close) || []
      ios.each do |io|
        at_exit do
          unless io.closed?
            io.flush
            io.close
          end
        end
      end
    end
  end

  instance
end