diff --git a/lib/xsv/workbook.rb b/lib/xsv/workbook.rb index d18285f..0ee7e86 100644 --- a/lib/xsv/workbook.rb +++ b/lib/xsv/workbook.rb @@ -42,6 +42,8 @@ def self.open(data, **kws) # trim_empty_rows (false) Scan sheet for end of content and don't return trailing rows # def initialize(zip, trim_empty_rows: false) + raise ArgumentError, "Passed argument is not an instance of Zip::File. Did you mean to use Workbook.open?" unless zip.is_a?(Zip::File) + @zip = zip @trim_empty_rows = trim_empty_rows diff --git a/test/workbook_test.rb b/test/workbook_test.rb index af916ba..3edd045 100644 --- a/test/workbook_test.rb +++ b/test/workbook_test.rb @@ -58,4 +58,10 @@ def test_open_without_shared_strings @workbook = Xsv::Workbook.open("test/files/no-shared-strings.xlsx") refute_empty @workbook.sheets end + + def test_new_instead_of_open + assert_raises ArgumentError do + Xsv::Workbook.new "not a Zip::File instance" + end + end end