Sha256: 99125c570215e110bfb2cfb8699681bab41c6ad48f9ad50015bdfdb0dde2122b

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

require File.expand_path("../../spec_helper", __FILE__)

module CukeForker
  describe LoggingListener do
    let(:stdout)   { StringIO.new }
    let(:listener) { LoggingListener.new stdout }

    it "logs all events" do
      Time.stub(:now => Time.now)

      mock_worker = mock(Worker,     :id => "1", :feature => "foo/bar")
      mock_display = mock(VncServer)
      mock_display.stub(:display).and_return(nil, ":5")

      listener.on_run_starting
      listener.on_display_starting mock_display
      listener.on_display_fetched mock_display
      listener.on_worker_starting mock_worker
      listener.on_eta Time.now, 10, 255
      listener.on_worker_finished mock_worker
      listener.on_display_released mock_display
      listener.on_run_interrupted
      listener.on_run_finished false
      listener.on_display_stopping mock_display

      timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S##{Process.pid}")

      stdout.string.should == <<-OUTPUT
I, [#{timestamp}]  INFO -- : [    run           ] starting
I, [#{timestamp}]  INFO -- : [    display(  )   ] starting
I, [#{timestamp}]  INFO -- : [    display(:5)   ] fetched
I, [#{timestamp}]  INFO -- : [    worker(1)     ] starting: foo/bar
I, [#{timestamp}]  INFO -- : [    eta(10/255)   ] #{Time.now.strftime "%Y-%m-%d %H:%M:%S"}
I, [#{timestamp}]  INFO -- : [    worker(1)     ] finished: foo/bar
I, [#{timestamp}]  INFO -- : [    display(:5)   ] released
I, [#{timestamp}]  INFO -- : [    run           ] interrupted - please wait
I, [#{timestamp}]  INFO -- : [    run           ] finished, passed
I, [#{timestamp}]  INFO -- : [    display(:5)   ] stopping
      OUTPUT
    end



  end # Worker
end # CukeForker

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cukeforker-0.0.1 spec/cukeforker/logging_listener_spec.rb