Sha256: 5d95ad4025f4ad691b5d9e715d89a8476d8d35f145410fc9bd3ecb327787071b

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require "spec_helper"
require "docks_theme_api"

describe Docks::Helpers do
  describe ".add_helpers_to" do
    let(:renderer) { Docks::Renderers::ERB.new }

    it "adds all bundled helpers" do
      helpers = []
      allow(renderer).to receive(:helpers) do |*args|
        helpers = helpers.concat(args)
      end

      described_class.add_helpers_to(renderer)

      described_class.constants.each do |const|
        expect(helpers).to include described_class.const_get(const)
      end
    end

    it "adds all theme helpers" do
      theme = Docks::Themes::API.instance
      helpers = []

      Docks.configure_with(theme: theme)
      allow(renderer).to receive(:helpers) do |*args|
        helpers = helpers.concat(args)
      end

      described_class.add_helpers_to(renderer)

      Docks.config.theme.helpers.each do |helper|
        expect(helpers).to include helper
      end
    end

    it "adds any user-configured helpers" do
      Docks.configure_with(helpers: ["foo.txt", "bar.txt"])

      helpers = []
      allow(renderer).to receive(:helpers) do |*args|
        helpers = helpers.concat(args)
      end

      described_class.add_helpers_to(renderer)

      Docks.config.helpers.each do |helper|
        expect(helpers).to include helper
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
docks_app-0.0.3 spec/lib/helpers_spec.rb