spec/tty/table/render_with_spec.rb in tty-0.1.0 vs spec/tty/table/render_with_spec.rb in tty-0.1.1

- old
+ new

@@ -1,14 +1,17 @@ -# -*- encoding: utf-8 -*- +# encoding: utf-8 require 'spec_helper' -describe TTY::Table, '#render_with' do +RSpec.describe TTY::Table, '#render_with' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { described_class.new header, rows } + let(:color) { Pastel.new(enabled: true) } + before { allow(Pastel).to receive(:new).and_return(color) } + context 'with invalid border class' do it "doesn't inherit from TTY::Table::Border" do expect { table.render_with String }.to raise_error(TTY::TypeError) end @@ -92,12 +95,12 @@ it 'displays border' do result = table.render_with MyBorder do |renderer| renderer.border.style = :red end expect(result).to eq <<-EOS.normalize - \e[31m|\e[0mh1\e[31m\e[0mh2\e[31m\e[0mh3\e[31m|\e[0m - \e[31m|\e[0ma1\e[31m\e[0ma2\e[31m\e[0ma3\e[31m|\e[0m - \e[31m|\e[0mb1\e[31m\e[0mb2\e[31m\e[0mb3\e[31m|\e[0m + \e[31m|\e[0mh1h2h3\e[31m|\e[0m + \e[31m|\e[0ma1a2a3\e[31m|\e[0m + \e[31m|\e[0mb1b2b3\e[31m|\e[0m EOS end end end # render_with