File: test_theme_configuration.rb

package info (click to toggle)
ruby-jekyll-data 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 420 kB
  • sloc: ruby: 909; sh: 95; makefile: 10
file content (57 lines) | stat: -rw-r--r-- 1,839 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
# frozen_string_literal: true

require "helper"

class TestThemeConfiguration < JekyllDataTest
  context "site without data files but with a configured theme" do
    setup do
      @site = fixture_site(
        "source"      => File.join(source_dir, "no_data_config"),
        "destination" => File.join(dest_dir, "no_data_config")
      )
      assert @site.theme
      @theme_data = ThemeDataReader.new(@site).read("_data")
      @site.process
    end

    should "read and use data under the 'theme' namespace" do
      assert_equal(
        File.read(File.join(fixture_dir, "no_data_config_output.html")),
        File.read(@site.in_dest_dir("output.html"))
      )
    end
  end

  context "site with theme configuration overrides" do
    setup do
      @site = fixture_site(
        "source"      => File.join(source_dir, "empty_config_override"),
        "destination" => File.join(dest_dir, "empty_config_override")
      )
    end

    should "alert if the override file is empty" do
      reader = double(@site)
      msg = "Cannot define or override Theme Configuration with an empty file!"
      expect(reader).to receive(:process).with(no_args).and_return(msg)
      assert_equal msg, reader.process
    end
  end

  context "site with theme configuration overrides" do
    setup do
      @site = fixture_site(
        "source"      => File.join(source_dir, "not_hash_config_override"),
        "destination" => File.join(dest_dir, "not_hash_config_override")
      )
    end

    should "alert if the override is not a Hash Object" do
      reader = double(@site)
      msg = "Theme Config or its override should be a Hash of key:value pairs " \
            "or mappings. But got Array instead."
      expect(reader).to receive(:process).with(no_args).and_return(msg)
      assert_equal msg, reader.process
    end
  end
end