-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
While writing tests for worksheet protection timon/spreadsheet@c2351bd3e2 I've found strange issue:
The following code fails:
def test_read_protected
path = File.join @data, "test_merged_and_protected.xls"
book = Spreadsheet.open path
sheet = book.worksheet(0)
assert(sheet.protected?, "Expected sheet to be protected")
assert_equal(Spreadsheet::Excel::Password.password_hash('testing'), sheet.password_hash)
end
# => Expected sheet to be protected.The following code runs fine due to side effects:
def test_read_protected
path = File.join @data, "test_merged_and_protected.xls"
book = Spreadsheet.open path
sheet = book.worksheet(0)
sheet.inspect # Hello, magic!
assert(sheet.protected?, "Expected sheet to be protected")
assert_equal(Spreadsheet::Excel::Password.password_hash('testing'), sheet.password_hash)
endI'm not sure what's correct way to handle this issue — either load all worksheets greedily after workbook is read, or guard all methods with ensure_rows_read — both approaches seems to have their positive and negative sides
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels