require 'spec_helper'
require 'chokepoint/time_window_examples'

describe Chokepoint::Hourly do
  let(:chokepoint) { Chokepoint::Hourly.new('test', :max => 3) }

  it_should_behave_like 'a time window'
  
  it "should not count last hour's requests against this hour's" do
    one_hour_ago = Time.now
    Timecop.freeze(DateTime.now - 1/24.0) do
      3.times { chokepoint.throttle { 'ok' } }
    end

    expect { chokepoint.throttle { 'ok' } }.to_not raise_error
  end
end
