<commit_before>require 'discordrb'

# alias so I don't have to type it out every time...
BUCKET = Discordrb::Commands::Bucket
RATELIMITER = Discordrb::Commands::RateLimiter

describe Discordrb::Commands::Bucket do
  describe 'rate_limited?' do
    it 'should not rate limit one request' do
      BUCKET.new(1, 5, 2).rate_limited?(:a).should be_falsy
      BUCKET.new(nil, nil, 2).rate_limited?(:a).should be_falsy
      BUCKET.new(1, 5, nil).rate_limited?(:a).should be_falsy
      BUCKET.new(0, 1, nil).rate_limited?(:a).should be_falsy
      BUCKET.new(0, 1_000_000_000, 500_000_000).rate_limited?(:a).should be_falsy
    end

    it 'should fail to initialize with invalid arguments' do
      expect { BUCKET.new(0, nil, 0) }.to raise_error(ArgumentError)
    end

    it 'should fail to rate limit something invalid' do
      expect { BUCKET.new(1, 5, 2).rate_limited?("can't RL a string!") }.to raise_error(ArgumentError)
    end

    it 'should rate limit one request over the limit' do
      b = BUCKET.new(1, 5, nil)
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_truthy
    end

    it 'should rate limit multiple requests that are over the limit' do
      b = BUCKET.new(3, 5, nil)
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_truthy
    end

    it 'should not rate limit after the limit ran out' do
      b = BUCKET.new(2, 5, nil)
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_truthy
      b.rate_limited?(:a, Time.now + 4).should be_truthy
      b.rate_limited?(:a, Time.now + 5).should be_falsy
    end

    it 'should reset the limit after it ran out' do
      b = BUCKET.new(2, 5, nil)
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_truthy
      b.rate_limited?(:a, Time.now + 5).should be_falsy
      b.rate_limited?(:a, Time.now + ).should be_falsy
    end
  end
end<commit_msg>Fix the test for limit resetting<commit_after>require 'discordrb'

# alias so I don't have to type it out every time...
BUCKET = Discordrb::Commands::Bucket
RATELIMITER = Discordrb::Commands::RateLimiter

describe Discordrb::Commands::Bucket do
  describe 'rate_limited?' do
    it 'should not rate limit one request' do
      BUCKET.new(1, 5, 2).rate_limited?(:a).should be_falsy
      BUCKET.new(nil, nil, 2).rate_limited?(:a).should be_falsy
      BUCKET.new(1, 5, nil).rate_limited?(:a).should be_falsy
      BUCKET.new(0, 1, nil).rate_limited?(:a).should be_falsy
      BUCKET.new(0, 1_000_000_000, 500_000_000).rate_limited?(:a).should be_falsy
    end

    it 'should fail to initialize with invalid arguments' do
      expect { BUCKET.new(0, nil, 0) }.to raise_error(ArgumentError)
    end

    it 'should fail to rate limit something invalid' do
      expect { BUCKET.new(1, 5, 2).rate_limited?("can't RL a string!") }.to raise_error(ArgumentError)
    end

    it 'should rate limit one request over the limit' do
      b = BUCKET.new(1, 5, nil)
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_truthy
    end

    it 'should rate limit multiple requests that are over the limit' do
      b = BUCKET.new(3, 5, nil)
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_truthy
    end

    it 'should not rate limit after the limit ran out' do
      b = BUCKET.new(2, 5, nil)
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_truthy
      b.rate_limited?(:a, Time.now + 4).should be_truthy
      b.rate_limited?(:a, Time.now + 5).should be_falsy
    end

    it 'should reset the limit after it ran out' do
      b = BUCKET.new(2, 5, nil)
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_falsy
      b.rate_limited?(:a).should be_truthy
      b.rate_limited?(:a, Time.now + 5).should be_falsy
      b.rate_limited?(:a, Time.now + 5.01).should be_falsy
    end
  end
end
{'fraction_non_alphanumeric': 0.12199762187871581, 'fraction_numerical': 0.02164090368608799, 'mean_word_length': 3.201798201798202, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1847368', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1553, 'n_words': 388}