|
2 | 2 |
|
3 | 3 | describe 'Creek trying to parsing an invalid file.' do |
4 | 4 | it 'Fail to open a legacy xls file.' do |
5 | | - lambda { Creek::Book.new 'spec/fixtures/invalid.xls' }.should raise_error 'Not a valid file format.' |
| 5 | + expect { Creek::Book.new 'spec/fixtures/invalid.xls' } |
| 6 | + .to raise_error 'Not a valid file format.' |
6 | 7 | end |
7 | 8 |
|
8 | 9 | it 'Ignore file extensions on request.' do |
9 | 10 | path = 'spec/fixtures/sample-as-zip.zip' |
10 | | - lambda { Creek::Book.new path, :check_file_extension => false }.should_not raise_error |
| 11 | + expect { Creek::Book.new path, check_file_extension: false } |
| 12 | + .not_to raise_error |
11 | 13 | end |
12 | 14 |
|
13 | 15 | it 'Check file extension when requested.' do |
14 | | - open_book = lambda { Creek::Book.new 'spec/fixtures/invalid.xls', :check_file_extension => true } |
15 | | - open_book.should raise_error 'Not a valid file format.' |
| 16 | + expect { Creek::Book.new 'spec/fixtures/invalid.xls', check_file_extension: true } |
| 17 | + .to raise_error 'Not a valid file format.' |
16 | 18 | end |
17 | 19 |
|
18 | 20 | it 'Fail to open remote file' do |
19 | | - lambda { Creek::Book.new 'http://dev-builds.libreoffice.org/tmp/test.xlsx' }.should raise_error |
| 21 | + expect { Creek::Book.new 'http://dev-builds.libreoffice.org/tmp/test.xlsx' } |
| 22 | + .to raise_error(Zip::Error, /not found/) |
20 | 23 | end |
21 | 24 |
|
22 | 25 | it 'Opens remote file with remote flag' do |
23 | | - lambda { Creek::Book.new 'http://dev-builds.libreoffice.org/tmp/test.xlsx', remote: true }.should_not raise_error |
| 26 | + expect { Creek::Book.new 'http://dev-builds.libreoffice.org/tmp/test.xlsx', remote: true } |
| 27 | + .not_to raise_error |
24 | 28 | end |
25 | 29 |
|
26 | 30 | it 'Check file extension of original_filename if passed.' do |
27 | 31 | path = 'spec/fixtures/temp_string_io_file_path_with_no_extension' |
28 | | - lambda { Creek::Book.new path, :original_filename => 'invalid.xls' }.should raise_error 'Not a valid file format.' |
29 | | - lambda { Creek::Book.new path, :original_filename => 'valid.xlsx' }.should_not raise_error |
| 32 | + expect { Creek::Book.new path, :original_filename => 'invalid.xls' } |
| 33 | + .to raise_error 'Not a valid file format.' |
| 34 | + expect { Creek::Book.new path, :original_filename => 'valid.xlsx' } |
| 35 | + .not_to raise_error |
30 | 36 | end |
31 | | - |
32 | 37 | end |
33 | 38 |
|
34 | 39 | describe 'Creek parsing a sample XLSX file' do |
|
49 | 54 | end |
50 | 55 |
|
51 | 56 | it 'open an XLSX file successfully.' do |
52 | | - @creek.should_not be_nil |
| 57 | + expect(@creek).not_to be_nil |
53 | 58 | end |
54 | 59 |
|
55 | 60 | it 'find sheets successfully.' do |
56 | | - @creek.sheets.count.should == 1 |
| 61 | + expect(@creek.sheets.count).to eq(1) |
57 | 62 | sheet = @creek.sheets.first |
58 | | - sheet.state.should eql nil |
59 | | - sheet.name.should eql 'Sheet1' |
60 | | - sheet.rid.should eql 'rId1' |
| 63 | + expect(sheet.state).to eql nil |
| 64 | + expect(sheet.name).to eql 'Sheet1' |
| 65 | + expect(sheet.rid).to eql 'rId1' |
61 | 66 | end |
62 | 67 |
|
63 | 68 | it 'Parse rows with empty cells successfully.' do |
|
68 | 73 | row_count += 1 |
69 | 74 | end |
70 | 75 |
|
71 | | - rows[0].should == @expected_rows[0] |
72 | | - rows[1].should == @expected_rows[1] |
73 | | - rows[2].should == @expected_rows[2] |
74 | | - rows[3].should == @expected_rows[3] |
75 | | - rows[4].should == @expected_rows[4] |
76 | | - rows[5].should == @expected_rows[5] |
77 | | - rows[6].should == @expected_rows[6] |
78 | | - rows[7].should == @expected_rows[7] |
79 | | - rows[8].should == @expected_rows[8] |
80 | | - row_count.should == 9 |
| 76 | + expect(rows[0]).to eq(@expected_rows[0]) |
| 77 | + expect(rows[1]).to eq(@expected_rows[1]) |
| 78 | + expect(rows[2]).to eq(@expected_rows[2]) |
| 79 | + expect(rows[3]).to eq(@expected_rows[3]) |
| 80 | + expect(rows[4]).to eq(@expected_rows[4]) |
| 81 | + expect(rows[5]).to eq(@expected_rows[5]) |
| 82 | + expect(rows[6]).to eq(@expected_rows[6]) |
| 83 | + expect(rows[7]).to eq(@expected_rows[7]) |
| 84 | + expect(rows[8]).to eq(@expected_rows[8]) |
| 85 | + expect(row_count).to eq(9) |
81 | 86 | end |
82 | 87 |
|
83 | 88 | it 'Parse rows with empty cells and meta data successfully.' do |
|
87 | 92 | rows << row |
88 | 93 | row_count += 1 |
89 | 94 | end |
90 | | - rows.map{|r| r['cells']}.should == @expected_rows |
| 95 | + expect(rows.map{|r| r['cells']}).to eq(@expected_rows) |
91 | 96 | end |
92 | 97 | end |
0 commit comments