Sha256: ab7d29f058af0f4bb4bc210058cd823b94fbf0e6ae48e3c5d8fc7629dfd9906c

Contents?: true

Size: 1011 Bytes

Versions: 4

Compression:

Stored size: 1011 Bytes

Contents

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

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

4 entries across 4 versions & 1 rubygems

Version Path
improved-rack-throttle-0.7.1 spec/spec_helper.rb
improved-rack-throttle-0.7.0 spec/spec_helper.rb
improved-rack-throttle-0.6.0 spec/spec_helper.rb
improved-rack-throttle-0.5.0 spec/spec_helper.rb