Sha256: 1db4a44c8eee6b3d4ca442c44853e918d5781af914c95ef11e53153a394ce9b7

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require 'helper'
require 'stringio'
require 'pilfer'

describe Pilfer do
  context 'reporting to a Pilfer::Logger' do
    let(:reporter) { Pilfer::Logger.new(output) }
    let(:output)   { StringIO.new }

    it 'reports profile' do
      Pilfer::Profiler.new(reporter).
        profile_files_matching(/integration_spec\.rb/, "testing") do
          10.times do
            sleep 0.01
          end
        end

      lines = output.string.split("\n")
      lines[0].should =~ %r{Profile start="[\d-]{10} [\d:]{8} UTC" description="testing"$}

      wall_time = lines[1].match(/wall_time=([\d\.]+)/)[1].to_f
      wall_time.should be_within(10).of(105)
    end

    it 'ignores optional reporter args' do
      Pilfer::Profiler.new(reporter).
        profile_files_matching(/integration_spec\.rb/, "testing",
                               :report => :async) do
          10.times do
            sleep 0.01
          end
        end

      lines = output.string.split("\n")
      lines[0].should =~ %r{Profile start="[\d-]{10} [\d:]{8} UTC" description="testing"$}

      wall_time = lines[1].match(/wall_time=([\d\.]+)/)[1].to_f
      wall_time.should be_within(10).of(105)
    end
  end

  context 'reporting to a Pilfer::Server' do
    it 'reports profile'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pilfer-1.0.2 spec/integration_spec.rb
pilfer-1.0.1 spec/integration_spec.rb
pilfer-1.0.0 spec/integration_spec.rb