Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert test suite to RSpec 3 #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions spec/cell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
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
@cell.colspan == 1
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
Expand Down
28 changes: 14 additions & 14 deletions spec/enumerable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
46 changes: 23 additions & 23 deletions spec/integration/alignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 |
+------+------+------+------+
Expand All @@ -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 |
+------+------+------+------+
Expand All @@ -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 |
+------+------+------+------+
Expand All @@ -96,7 +96,7 @@
+------+------+------+------+
| aaaa | b | cc | ddd |
+------+------+------+------+
}) }
})) }
end
end

Expand All @@ -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

Expand All @@ -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 |
+------+------+------+------+
Expand All @@ -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
24 changes: 12 additions & 12 deletions spec/integration/boundaries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
+------+------+------+------+
Expand All @@ -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 ||
++------++------++------++------++
Expand All @@ -41,15 +41,15 @@
++------++------++------++------++
|| aaaa || b || cc || ddd ||
++------++------++------++------++
}) }
})) }

context 'with spanned cells' do
before do
table.rows << :separator
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 ||
++------++------++------++------++
Expand All @@ -60,7 +60,7 @@
++------++------++------++------++
|| aaaa || b || cc || ddd ||
++------++------++------++------++
}) }
})) }
end

end
Expand All @@ -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 |
+======+======+======+======+
Expand All @@ -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 |
*------*------*------*------*
Expand All @@ -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 |
+----------+----------+----------+----------+
Expand All @@ -108,6 +108,6 @@
+----------+----------+----------+----------+
| aaaa | b | cc | ddd |
+----------+----------+----------+----------+
}) }
})) }
end
end
Loading