aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2022-03-19 21:48:07 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2022-03-19 21:48:07 -0400
commita6e765da9b4da8cf9ddedcbaeb29fe5dca5df263 (patch)
tree39a2e5d06c16d048e9618e1170e3b6304fbade2e /spec/lib
parente67f4551479264125a641b955523d95e192b6d44 (diff)
parentf5fb17e5a64b215644bc104f099dad8c2f10c37d (diff)
Update upstream source from tag 'upstream/2.9.0'
Update to upstream version '2.9.0' with Debian dir 41b8f9c552bbf25b076de11901d6f615d684366f
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/roo/excelx/cell/time_spec.rb15
-rwxr-xr-xspec/lib/roo/excelx_spec.rb10
-rw-r--r--spec/lib/roo/spreadsheet_spec.rb2
-rw-r--r--spec/lib/roo/utils_spec.rb9
4 files changed, 25 insertions, 11 deletions
diff --git a/spec/lib/roo/excelx/cell/time_spec.rb b/spec/lib/roo/excelx/cell/time_spec.rb
new file mode 100644
index 0000000..214443f
--- /dev/null
+++ b/spec/lib/roo/excelx/cell/time_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+RSpec.describe Roo::Excelx::Cell::Time do
+ it "should set the cell value to the correct number of seconds" do
+ value = 0.05513888888888888 # '1:19:24'
+ excelx_type = [:numeric_or_formula, "h:mm:ss"]
+ base_timestamp = Date.new(1899, 12, 30).to_time.to_i
+ time_cell = Roo::Excelx::Cell::Time.new(value, nil, excelx_type, 1, nil, base_timestamp, nil)
+ expect(time_cell.value).to eq(1*60*60 + 19*60 + 24) # '1:19:24' in seconds
+ # use case from https://github.com/roo-rb/roo/issues/310
+ value = 0.523761574074074 # '12:34:13' in seconds
+ time_cell = Roo::Excelx::Cell::Time.new(value, nil, excelx_type, 1, nil, base_timestamp, nil)
+ expect(time_cell.value).to eq(12*60*60 + 34*60 + 13) # 12:34:13 in seconds
+ end
+end \ No newline at end of file
diff --git a/spec/lib/roo/excelx_spec.rb b/spec/lib/roo/excelx_spec.rb
index 1b67a4d..7cc9b13 100755
--- a/spec/lib/roo/excelx_spec.rb
+++ b/spec/lib/roo/excelx_spec.rb
@@ -86,6 +86,14 @@ describe Roo::Excelx do
end
end
+ describe 'for a workbook with hidden sheets' do
+ let(:path) { 'test/files/hidden_sheets.xlsx' }
+
+ it 'returns the cell contents from the visible sheet' do
+ expect(Roo::Excelx.new(path, only_visible_sheets: true).cell('A', 1)).to eq "visible sheet 1"
+ end
+ end
+
describe '#parse' do
let(:path) { 'test/files/numeric-link.xlsx' }
@@ -653,4 +661,4 @@ describe 'Roo::Excelx with options set' do
end
end
end
-end \ No newline at end of file
+end
diff --git a/spec/lib/roo/spreadsheet_spec.rb b/spec/lib/roo/spreadsheet_spec.rb
index 19fb8a7..08b6bf4 100644
--- a/spec/lib/roo/spreadsheet_spec.rb
+++ b/spec/lib/roo/spreadsheet_spec.rb
@@ -25,7 +25,7 @@ describe Roo::Spreadsheet do
let(:filename) { tempfile.path }
it 'loads the proper type' do
- expect(Roo::CSV).to receive(:new).with(filename, file_warning: :ignore).and_call_original
+ expect(Roo::CSV).to receive(:new).with(filename, {file_warning: :ignore}).and_call_original
expect(Roo::Spreadsheet.open(tempfile, extension: :csv)).to be_a(Roo::CSV)
end
end
diff --git a/spec/lib/roo/utils_spec.rb b/spec/lib/roo/utils_spec.rb
index c000ae7..a32a32d 100644
--- a/spec/lib/roo/utils_spec.rb
+++ b/spec/lib/roo/utils_spec.rb
@@ -43,15 +43,6 @@ RSpec.describe ::Roo::Utils do
end
end
- context '.split_coordinate' do
- it "returns the expected result" do
- expect(described_class.split_coordinate('A1')).to eq [1, 1]
- expect(described_class.split_coordinate('B2')).to eq [2, 2]
- expect(described_class.split_coordinate('R2')).to eq [2, 18]
- expect(described_class.split_coordinate('AR31')).to eq [31, 18 + 26]
- end
- end
-
context '.extract_coordinate' do
it "returns the expected result" do
expect(described_class.extract_coordinate('A1')).to eq [1, 1]