diff options
| author | 2025-11-26 19:02:28 -0500 | |
|---|---|---|
| committer | 2025-11-26 19:02:28 -0500 | |
| commit | c62f8376a13e7a4f493167aba1c66a9201fc59c6 (patch) | |
| tree | d58492f972be02c406d26620004e1ffe2086fbc7 /spec | |
| parent | ae103e148eb3c15606b816505492d870ef062ad3 (diff) | |
New upstream version 3.0.0.upstream/3.0.0upstream
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/lib/roo/base_spec.rb | 36 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 11 |
2 files changed, 42 insertions, 5 deletions
diff --git a/spec/lib/roo/base_spec.rb b/spec/lib/roo/base_spec.rb index 9d44656..2d8d8d7 100644 --- a/spec/lib/roo/base_spec.rb +++ b/spec/lib/roo/base_spec.rb @@ -183,10 +183,22 @@ describe Roo::Base do end describe '#each_with_pagename' do - it 'should return an enumerator with all the rows' do - each_with_pagename = spreadsheet.each_with_pagename - expect(each_with_pagename).to be_a(Enumerator) - expect(each_with_pagename.to_a.last).to eq([spreadsheet.default_sheet, spreadsheet]) + context 'when block given' do + it 'iterate with sheet and sheet_name' do + sheet_names = [] + spreadsheet.each_with_pagename do |sheet_name, sheet| + sheet_names << sheet_name + end + expect(sheet_names).to eq ['my_sheet', 'blank sheet'] + end + end + + context 'when called without block' do + it 'should return an enumerator with all the rows' do + each_with_pagename = spreadsheet.each_with_pagename + expect(each_with_pagename).to be_a(Enumerator) + expect(each_with_pagename.to_a.last).to eq([spreadsheet.default_sheet, spreadsheet]) + end end end @@ -277,7 +289,21 @@ EOS end it 'should convert the spreadsheet to csv using the separator when is passed on the parameter' do - expect(spreadsheet.to_csv(nil, ';')).to eq(expected_csv_with_semicolons) + expect(spreadsheet.to_csv(separator: ';')).to eq(expected_csv_with_semicolons) + end + + context 'should contains the deprecation warning message' do + it 'convert the spreadsheet to csv using the separator' do + converting =-> { spreadsheet.to_csv(nil, ';') } + expect(converting.call).to eq(expected_csv_with_semicolons) + expect(&converting).to output(/DEPRECATION.*:separator\b/).to_stderr + end + + it 'be able to arguments: filename, separator, sheet' do + converting =-> { spreadsheet.to_csv(nil, ';', spreadsheet.default_sheet) } + expect(converting.call).to eq(expected_csv_with_semicolons) + expect(&converting).to output(/DEPRECATION.*:sheet\b/).to_stderr + end end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a093008..f35cf55 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,4 +6,15 @@ RSpec.configure do |c| c.include Helpers c.color = true c.formatter = :documentation if ENV["USE_REPORTERS"] + original_stderr = $stderr + original_stdout = $stdout + c.before(:all) do + # Redirect stderr and stdout + $stderr = File.open(File::NULL, "w") + $stdout = File.open(File::NULL, "w") + end + c.after(:all) do + $stderr = original_stderr + $stdout = original_stdout + end end |
