Sha256: 27c766552479f798bae106efdeeec3db5753d57af8d443be225f5b19868fa6e7
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' describe Rack::Throttle::Interval do include Rack::Test::Methods before do def app @target_app ||= example_target_app @app ||= Rack::Throttle::Interval.new(@target_app, :min => 0.1) end end it "should allow the request if the source has not been seen" do get "/foo" last_response.body.should show_allowed_response end it "should allow the request if the source has not been seen in the current interval" do get "/foo" sleep 0.2 # Should time travel this instead? get "/foo" last_response.body.should show_allowed_response end it "should not all the request if the source has been seen inside the current interval" do 2.times { get "/foo" } last_response.body.should show_throttled_response end it "should gracefully allow the request if the cache bombs on getting" do app.should_receive(:cache_get).and_raise(StandardError) get "/foo" last_response.body.should show_allowed_response end it "should gracefully allow the request if the cache bombs on setting" do app.should_receive(:cache_set).and_raise(StandardError) 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/interval_spec.rb |
railslove-rack-throttle-0.0.0 | spec/interval_spec.rb |