Sha256: 02e92a5e704eb79f3e846b9aa52b97827e1bbc5edcfc325f15af63ee3b0c6230

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'helper'
require 'pilfer/profiler'

describe Pilfer::Profiler do
  let(:reporter) { stub(:reporter, :write => nil) }
  let(:start)    { stub(:start) }

  describe '#profile' do
    it 'profiles all files by default' do
      profiler = stub(:profiler)
      profiler.should_receive(:call).with(/./)
      Pilfer::Profiler.new(reporter).profile(profiler) { }
    end

    it 'returns value of app' do
      profiler = lambda {|*args, &app|
        app.call
        :profiler_response
      }

      response = Pilfer::Profiler.new(reporter).profile(profiler) {
        :app_response
      }

      response.should eq(:app_response)
    end

    it 'writes profile to reporter' do
      profiler = stub(:profiler, :call => :profiler_response)
      reporter.should_receive(:write).with(:profiler_response, start)
      Pilfer::Profiler.new(reporter).profile(profiler, start) { }
    end
  end

  describe '#profile_files_matching' do
    let(:matcher) { stub(:matcher) }

    it 'passes file matcher to profiler' do
      profiler = stub(:profiler)
      profiler.should_receive(:call).with(matcher)
      Pilfer::Profiler.new(reporter).
        profile_files_matching(matcher, profiler) { }
    end

    it 'writes profile to reporter' do
      profiler = stub(:profiler, :call => :profiler_response)
      reporter.should_receive(:write).with(:profiler_response, start)
      Pilfer::Profiler.new(reporter).
        profile_files_matching(matcher, profiler, start) { }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pilfer-0.0.1.pre4 spec/pilfer/profiler_spec.rb