Sha256: c6ccfdf33c4d9c5d6b3ced4779a159b5ba6b46e43559ebaac1f8fb3fed5a9b24

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require "spec_helper"

describe FactoryGirlProfiling::Profiler do
  subject { FactoryGirlProfiling::Profiler.instance }
  let(:output) { StringIO.new }
  before do
    subject.reset
    subject.output_buffer = output
  end
  context 'timing' do
    it "saves and prints given data" do
      subject.add_timing('some name', 'some strategy', 42)
      subject.print_timing_results
      expect(output.string).to include('some name')
      expect(output.string).to include('some strategy')
      expect(output.string).to include('42')
    end
  end

  context 'counting' do
    it "saves and prints given data" do
      subject.add_counting('some name', 'some strategy')
      subject.add_counting('some name', 'some strategy')
      subject.print_counting_results
      expect(output.string).to include('some name')
      expect(output.string).to include('some strategy')
      expect(output.string).to include('2')
    end
  end

  context '#reset' do
    it "resets saved data" do
      subject.print_results
      blank_result = output.string
      output.reopen
      subject.add_counting('some name', 'some strategy')
      subject.add_timing('some name', 'some strategy', 42)
      subject.reset
      subject.print_results
      expect(output.string).to eq(blank_result)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
factory_girl_profiling-0.0.1 spec/lib/factory_girl_profiling/profiler_spec.rb