Sha256: f9879a6d4506904e0f7fe8b3c142e73bed29167ee999adcbde08e2f4e6724700

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe LiquidDiagrams::Renderers::GraphvizRenderer, :renderers do
  subject(:renderer) { described_class.new('content') }

  describe '#render' do
    include_examples 'render with stdin and stdout', described_class
  end

  describe '#executable' do
    it { expect(renderer.executable).to eq 'dot -Tsvg' }
  end

  describe '#arguments' do
    context 'with string attributes' do
      before do
        renderer.instance_variable_set(
          :@config, { 'graph_attributes' => 'color=red' }
        )
      end

      it do
        expect(renderer.arguments).to match '-Gcolor=red'
      end
    end

    context 'with array attributes' do
      before do
        renderer.instance_variable_set(
          :@config, { 'node_attributes' => %w[color=red size=10] }
        )
      end

      it do
        expect(renderer.arguments).to match '-Ncolor=red -Nsize=10'
      end
    end

    context 'with hash attributes' do
      before do
        renderer.instance_variable_set(
          :@config, { 'edge_attributes' => { 'color': 'red', 'size': '10' } }
        )
      end

      it do
        expect(renderer.arguments).to match '-Ecolor=red -Esize=10'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
liquid-diagrams-0.4.0 spec/liquid_diagrams/renderers/graphviz_renderer_spec.rb