diff --git a/spec/cell_spec.rb b/spec/cell_spec.rb index ae9f7e0..0a4f430 100644 --- a/spec/cell_spec.rb +++ b/spec/cell_spec.rb @@ -7,7 +7,7 @@ end it "should be left justified by default" do - @cell.align.should == :left + expect(@cell.align).to eq(:left) end it "should span 1 column by default" do @@ -15,9 +15,9 @@ end it "should return correct column index" do - @table.text_table_rows.first.cells[0].column_index.should == 0 - @table.text_table_rows.first.cells[1].column_index.should == 1 - @table.text_table_rows.first.cells[2].column_index.should == 3 + expect(@table.text_table_rows.first.cells[0].column_index).to eq(0) + expect(@table.text_table_rows.first.cells[1].column_index).to eq(1) + expect(@table.text_table_rows.first.cells[2].column_index).to eq(3) end end diff --git a/spec/enumerable_spec.rb b/spec/enumerable_spec.rb index 9bcae8d..2c7cf0a 100644 --- a/spec/enumerable_spec.rb +++ b/spec/enumerable_spec.rb @@ -11,45 +11,45 @@ end it "to Text::Table" do - @arr.to_text_table.to_s.should == deindent(%q{ + expect(@arr.to_text_table.to_s).to eq(deindent(%q{ +----+-----+------+ | 11 | 2 | 3333 | | 44 | 56 | 6 | | 7 | 888 | 99 | +----+-----+------+ - }) + })) end it "to Text::Table using flat array" do - [11, 44, 7].to_text_table.to_s.should == deindent(%q{ + expect([11, 44, 7].to_text_table.to_s).to eq(deindent(%q{ +----+ | 11 | | 44 | | 7 | +----+ - }) + })) end it "to Text::Table, setting first row as head" do - @arr.to_text_table(:first_row_is_head => true).to_s.should == deindent(%q{ + expect(@arr.to_text_table(:first_row_is_head => true).to_s).to eq(deindent(%q{ +----+-----+------+ | 11 | 2 | 3333 | +----+-----+------+ | 44 | 56 | 6 | | 7 | 888 | 99 | +----+-----+------+ - }) + })) end it "to Text::Table, setting last row as foot" do - @arr.to_text_table(:last_row_is_foot => true).to_s.should == deindent(%q{ + expect(@arr.to_text_table(:last_row_is_foot => true).to_s).to eq(deindent(%q{ +----+-----+------+ | 11 | 2 | 3333 | | 44 | 56 | 6 | +----+-----+------+ | 7 | 888 | 99 | +----+-----+------+ - }) + })) end end @@ -61,32 +61,32 @@ } end it "to Text::Table" do - @hsh.to_text_table.to_s.should == deindent(%q{ + expect(@hsh.to_text_table.to_s).to eq(deindent(%q{ +---+----+ | k | vv | | k | vv | +---+----+ - }) + })) end it "to Text::Table, setting first row as head" do - @hsh.to_text_table(:first_row_is_head => true).to_s.should == deindent(%q{ + expect(@hsh.to_text_table(:first_row_is_head => true).to_s).to eq(deindent(%q{ +---+----+ | k | vv | +---+----+ | k | vv | +---+----+ - }) + })) end it "to Text::Table, setting last row as foot" do - @hsh.to_text_table(:last_row_is_foot => true).to_s.should == deindent(%q{ + expect(@hsh.to_text_table(:last_row_is_foot => true).to_s).to eq(deindent(%q{ +---+----+ | k | vv | +---+----+ | k | vv | +---+----+ - }) + })) end end end diff --git a/spec/integration/alignment_spec.rb b/spec/integration/alignment_spec.rb index 12c8e16..84521b0 100644 --- a/spec/integration/alignment_spec.rb +++ b/spec/integration/alignment_spec.rb @@ -14,40 +14,40 @@ context 'when left' do let(:align) { :left } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +-----+------+------+------+ | a | bb | ccc | dddd | +-----+------+------+------+ | aa | bbb | cccc | d | | aaa | bbbb | c | dd | +-----+------+------+------+ - }) } + })) } end context 'when center' do let(:align) { :center } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +-----+------+------+------+ | a | bb | ccc | dddd | +-----+------+------+------+ | aa | bbb | cccc | d | | aaa | bbbb | c | dd | +-----+------+------+------+ - }) } + })) } end context 'when right' do let(:align) { :right } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +-----+------+------+------+ | a | bb | ccc | dddd | +-----+------+------+------+ | aa | bbb | cccc | d | | aaa | bbbb | c | dd | +-----+------+------+------+ - }) } + })) } end end @@ -57,7 +57,7 @@ context 'when left' do let(:align) { :left } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -66,13 +66,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'when center' do let(:align) { :center } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -81,13 +81,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'when right' do let(:align) { :right } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -96,7 +96,7 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end end @@ -107,40 +107,40 @@ context 'when left' do let(:align) { :left } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+-----+ | aa | bbb | cccc | d | | aaa | bbbb | c | dd | +------+------+------+-----+ | aaaa | b | cc | ddd | +------+------+------+-----+ - }) } + })) } end context 'when center' do let(:align) { :center } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+-----+ | aa | bbb | cccc | d | | aaa | bbbb | c | dd | +------+------+------+-----+ | aaaa | b | cc | ddd | +------+------+------+-----+ - }) } + })) } end context 'when right' do let(:align) { :right } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+-----+ | aa | bbb | cccc | d | | aaa | bbbb | c | dd | +------+------+------+-----+ | aaaa | b | cc | ddd | +------+------+------+-----+ - }) } + })) } end end @@ -155,7 +155,7 @@ table.align_column 3, :right end - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -167,19 +167,19 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'of rows' do - pending + skip end context 'of headers' do - pending + skip end context 'of footers' do - pending + skip end end end diff --git a/spec/integration/boundaries_spec.rb b/spec/integration/boundaries_spec.rb index 2287f2b..6d61929 100644 --- a/spec/integration/boundaries_spec.rb +++ b/spec/integration/boundaries_spec.rb @@ -16,7 +16,7 @@ context 'when ":"' do let(:horizontal_boundary) { ':' } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ : a : bb : ccc : dddd : +------+------+------+------+ @@ -25,14 +25,14 @@ +------+------+------+------+ : aaaa : b : cc : ddd : +------+------+------+------+ - }) } + })) } end context 'when "||" and boundary intersection is "++"' do let(:horizontal_boundary) { '||' } let(:boundary_intersection) { '++' } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ ++------++------++------++------++ || a || bb || ccc || dddd || ++------++------++------++------++ @@ -41,7 +41,7 @@ ++------++------++------++------++ || aaaa || b || cc || ddd || ++------++------++------++------++ - }) } + })) } context 'with spanned cells' do before do @@ -49,7 +49,7 @@ table.rows << [{ :value => 'x', :colspan => 2, :align => :right }, 'c', 'd'] end - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ ++------++------++------++------++ || a || bb || ccc || dddd || ++------++------++------++------++ @@ -60,7 +60,7 @@ ++------++------++------++------++ || aaaa || b || cc || ddd || ++------++------++------++------++ - }) } + })) } end end @@ -69,7 +69,7 @@ describe 'vertical boundaries when "="' do let(:vertical_boundary) { '=' } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +======+======+======+======+ | a | bb | ccc | dddd | +======+======+======+======+ @@ -78,13 +78,13 @@ +======+======+======+======+ | aaaa | b | cc | ddd | +======+======+======+======+ - }) } + })) } end describe 'boundary intersections when "*"' do let(:boundary_intersection) { '*' } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ *------*------*------*------* | a | bb | ccc | dddd | *------*------*------*------* @@ -93,13 +93,13 @@ *------*------*------*------* | aaaa | b | cc | ddd | *------*------*------*------* - }) } + })) } end describe 'horizantal padding when 3 spaces' do let(:horizontal_padding) { 3 } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +----------+----------+----------+----------+ | a | bb | ccc | dddd | +----------+----------+----------+----------+ @@ -108,6 +108,6 @@ +----------+----------+----------+----------+ | aaaa | b | cc | ddd | +----------+----------+----------+----------+ - }) } + })) } end end diff --git a/spec/integration/column_spans_spec.rb b/spec/integration/column_spans_spec.rb index bdfbe11..4d71ca8 100644 --- a/spec/integration/column_spans_spec.rb +++ b/spec/integration/column_spans_spec.rb @@ -13,7 +13,7 @@ context 'aligned to the left' do let(:align) { :left } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -23,13 +23,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'center aligned' do let(:align) { :center } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -39,13 +39,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'aligned to the right' do let(:align) { :right } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -55,7 +55,7 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end end @@ -67,7 +67,7 @@ context 'aligned to the left' do let(:align) { :left } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -77,13 +77,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'center aligned' do let(:align) { :center } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -93,13 +93,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'aligned to the right' do let(:align) { :right } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -109,7 +109,7 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end end end @@ -123,7 +123,7 @@ context 'aligned to the left' do let(:align) { :left } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -133,13 +133,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'center aligned' do let(:align) { :center } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -149,13 +149,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'aligned to the right' do let(:align) { :right } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -165,7 +165,7 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end end @@ -177,7 +177,7 @@ context 'aligned to the left' do let(:align) { :left } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -187,13 +187,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'center aligned' do let(:align) { :center } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -203,13 +203,13 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end context 'aligned to the right' do let(:align) { :right } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+------+ | a | bb | ccc | dddd | +------+------+------+------+ @@ -219,7 +219,7 @@ +------+------+------+------+ | aaaa | b | cc | ddd | +------+------+------+------+ - }) } + })) } end end end diff --git a/spec/integration/parts_spec.rb b/spec/integration/parts_spec.rb index 443aeeb..7dcc0cf 100644 --- a/spec/integration/parts_spec.rb +++ b/spec/integration/parts_spec.rb @@ -8,61 +8,61 @@ subject { table.to_s } describe 'rows' do - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +-----+------+------+----+ | aa | bbb | cccc | d | | aaa | bbbb | c | dd | +-----+------+------+----+ - }) } + })) } context 'when nothing is passed into the contructor' do let(:rows) { nil } it 'is an empty array' do - table.rows.should == [] + expect(table.rows).to eq([]) end end context 'with unequal number of cells' do - pending + skip end end describe 'head' do let(:head) { @head } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +-----+------+------+------+ | a | bb | ccc | dddd | +-----+------+------+------+ | aa | bbb | cccc | d | | aaa | bbbb | c | dd | +-----+------+------+------+ - }) } + })) } end describe 'foot' do let(:foot) { @foot } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +------+------+------+-----+ | aa | bbb | cccc | d | | aaa | bbbb | c | dd | +------+------+------+-----+ | aaaa | b | cc | ddd | +------+------+------+-----+ - }) } + })) } end describe 'separators' do let(:rows) { @rows.insert(1, :separator) } - it { should == deindent(%q{ + it { is_expected.to eq(deindent(%q{ +-----+------+------+----+ | aa | bbb | cccc | d | +-----+------+------+----+ | aaa | bbbb | c | dd | +-----+------+------+----+ - }) } + })) } end end diff --git a/spec/integration/performance_spec.rb b/spec/integration/performance_spec.rb index 19c9e5c..79c373e 100644 --- a/spec/integration/performance_spec.rb +++ b/spec/integration/performance_spec.rb @@ -6,7 +6,7 @@ base = time_to_render_num_of_rows 1_000 time = time_to_render_num_of_rows 10_000 - time.should_not > base * 20 + expect(time).not_to be > base * 20 end def time_to_render_num_of_rows(num) diff --git a/spec/integration_helper.rb b/spec/integration_helper.rb index 05b9325..a4ba2de 100644 --- a/spec/integration_helper.rb +++ b/spec/integration_helper.rb @@ -8,6 +8,5 @@ %w( aaa bbbb c dd ), ] @foot = %w( aaaa b cc ddd ) - @table = Text::Table.new :rows => @rows, :head => @head, :foot => @foot end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 557ceb6..9973f9b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'text-table' require 'rspec' -require 'rspec/autorun' def deindent(table) table.gsub(/^\s*/, '') diff --git a/text-table.gemspec b/text-table.gemspec index 68e15d9..1cf4b16 100644 --- a/text-table.gemspec +++ b/text-table.gemspec @@ -17,6 +17,6 @@ Gem::Specification.new do |gem| gem.files = `git ls-files`.split($/) gem.test_files = `git ls-files -- spec/*`.split($/) gem.extra_rdoc_files = %w[LICENSE README.rdoc] - gem.add_development_dependency 'rspec', '~> 2' + gem.add_development_dependency 'rspec', '~> 3.5' gem.license = 'MIT' end