File: spec_helper.rb

package info (click to toggle)
ruby-jekyll-redirect-from 0.15.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 280 kB
  • sloc: ruby: 636; sh: 17; makefile: 4
file content (59 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# frozen_string_literal: true

require "jekyll"
require "jekyll-redirect-from"

RSpec.configure do |config|
  config.run_all_when_everything_filtered = true
  config.filter_run :focus

  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  config.before(:each) do
    Jekyll.logger.log_level = :error
    dest_path.rmtree if dest_path.exist?
    site.reset
  end

  config.after(:each) do
    dest_path.rmtree if dest_path.exist?
  end

  def fixtures_path
    Pathname.new(__dir__).join("fixtures")
  end

  def dest_path
    Pathname.new(site.dest)
  end

  def dest_dir(*paths)
    dest_path.join(*paths)
  end

  def config
    Jekyll.configuration(
      "source"      => fixtures_path.to_s,
      "destination" => fixtures_path.join("_site").to_s,
      "collections" => {
        "articles" => { "output" => true },
        "authors"  => {},
      },
      "url"         => "http://jekyllrb.com",
      "gems"        => [
        "jekyll-redirect-from",
        "jekyll-sitemap",
      ],
      "defaults"    => [{
        "scope"  => { "path" => "" },
        "values" => { "layout" => "layout" },
      }]
    ).backwards_compatibilize
  end

  def site
    @site ||= Jekyll::Site.new(config)
  end
end