|
39 | 39 | end |
40 | 40 | end |
41 | 41 |
|
| 42 | + describe 'read tables' do |
| 43 | + before do |
| 44 | + @doc = Docx::Document.open(@fixtures_path + '/tables.docx') |
| 45 | + end |
| 46 | + |
| 47 | + it "should have tables with rows and cells" do |
| 48 | + expect(@doc.tables.count).to eq 2 |
| 49 | + @doc.tables.each do |table| |
| 50 | + expect(table).to be_an_instance_of(Docx::Elements::Containers::Table) |
| 51 | + table.rows.each do |row| |
| 52 | + expect(row).to be_an_instance_of(Docx::Elements::Containers::TableRow) |
| 53 | + row.cells.each do |cell| |
| 54 | + expect(cell).to be_an_instance_of(Docx::Elements::Containers::TableCell) |
| 55 | + end |
| 56 | + end |
| 57 | + end |
| 58 | + end |
| 59 | + |
| 60 | + it "should have tables with columns and cells" do |
| 61 | + @doc.tables.each do |table| |
| 62 | + table.columns.each do |column| |
| 63 | + expect(column).to be_an_instance_of(Docx::Elements::Containers::TableColumn) |
| 64 | + column.cells.each do |cell| |
| 65 | + expect(cell).to be_an_instance_of(Docx::Elements::Containers::TableCell) |
| 66 | + end |
| 67 | + end |
| 68 | + end |
| 69 | + end |
| 70 | + |
| 71 | + it "should have proper count" do |
| 72 | + expect(@doc.tables[0].row_count).to eq 171 |
| 73 | + expect(@doc.tables[1].row_count).to eq 2 |
| 74 | + expect(@doc.tables[0].column_count).to eq 2 |
| 75 | + expect(@doc.tables[1].column_count).to eq 2 |
| 76 | + end |
| 77 | + |
| 78 | + it "should have tables with proper text" do |
| 79 | + @doc.tables[0].rows[0].cells[0].text.should eq "ENGLISH" |
| 80 | + @doc.tables[0].rows[0].cells[1].text.should eq "FRANÇAIS" |
| 81 | + @doc.tables[1].rows[0].cells[0].text.should eq "Second table" |
| 82 | + @doc.tables[1].rows[0].cells[1].text.should eq "Second tableau" |
| 83 | + @doc.tables[0].columns[0].cells[5].text.should eq "aphids" |
| 84 | + @doc.tables[0].columns[1].cells[5].text.should eq "puceron" |
| 85 | + end |
| 86 | + end |
| 87 | + |
42 | 88 | describe 'editing' do |
43 | 89 | before do |
44 | 90 | @doc = Docx::Document.open(@fixtures_path + '/editing.docx') |
|
0 commit comments