diff --git a/lib/rack/attack/track.rb b/lib/rack/attack/track.rb index 4bfc145..e0039e3 100644 --- a/lib/rack/attack/track.rb +++ b/lib/rack/attack/track.rb @@ -3,19 +3,19 @@ module Rack class Track extend Forwardable - attr_reader :checker + attr_reader :filter def initialize(name, options = {}, block) options[:type] = :track if options[:limit] && options[:period] - @checker = Throttle.new(name, options, block) + @filter = Throttle.new(name, options, block) else - @checker = Check.new(name, options, block) + @filter = Check.new(name, options, block) end end - def_delegator :@checker, :[], :[] + def_delegator :@filter, :[] end end end diff --git a/spec/rack_attack_track_spec.rb b/spec/rack_attack_track_spec.rb index 8603266..9f9ca9c 100644 --- a/spec/rack_attack_track_spec.rb +++ b/spec/rack_attack_track_spec.rb @@ -43,16 +43,16 @@ describe 'Rack::Attack.track' do end describe "without limit and period options" do - it "should delegate [] to check" do + it "should assign the track filter to a Check instance" do tracker = Rack::Attack.track("homepage") { |req| req.path == "/"} - tracker.checker.class.must_equal Rack::Attack::Check + tracker.filter.class.must_equal Rack::Attack::Check end end describe "with limit and period options" do - it "should delegate [] method to throttle" do + it "should assign the track filter to a Throttle instance" do tracker = Rack::Attack.track("homepage", :limit => 10, :period => 10) { |req| req.path == "/"} - tracker.checker.class.must_equal Rack::Attack::Throttle + tracker.filter.class.must_equal Rack::Attack::Throttle end end end