Sha256: 98353d2af338f8ed51d6ccd68ae502d3918ca4681466d8f80a2577b192b810b3

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

# Copyright 2013 Google Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0, found in the LICENSE file.

require "pry"

require_relative "../lib/rack/allocation_stats"
require_relative "hello_world_app"
require_relative "yaml_app"
require_relative "yajl_app"

require "factory_girl"
require_relative "factories"

if RbConfig::CONFIG["MAJOR"].to_i < 2 || RbConfig::CONFIG["MINOR"].to_i < 1
  warn "Error: ObjectStats requires Ruby 2.1 or greater"
  exit 1
end

module Matchers
  class QueryString
    def initialize(expected_match)
      @expected_match = expected_match
    end

    def matches?(env)
      request = Rack::Request.new(env)
      query_string = request.GET
      if query_string.eql? @expected_match
        true
      else
        env_description = "env, where Rack::Request.new(env).GET is #{query_string.inspect}"
        env.instance_eval <<-RUBY
          def description; #{env_description.inspect}; end
        RUBY
        false
      end
    end

    def description
      "query_string(#{@expected_match.inspect})"
    end

    def failure_message; end

    def negative_failure_message; end
  end

  def query_string(expected)
    QueryString.new(expected)
  end
end

RSpec.configure do |config|
  config.include Matchers
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-allocation_stats-0.1.2 spec/spec_helper.rb
rack-allocation_stats-0.1.1 ./spec/spec_helper.rb
rack-allocation_stats-0.1.0 ./spec/spec_helper.rb