Sha256: 5c38310a25f3a94c4fc82141e6380df2957d8505d2bffed1b2ffe512e94489e3
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' describe Rack::Throttle::PerMinute do include Rack::Test::Methods before do def app @target_app ||= example_target_app @app ||= Rack::Throttle::PerMinute.new(@target_app, :max_per_minute => 3) end end it "should be allowed if not seen this hour" do get "/foo" last_response.body.should show_allowed_response end it "should be allowed if seen fewer than the max allowed per hour" do 2.times { get "/foo" } last_response.body.should show_allowed_response end it "should not be allowed if seen more times than the max allowed per hour" do 4.times { get "/foo" } last_response.body.should show_throttled_response end it "should be allowed if we are in a new minute" do Time.stub!(:now).and_return(Time.local(2000,"jan",1,0,0,0)) 4.times { get "/foo" } last_response.body.should show_throttled_response forward_one_minute = Time.now + 60 Time.stub!(:now).and_return(forward_one_minute) get "/foo" last_response.body.should show_allowed_response end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
railslove-rack-throttle-0.0.1 | spec/per_minute_spec.rb |
railslove-rack-throttle-0.0.0 | spec/per_minute_spec.rb |