Fix test breakage
This commit is contained in:
parent
2907761556
commit
3ae28874bf
8 changed files with 45 additions and 37 deletions
|
@ -334,8 +334,9 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
# Whether we're in a specific environment
|
# Whether we're in a specific environment
|
||||||
|
# @param [Symbol] key
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
Contract Bool
|
Contract Symbol => Bool
|
||||||
def environment?(key)
|
def environment?(key)
|
||||||
config[:environment] == key
|
config[:environment] == key
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ require 'middleman-core/util/data'
|
||||||
module Middleman::CoreExtensions
|
module Middleman::CoreExtensions
|
||||||
class FrontMatter < ::Middleman::Extension
|
class FrontMatter < ::Middleman::Extension
|
||||||
# Try to run after routing but before directory_indexes
|
# 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)
|
def initialize(app, options_hash={}, &block)
|
||||||
super
|
super
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Middleman
|
||||||
class Routing < Extension
|
class Routing < Extension
|
||||||
# This should always run late, but not as late as :directory_indexes,
|
# This should always run late, but not as late as :directory_indexes,
|
||||||
# so it can add metadata to any pages generated by other extensions
|
# 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 the `page` method to config.
|
||||||
expose_to_config :page
|
expose_to_config :page
|
||||||
|
|
|
@ -23,7 +23,8 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
|
||||||
|
|
||||||
if file && file[:full_path].exist?
|
if file && file[:full_path].exist?
|
||||||
begin
|
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
|
# Check for @2x and @3x image
|
||||||
retina = full_path.match(/@(\d)x\.[a-zA-Z]{3,4}$/)
|
retina = full_path.match(/@(\d)x\.[a-zA-Z]{3,4}$/)
|
||||||
if retina
|
if retina
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
||||||
|
|
||||||
def ready
|
def ready
|
||||||
# Setup Rack middleware to minify JS
|
# Setup Rack middleware to minify JS
|
||||||
app.use Rack, compressor: chosen_compressor,
|
app.use Rack, compressor: options[:compressor],
|
||||||
ignore: Array(options[:ignore]) + [/\.min\./],
|
ignore: Array(options[:ignore]) + [/\.min\./],
|
||||||
inline: options[:inline],
|
inline: options[:inline],
|
||||||
content_types: options[:content_types],
|
content_types: options[:content_types],
|
||||||
|
|
|
@ -14,6 +14,12 @@ require 'middleman-core/template_renderer'
|
||||||
::Rack::Mime::MIME_TYPES['.html'] = 'text/html; charset=utf-8'
|
::Rack::Mime::MIME_TYPES['.html'] = 'text/html; charset=utf-8'
|
||||||
::Rack::Mime::MIME_TYPES['.htm'] = '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
|
module Middleman
|
||||||
class Rack
|
class Rack
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
Then /^the file "([^\"]*)" has the contents$/ do |path, contents|
|
Then /^the file "([^\"]*)" has the contents$/ do |path, contents|
|
||||||
write_file(path, contents)
|
write_file(path, contents)
|
||||||
|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
@server_inst.files.find_new_files!
|
@server_inst.files.find_new_files!
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the file "([^\"]*)" is removed$/ do |path|
|
Then /^the file "([^\"]*)" is removed$/ do |path|
|
||||||
step %Q{I remove the file "#{path}"}
|
step %Q{I remove the file "#{path}"}
|
||||||
|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
@server_inst.files.find_new_files!
|
@server_inst.files.find_new_files!
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
require 'middleman-core/rack'
|
||||||
require 'rspec/expectations'
|
require 'rspec/expectations'
|
||||||
require 'capybara/cucumber'
|
require 'capybara/cucumber'
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ Given /^the Server is running$/ do
|
||||||
|
|
||||||
initialize_commands = @initialize_commands || []
|
initialize_commands = @initialize_commands || []
|
||||||
|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
@server_inst = ::Middleman::Application.new do
|
@server_inst = ::Middleman::Application.new do
|
||||||
config[:watcher_disable] = true
|
config[:watcher_disable] = true
|
||||||
config[:show_exceptions] = false
|
config[:show_exceptions] = false
|
||||||
|
@ -51,9 +52,8 @@ Given /^the Server is running$/ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
rack = ::Middleman::Rack.new(@server_inst)
|
Capybara.app = ::Middleman::Rack.new(@server_inst).to_app
|
||||||
Capybara.app = rack.to_app
|
# end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
|
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
|
||||||
|
@ -66,73 +66,73 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I go to "([^\"]*)"$/ do |url|
|
When /^I go to "([^\"]*)"$/ do |url|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
visit(URI.encode(url).to_s)
|
visit(URI.encode(url).to_s)
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
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
|
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.response_headers['Content-Type']).to start_with expected
|
expect(page.response_headers['Content-Type']).to start_with expected
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^\"]*)"$/ do |expected|
|
Then /^I should see "([^\"]*)"$/ do |expected|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.body).to include expected
|
expect(page.body).to include expected
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see '([^\']*)'$/ do |expected|
|
Then /^I should see '([^\']*)'$/ do |expected|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.body).to include expected
|
expect(page.body).to include expected
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see:$/ do |expected|
|
Then /^I should see:$/ do |expected|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.body).to include expected
|
expect(page.body).to include expected
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see "([^\"]*)"$/ do |expected|
|
Then /^I should not see "([^\"]*)"$/ do |expected|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.body).not_to include expected
|
expect(page.body).not_to include expected
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see content matching %r{(.*)}$/ do |expected|
|
Then /^I should see content matching %r{(.*)}$/ do |expected|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.body).to match(expected)
|
expect(page.body).to match(expected)
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see content matching %r{(.*)}$/ do |expected|
|
Then /^I should not see content matching %r{(.*)}$/ do |expected|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.body).to_not match(expected)
|
expect(page.body).to_not match(expected)
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see:$/ do |expected|
|
Then /^I should not see:$/ do |expected|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.body).not_to include expected
|
expect(page.body).not_to include expected
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.status_code).to eq expected.to_i
|
expect(page.status_code).to eq expected.to_i
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
||||||
cd(".") do
|
# cd(".") do
|
||||||
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue