Sha256: 6da951401a6f2453499520a5145bd89bb06ec89082f555572f04d7fbd380d3e0

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "Rack::Counter" do

  include Rack::Test::Methods

  describe "with no options specified" do
    def app
      Rack::Builder.new do
        use Rack::Counter
        run BlankApplication.new
      end
    end

    describe "when hitting the app several times" do
      before(:each) do
        @stats_before = JSON.parse(get('/_stats.json').body)
        50.times { get '/' }
        @stats_after = JSON.parse(get('/_stats.json').body)
      end

      it "records the proper number of hits" do
        (@stats_after['hits'] - @stats_before['hits']).should == 50
      end

      it "should change the hits/sec" do
        @stats_after['avg_per_sec'].should_not == @stats_before['avg_per_sec']
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-counter-1.0.0 spec/rack_counter_spec.rb