Sha256: 35a094e4be2c94c82a020ee806581d88cc4f6fdd4e9b8056a374e586949a1351
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
require File.join(File.dirname(__FILE__), '..', 'spec_helper') describe Rack::Throttle::Limiter do include Rack::Test::Methods def app @target_app ||= example_target_app @app ||= Rack::Throttle::Limiter.new(@target_app) end describe "basic calling" do it "should return the example app" do get "/foo" last_response.body.should show_allowed_response end it "should call the application if allowed" do app.should_receive(:allowed?).and_return(true) get "/foo" last_response.body.should show_allowed_response end it "should give a rate limit exceeded message if not allowed" do app.should_receive(:allowed?).and_return(false) get "/foo" last_response.body.should show_throttled_response end end describe "allowed?" do it "should return true if whitelisted" do app.should_receive(:whitelisted?).and_return(true) get "/foo" last_response.body.should show_allowed_response end it "should return false if blacklisted" do app.should_receive(:blacklisted?).and_return(true) get "/foo" last_response.body.should show_throttled_response end it "should return true if not whitelisted or blacklisted" do app.should_receive(:whitelisted?).and_return(false) app.should_receive(:blacklisted?).and_return(false) get "/foo" last_response.body.should show_allowed_response end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
improved-rack-throttle-w-expiry-0.8.0 | spec/limiters/limiter_spec.rb |
improved-rack-throttle-0.7.1 | spec/limiters/limiter_spec.rb |
improved-rack-throttle-0.7.0 | spec/limiters/limiter_spec.rb |