spec/spec_helper.rb in middleman-blog-similar-1.0.0 vs spec/spec_helper.rb in middleman-blog-similar-1.1.0

- old
+ new

@@ -6,12 +6,36 @@ require 'rspec' require "middleman-core" require "middleman-blog" require "middleman-blog/helpers" +module SpecHelpers + include FileUtils -# Memo: https://github.com/middleman/middleman/issues/737#issuecomment-14122832 -module SpecHelpers; end + def middleman_app fixture_path, &block + tmp_dir = File.expand_path("../../tmp", __FILE__) + fixture_dir = File.expand_path("../../fixtures", __FILE__) + fixture_tmp = File.join tmp_dir, "rspec" + root_dir = File.join fixture_tmp, fixture_path + rmtree fixture_tmp + mkdir_p tmp_dir + cp_r fixture_dir, fixture_tmp + ENV["MM_SOURCE"] = 'source' + ENV["MM_ROOT"] = root_dir + initialize_commands = @initialize_commands || [] + initialize_commands.unshift block + initialize_commands.unshift lambda { + set :environment, :development + set :show_exceptions, false + activate :blog + } + Middleman::Application.server.inst do + initialize_commands.each do |p| + instance_exec(&p) + end + end + end +end Spork.prefork do RSpec.configure do |config| config.include SpecHelpers end