Sha256: 0954bcd33d721553bcedec83ed76dceffa412aa2bd346d9dfa7973420fbfe25d

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# So that the installed throttle gem doesnt interfere
$:.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))

require 'rubygems'
require "spec"
require 'spec/autorun'
require "rack/test"
require "rack/throttle"

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

Spec::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

Spec::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

2 entries across 2 versions & 1 rubygems

Version Path
railslove-rack-throttle-0.0.1 spec/spec_helper.rb
railslove-rack-throttle-0.0.0 spec/spec_helper.rb