Sha256: 17eb500510ba1d8b54e7c48fe78dc880be763c13dee14fc75d1714b03b4837d5
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require 'spec_helper' RSpec.describe LiquidDiagrams::BasicBlock do let(:block) do TestBlock.parse( 'test', '', Liquid::Tokenizer.new('{% endtest %}'), Liquid::ParseContext.new ) end before do stub_const('TestBlock', Class.new(described_class)) stub_const('TestRenderer', Class.new) end describe '.renderer' do it 'return the renderer matching the block' do expect(TestBlock.renderer).to be TestRenderer end end describe '#render' do it 'call #render!' do allow(block).to receive(:render!).and_return 'success' expect(block.render(Liquid::Context.new)).to eq 'success' end context 'when rendering failed' do let(:error) { LiquidDiagrams::Errors::BasicError.new } it 'rescue and return the error' do allow(block).to receive(:render!).and_raise(error) expect(block.render(Liquid::Context.new)).to eq error end end end describe '#render!' do it 'render with renderer' do allow(TestRenderer).to receive(:render).and_return 'success' expect(block.render!(Liquid::Context.new)).to eq 'success' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
liquid-diagrams-0.1.0 | spec/liquid_diagrams/basic_block_spec.rb |