Sha256: 37b5d9c9cbbea7fb1a045075888c8a0212475ddb58db71d96ffd4a48ed094d2f

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'spec_helper')

describe Rack::Throttle::MethodMatcher do
  include Rack::Test::Methods

  def app
    @target_app ||= example_target_app
    @app ||= Rack::Throttle::Limiter.new(@target_app, :rules => {:method => :post})
  end

  it "should not bother checking if the path doesn't match the rule" do
    app.should_not_receive(:allowed?)
    get "/foo"
    last_response.body.should show_allowed_response
  end
  
  it "should check if the path matches the rule" do
    app.should_receive(:allowed?).and_return(false)
    post "/foo"
    last_response.body.should show_throttled_response
  end

  it "should append the rule to the cache key" do
    post "/foo"
    app.send(:cache_key, last_request).should == "127.0.0.1:meth-post"
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
improved-rack-throttle-w-expiry-0.8.0 spec/matchers/method_matcher_spec.rb
improved-rack-throttle-0.7.1 spec/matchers/method_matcher_spec.rb
improved-rack-throttle-0.7.0 spec/matchers/method_matcher_spec.rb