Sha256: 503e31f0d5bdc78b4c6610cd55df74243fd8810d9f4ffbbf62a8bcd55e361dbc

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

require_relative '../spec_helper'

describe PerformanceStats do
  let(:backend){ double(get: nil, set: nil, del: nil) }
  let(:performance_stats){ PerformanceStats.new(backend) }
  let(:key){ 'key' }

  before :each do
    performance_stats.stub(:generate_key){ key }
  end

  describe 'average_access' do
    it 'should return the average time spent in the test' do
      performance_stats.average_access.should be_kind_of(Float)
    end

    it 'should remove the key created' do
      backend.should_receive(:del).with(key)
      performance_stats.average_access
    end
  end

  describe 'average_write' do
    it 'should return the average time spent in the test' do
      performance_stats.average_write.should be_kind_of(Float)
    end

    it 'should remove the key created' do
      backend.should_receive(:del).with(key)
      performance_stats.average_write
    end
  end

  describe 'average_create_and_delete' do
    it 'should return the average time spent in the test' do
      performance_stats.average_create_and_delete.should be_kind_of(Float)
    end

    it 'should remove the key created' do
      backend.should_receive(:del).with(key)
      performance_stats.average_create_and_delete
    end
  end

  describe 'results' do
    before :each do
      performance_stats.stub(:average_access)
      performance_stats.stub(:average_write)
      performance_stats.stub(:average_create_and_delete)
    end

    it 'should include performance stats' do
      performance_stats.results.should include(:average_access)
      performance_stats.results.should include(:average_write)
      performance_stats.results.should include(:average_create_and_delete)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis_monitor-0.2 lib/engine/spec/lib/performance_stats_spec.rb