Sha256: 007c7a80da7139d7dd08519baab9d4f6e9fa6960651f9af643136e09b5610e2a

Contents?: true

Size: 974 Bytes

Versions: 1

Compression:

Stored size: 974 Bytes

Contents

# frozen_string_literal: true

RSpec.shared_examples 'render with stdin and stdout' do |klass|
  let(:renderer) { klass.new 'content' }

  before do
    allow(renderer).to receive(:build_command).and_return 'cmd'
    allow(LiquidDiagrams::Rendering).to receive(
      :render_with_stdin_stdout
    ).and_return 'ok'
  end

  it 'render with stdin and stdout' do
    expect(renderer.render).to eq 'ok'

    expect(LiquidDiagrams::Rendering).to have_received(
      :render_with_stdin_stdout
    ).with('cmd', 'content')
  end
end

RSpec.shared_examples 'render with tempfile' do |klass|
  let(:renderer) { klass.new 'content' }

  before do
    allow(renderer).to receive(:build_command)
    allow(LiquidDiagrams::Rendering).to receive(
      :render_with_tempfile
    ).and_yield('in', 'out').and_return 'ok'
  end

  it 'render with tempfile' do
    expect(renderer.render).to eq 'ok'
    expect(LiquidDiagrams::Rendering).to have_received(:render_with_tempfile)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
liquid-diagrams-0.4.0 spec/support/shared_examples.rb