Sha256: 4f458d232707c2f8fdac5e0187b897d112153e19add13fe879b447b430a86b20

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

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

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

require 'codeclimate-test-reporter'
require 'coveralls'
require 'simplecov'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
  Coveralls::SimpleCov::Formatter,
  SimpleCov::Formatter::HTMLFormatter,
  CodeClimate::TestReporter::Formatter
]

SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/..'))
SimpleCov.start

ENV['COVERALLS_REPO_TOKEN'] && Coveralls.wear!

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.new do
      initialize_commands.each do |p|
        instance_exec(&p)
      end
    end
  end
end

RSpec.configure do |config|
  config.include SpecHelpers
end

require 'middleman-blog-similar/extension'
require 'middleman-blog-similar'
Dir.glob(PROJECT_ROOT_PATH + '/lib/middleman-blog-similar/tagger/*') { |file| require file }

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-blog-similar-2.0.1 spec/spec_helper.rb