Sha256: da814661786617707be8e9003e3cd38ea82a9345f530054e29d9874d854bb028

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require "rspec"
require "rack/test"
require "rack/throttle"
require "timecop"

unless RUBY_VERSION.match(/1\.8/)
  require 'simplecov'
  SimpleCov.start
end

def example_target_app
  @target_app = double("Example Rack App")
  @target_app.stub(:call).with(any_args()).and_return([200, {}, "Example App Body"])
  @target_app
end

RSpec::Matchers.define :show_allowed_response do
  match do |body|
    body.include?("Example App Body")
  end
  
  failure_message_for_should do
    "expected response to show the allowed response" 
  end 

  failure_message_for_should_not do
    "expected response not to show the allowed response" 
  end
  
  description do
    "expected the allowed response"
  end 
end

RSpec::Matchers.define :show_throttled_response do
  match do |body|
    body.include?("Rate Limit Exceeded")
  end
  
  failure_message_for_should do
    "expected response to show the throttled response" 
  end 

  failure_message_for_should_not do
    "expected response not to show the throttled response" 
  end
  
  description do
    "expected the throttled response"
  end 
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
improved-rack-throttle-w-expiry-0.8.0 spec/spec_helper.rb