Sha256: bde2abf13f36d8b36a1debe740739366dd4e1560cc4373530348a451d5da147d

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe LiquidDiagrams::BasicRenderer do
  let(:renderer) { described_class.new('') }

  describe '.render' do
    before do
      allow(renderer).to receive(:render).and_return 'yay'
      allow(described_class).to receive(:new).and_return(renderer)
    end

    it 'create an instance and render with it' do
      expect(described_class.render('content', { k: :v })).to eq 'yay'
    end
  end

  describe '#render' do
    it 'raise not implemented error' do
      expect { renderer.render }.to raise_error(
        LiquidDiagrams::Errors::NotImplementedError
      )
    end
  end

  describe '#build_command' do
    it 'combine #executable and #arguments' do
      allow(renderer).to receive(:executable).and_return 'cmd'
      allow(renderer).to receive(:arguments).and_return '--flag --opt val'

      expect(renderer.build_command).to eq 'cmd --flag --opt val'
    end
  end

  describe '#executable' do
    it 'provide a default executable' do
      expect(renderer.executable).to eq 'basic'
    end
  end

  describe '#arguments' do
    it 'combine options and flags' do
      allow(LiquidDiagrams::Utils).to receive(:build_flags).and_return '--flag'
      allow(LiquidDiagrams::Utils).to receive(:build_options).and_return '--opt val'

      expect(renderer.arguments).to eq '--flag --opt val'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
liquid-diagrams-0.4.0 spec/liquid_diagrams/basic_renderer_spec.rb