rely directly on rack-mock

This commit is contained in:
Thomas Reynolds 2014-01-02 17:25:31 -08:00
parent 926ba0036c
commit c06fbcfc93
5 changed files with 20 additions and 20 deletions

View file

@ -50,9 +50,8 @@ module Middleman::Cli
raise Thor::Error, 'Error: Could not find a Middleman project config, perhaps you are in the wrong folder?'
end
# Use Rack::Test for inspecting a running server for output
require 'rack'
require 'rack/test'
require 'rack/mock'
require 'find'
@ -115,7 +114,7 @@ module Middleman::Cli
@to_clean = Set.new
@logger = @app.logger
@rack = ::Rack::Test::Session.new(@app.class.to_rack_app)
@rack = ::Rack::MockRequest.new(@app.class.to_rack_app)
super(base, @build_dir, config)
end

View file

@ -221,7 +221,7 @@ module Middleman
run_hook :before
# Get the resource object for this path
resource = sitemap.find_resource_by_destination_path(request_path)
resource = sitemap.find_resource_by_destination_path(request_path.gsub(' ', '%20'))
# Return 404 if not in sitemap
return not_found(res, request_path) unless resource && !resource.ignored?

View file

@ -1,6 +1,6 @@
# encoding: UTF-8
require 'rack/test'
require 'rack/mock'
Given /^a clean server$/ do
@initialize_commands = []
@ -57,7 +57,7 @@ Given /^the Server is running$/ do
end
app_rack = @server_inst.class.to_rack_app
@browser = ::Rack::Test::Session.new(::Rack::MockSession.new(app_rack))
@browser = ::Rack::MockRequest.new(app_rack)
end
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
@ -66,33 +66,37 @@ Given /^the Server is running at "([^\"]*)"$/ do |app_path|
end
When /^I go to "([^\"]*)"$/ do |url|
@browser.get(URI.escape(url))
@last_response = @browser.get(URI.escape(url))
end
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
lambda { @browser.get(URI.escape(url)) }.should_not raise_exception
last_response = nil
lambda {
last_response = @browser.get(URI.escape(url))
}.should_not raise_exception
@last_response = last_response
end
Then /^the content type should be "([^\"]*)"$/ do |expected|
@browser.last_response.content_type.should start_with(expected)
@last_response.content_type.should start_with(expected)
end
Then /^I should see "([^\"]*)"$/ do |expected|
@browser.last_response.body.should include(expected)
@last_response.body.should include(expected)
end
Then /^I should see '([^\']*)'$/ do |expected|
@browser.last_response.body.should include(expected)
@last_response.body.should include(expected)
end
Then /^I should see:$/ do |expected|
@browser.last_response.body.should include(expected)
@last_response.body.should include(expected)
end
Then /^I should not see "([^\"]*)"$/ do |expected|
@browser.last_response.body.should_not include(expected)
@last_response.body.should_not include(expected)
end
Then /^I should see "([^\"]*)" lines$/ do |lines|
@browser.last_response.body.chomp.split($/).length.should == lines.to_i
@last_response.body.chomp.split($/).length.should == lines.to_i
end

View file

@ -8,7 +8,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
super
require 'digest/sha1'
require 'rack/test'
require 'rack/mock'
require 'uri'
end
@ -22,7 +22,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
# Update the main sitemap resource list
# @return [void]
def manipulate_resource_list(resources)
@rack_client ||= ::Rack::Test::Session.new(app.class.to_rack_app)
@rack_client = ::Rack::MockRequest.new(app.class.to_rack_app)
# Process resources in order: binary images and fonts, then SVG, then JS/CSS.
# This is so by the time we get around to the text files (which may reference
@ -43,7 +43,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
return if ignored_resource?(resource)
# Render through the Rack interface so middleware and mounted apps get a shot
response = @rack_client.get(URI.escape(resource.destination_path), {}, { 'bypass_asset_hash' => 'true' })
response = @rack_client.get(URI.escape(resource.destination_path), { 'bypass_asset_hash' => 'true' })
raise "#{resource.path} should be in the sitemap!" unless response.status == 200
digest = Digest::SHA1.hexdigest(response.body)[0..7]

View file

@ -22,9 +22,6 @@ Gem::Specification.new do |s|
s.add_dependency("rack", [">= 1.4.5"])
s.add_dependency("tilt", ["~> 1.4.1"])
# Builder
s.add_dependency("rack-test", ["~> 0.6.2"])
# Helpers
s.add_dependency("activesupport", ["~> 4.0.1"])