spec/tty/text/truncation/truncate_spec.rb in tty-0.0.11 vs spec/tty/text/truncation/truncate_spec.rb in tty-0.1.0

- old
+ new

@@ -1,79 +1,79 @@ -# -*- encoding: utf-8 -*- +# encoding: utf-8 require 'spec_helper' describe TTY::Text::Truncation, '#truncate' do let(:separator) { nil } - let(:options) { { :length => length, :separator => separator, :trailing => trailing } } - let(:trailing) { '…' } - let(:object) { described_class.new(text, options) } + let(:options) { { length: length, separator: separator, trailing: trailing } } + let(:trailing) { '…' } + let(:object) { described_class.new(text, options) } subject { object.truncate } context 'unicode support' do - let(:text) { 'ラドクリフ、マラソン五輪代表に1万m出場にも含み' } + let(:text) { 'ラドクリフ、マラソン五輪代表に1万m出場にも含み' } context 'with zero length' do let(:length) { 0 } - it { should == text } + it { is_expected.to eq(text) } end context 'with nil length' do let(:length) { nil } - it { should == text } + it { is_expected.to eq(text) } end context 'with equal length' do let(:length) { text.length } - it { should == text } + it { is_expected.to eq(text) } end context 'with truncation' do let(:length) { 12 } - it { should == "ラドクリフ、マラソン五#{trailing}" } + it { is_expected.to eq("ラドクリフ、マラソン五#{trailing}") } end context 'without truncation' do let(:length) { 100 } - it { should == text } + it { is_expected.to eq(text) } end context 'with separator' do let(:length) { 12 } let(:separator) { ' ' } - it { should == "ラドクリフ、マラソン五#{trailing}" } + it { is_expected.to eq("ラドクリフ、マラソン五#{trailing}") } end end context 'with custom trailing' do let(:text) { 'ラドクリフ、マラソン五輪代表に1万m出場にも含み' } let(:length) { 20 } let(:trailing) { '... (see more)' } - it { should == "ラドクリフ、#{trailing}" } + it { is_expected.to eq("ラドクリフ、#{trailing}") } end context 'with separator' do let(:length) { 25 } let(:text) { "Immense as whales, the motion of whose vast bodies can in a peaceful calm trouble the ocean til it boil." } context 'blank' do let(:separator) { '' } - it { should == "Immense as whales, the m#{trailing}"} + it { is_expected.to eq("Immense as whales, the m#{trailing}") } end context 'space' do let(:separator) { ' ' } - it { should == "Immense as whales, the…" } + it { is_expected.to eq("Immense as whales, the…") } end end context 'with excape' do let(:text) { "This is a \e[1m\e[34mbold blue text\e[0m" }