Sha256: 672a8e984455a86d6418eec302e6be1145385edbc92682c67bcdedf34c587777

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

# -*- encoding : utf-8 -*-
require 'megingiard/centered_canvas'

describe Megingiard::CenteredCanvas do
  subject { Megingiard::CenteredCanvas.new(output) }
  let(:node) { double }
  let(:node_as_string) { double }
  let(:right_adjusted_text) { double }
  let(:output) { double }
  let(:cell_width) { double }

  before do
    stub_const('Megingiard::CELL_WIDTH', cell_width)
    allow(node).to receive(:to_s)
      .and_return(node_as_string)
    allow(node_as_string).to receive(:rjust)
      .and_return(right_adjusted_text)
    allow(output).to receive(:print)
  end

  describe 'draw_left_column' do
    it 'should to_s and right adjust the text' do
      expect(node_as_string).to receive(:rjust)
        .with(cell_width)
      subject.draw_left_column(node)
    end

    it 'should print the resulting text to the output' do
      expect(output).to receive(:print)
        .with(right_adjusted_text)
      subject.draw_left_column(node)
    end

    it 'should know that it has drawn a left column' do
      expect do
        subject.draw_left_column(node)
      end.to change { subject.left_column_drawn? }.to(true)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
megingiard-0.1.0 spec/unit/centered_canvas/draw_left_column_spec.rb
megingiard-0.0.1 spec/unit/centered_canvas/draw_left_column_spec.rb