Sha256: a933d3b6d5b5cbbba0246ee90ce6adb27d55c687180dfafc81fbff673958bc0e

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

PROJECT_ROOT_PATH = File.dirname(File.dirname(__FILE__))

require 'rubygems'
$LOAD_PATH.unshift File.join(PROJECT_ROOT_PATH, 'lib')
require 'spork'
require 'rspec'
require "middleman-core"
require "middleman-blog"
require "middleman-blog/helpers"

module SpecHelpers
  include FileUtils

  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
  require "middleman-blog-similar"
  require "middleman-blog-similar/extension"
end

Spork.each_run do; end

if ENV['CODECLIMATE_REPO_TOKEN']
  CodeClimate::TestReporter.start
  require "codeclimate-test-reporter"
end

class String
  def unindent
    gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "").sub(/\n$/, '')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-blog-similar-1.1.1 spec/spec_helper.rb
middleman-blog-similar-1.1.0 spec/spec_helper.rb