Sha256: 21aba28fce0a811e03fc8030e5752f6cb309aa7d6e8b66e55902875f202ef6ff

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'middleman/rack'
require 'rack/test'

module MiddlemanServerHelpers
  include Rack::Test::Methods

  def app
    @app.call
  end

  def visit(path)
    get(path)
    raise last_response.errors if !last_response.errors.empty?
  end

  def find_on_page(string)
    expect(last_response.body).to include(string)
  end

  def run_site(path, &block)
    setup_environment(path)

    @app = lambda do
      instance = ::Middleman::Application.new do
        config[:watcher_disable] = true
        config[:show_exceptions] = false

        # Require the pagination extension after the
        # server has booted, as would typically happen.
        require File.expand_path('../../../lib/middleman/search_engine_sitemap', __FILE__)

        app.after_configuration_eval do
          config_context.instance_exec(&block)
        end
      end

      ::Middleman::Rack.new(instance).to_app
    end
  end

  private

  def setup_environment(path)
    ENV['MM_ROOT'] = File.expand_path("../../#{path}", __FILE__)
    ENV['TEST'] = "true"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
middleman-search_engine_sitemap-1.4.0 spec/support/middleman_server_helpers.rb
middleman-search_engine_sitemap-1.4.0.beta spec/support/middleman_server_helpers.rb
middleman-search_engine_sitemap-1.4.0.alpha spec/support/middleman_server_helpers.rb