Fix test breakage

This commit is contained in:
Thomas Reynolds 2015-09-19 14:07:42 -07:00
parent 2907761556
commit 3ae28874bf
8 changed files with 45 additions and 37 deletions

View file

@ -334,8 +334,9 @@ module Middleman
end
# Whether we're in a specific environment
# @param [Symbol] key
# @return [Boolean]
Contract Bool
Contract Symbol => Bool
def environment?(key)
config[:environment] == key
end

View file

@ -12,7 +12,7 @@ require 'middleman-core/util/data'
module Middleman::CoreExtensions
class FrontMatter < ::Middleman::Extension
# Try to run after routing but before directory_indexes
self.resource_list_manipulator_priority = 10
self.resource_list_manipulator_priority = 20
def initialize(app, options_hash={}, &block)
super

View file

@ -4,7 +4,7 @@ module Middleman
class Routing < Extension
# This should always run late, but not as late as :directory_indexes,
# so it can add metadata to any pages generated by other extensions
self.resource_list_manipulator_priority = 80
self.resource_list_manipulator_priority = 10
# Expose the `page` method to config.
expose_to_config :page

View file

@ -23,7 +23,8 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
if file && file[:full_path].exist?
begin
width, height = ::FastImage.size(file[:full_path].to_s, raise_on_failure: true)
full_path = file[:full_path].to_s
width, height = ::FastImage.size(full_path, raise_on_failure: true)
# Check for @2x and @3x image
retina = full_path.match(/@(\d)x\.[a-zA-Z]{3,4}$/)
if retina

View file

@ -13,7 +13,7 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
def ready
# Setup Rack middleware to minify JS
app.use Rack, compressor: chosen_compressor,
app.use Rack, compressor: options[:compressor],
ignore: Array(options[:ignore]) + [/\.min\./],
inline: options[:inline],
content_types: options[:content_types],

View file

@ -14,6 +14,12 @@ require 'middleman-core/template_renderer'
::Rack::Mime::MIME_TYPES['.html'] = 'text/html; charset=utf-8'
::Rack::Mime::MIME_TYPES['.htm'] = 'text/html; charset=utf-8'
# Sourcemap format
::Rack::Mime::MIME_TYPES['.map'] = 'application/json; charset=utf-8'
# Create a MIME type for PHP files (for detection by extensions)
::Rack::Mime::MIME_TYPES['.php'] = 'text/php'
module Middleman
class Rack
extend Forwardable

View file

@ -1,15 +1,15 @@
Then /^the file "([^\"]*)" has the contents$/ do |path, contents|
write_file(path, contents)
cd(".") do
# cd(".") do
@server_inst.files.find_new_files!
end
# end
end
Then /^the file "([^\"]*)" is removed$/ do |path|
step %Q{I remove the file "#{path}"}
cd(".") do
# cd(".") do
@server_inst.files.find_new_files!
end
# end
end

View file

@ -1,3 +1,4 @@
require 'middleman-core/rack'
require 'rspec/expectations'
require 'capybara/cucumber'
@ -41,7 +42,7 @@ Given /^the Server is running$/ do
initialize_commands = @initialize_commands || []
cd(".") do
# cd(".") do
@server_inst = ::Middleman::Application.new do
config[:watcher_disable] = true
config[:show_exceptions] = false
@ -51,9 +52,8 @@ Given /^the Server is running$/ do
end
end
rack = ::Middleman::Rack.new(@server_inst)
Capybara.app = rack.to_app
end
Capybara.app = ::Middleman::Rack.new(@server_inst).to_app
# end
end
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
@ -66,73 +66,73 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string|
end
When /^I go to "([^\"]*)"$/ do |url|
cd(".") do
# cd(".") do
visit(URI.encode(url).to_s)
end
# end
end
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
cd(".") do
# cd(".") do
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
end
# end
end
Then /^the content type should be "([^\"]*)"$/ do |expected|
cd(".") do
# cd(".") do
expect(page.response_headers['Content-Type']).to start_with expected
end
# end
end
Then /^I should see "([^\"]*)"$/ do |expected|
cd(".") do
# cd(".") do
expect(page.body).to include expected
end
# end
end
Then /^I should see '([^\']*)'$/ do |expected|
cd(".") do
# cd(".") do
expect(page.body).to include expected
end
# end
end
Then /^I should see:$/ do |expected|
cd(".") do
# cd(".") do
expect(page.body).to include expected
end
# end
end
Then /^I should not see "([^\"]*)"$/ do |expected|
cd(".") do
# cd(".") do
expect(page.body).not_to include expected
end
# end
end
Then /^I should see content matching %r{(.*)}$/ do |expected|
cd(".") do
# cd(".") do
expect(page.body).to match(expected)
end
# end
end
Then /^I should not see content matching %r{(.*)}$/ do |expected|
cd(".") do
# cd(".") do
expect(page.body).to_not match(expected)
end
# end
end
Then /^I should not see:$/ do |expected|
cd(".") do
# cd(".") do
expect(page.body).not_to include expected
end
# end
end
Then /^the status code should be "([^\"]*)"$/ do |expected|
cd(".") do
# cd(".") do
expect(page.status_code).to eq expected.to_i
end
# end
end
Then /^I should see "([^\"]*)" lines$/ do |lines|
cd(".") do
# cd(".") do
expect(page.body.chomp.split($/).length).to eq lines.to_i
end
# end
end