Sha256: 1d1ea730049715fc6d64352a517824dc986ae7d7b75f6a9750601a866b65106a

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 Bytes

Contents

module GeoRedirect
  module Support
    def fixture_path(file)
      "spec/fixtures/#{file}"
    end

    def nonexisting_file_path
      "/no_such_file"
    end

    def app
      Rack::Lint.new(@app)
    end

    def mock_app(options = {})
      # Simple HTTP server that always returns 'Hello world!'
      main_app = lambda { |env|
        Rack::Request.new(env)
        headers = {"Content-Type" => "text/html"}
        [200, headers, ["Hello world!"]]
      }

      @logfile = Tempfile.new("log")
      options = { :config => fixture_path("config.yml"),
                  :db => fixture_path("GeoIP.dat"),
                  :logfile => @logfile.path
                }.merge(options)

      builder = Rack::Builder.new
      builder.use GeoRedirect::Middleware, options
      builder.run main_app
      @app = builder.to_app
    end

    def log_should_include(message)
      @logfile.rewind
      @logfile.read.should include(message)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geo_redirect-0.3 spec/support/geo_redirect.rb