robust_excel_ole 0.6 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog +12 -0
- data/README.rdoc +5 -3
- data/README_detail.rdoc +1 -1
- data/examples/edit_sheets/example_adding_sheets.rb +1 -1
- data/examples/edit_sheets/example_expanding.rb +1 -1
- data/examples/open_save_close/example_control_to_excel.rb +2 -2
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_forget.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_accept.rb +2 -2
- data/examples/open_save_close/example_read_only.rb +1 -1
- data/examples/open_save_close/example_simple.rb +1 -1
- data/lib/robust_excel_ole/book.rb +89 -111
- data/lib/robust_excel_ole/excel.rb +49 -50
- data/lib/robust_excel_ole/general.rb +3 -3
- data/lib/robust_excel_ole/reo_common.rb +78 -1
- data/lib/robust_excel_ole/sheet.rb +16 -23
- data/lib/robust_excel_ole/version.rb +1 -1
- data/spec/book_spec.rb +7 -7
- data/spec/book_specs/book_close_spec.rb +24 -5
- data/spec/book_specs/book_misc_spec.rb +16 -7
- data/spec/book_specs/book_open_spec.rb +15 -20
- data/spec/book_specs/book_save_spec.rb +21 -21
- data/spec/book_specs/book_sheet_spec.rb +3 -3
- data/spec/book_specs/book_unobtr_spec.rb +1 -1
- data/spec/data/book_with_blank.xls +0 -0
- data/spec/data/different_workbook.xls +0 -0
- data/spec/data/refed_wb.xls +0 -0
- data/spec/data/reference_workbook.xls +0 -0
- data/spec/data/referencing_wb.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +87 -125
- data/spec/general_spec.rb +2 -2
- data/spec/reo_common_spec.rb +1 -1
- data/spec/sheet_spec.rb +13 -17
- metadata +7 -3
data/spec/excel_spec.rb
CHANGED
@@ -20,6 +20,8 @@ module RobustExcelOle
|
|
20
20
|
@another_simple_file = @dir + '/another_workbook.xls'
|
21
21
|
@different_file = @dir + '/different_workbook.xls'
|
22
22
|
@invalid_name_file = 'b/workbook.xls'
|
23
|
+
@simple_file1 = @simple_file
|
24
|
+
@different_file1 = @different_file
|
23
25
|
end
|
24
26
|
|
25
27
|
after do
|
@@ -31,8 +33,8 @@ module RobustExcelOle
|
|
31
33
|
|
32
34
|
before do
|
33
35
|
|
34
|
-
book1 = Book.open(@
|
35
|
-
book2 = Book.open(@
|
36
|
+
book1 = Book.open(@simple_file1)
|
37
|
+
book2 = Book.open(@simple_file1, :force_excel => :new)
|
36
38
|
a = book1.saved
|
37
39
|
end
|
38
40
|
|
@@ -327,7 +329,6 @@ module RobustExcelOle
|
|
327
329
|
end
|
328
330
|
end
|
329
331
|
|
330
|
-
# Error
|
331
332
|
context "close excel instances" do
|
332
333
|
def direct_excel_creation_helper # :nodoc: #
|
333
334
|
expect { WIN32OLE.connect("Excel.Application") }.to raise_error
|
@@ -340,13 +341,11 @@ module RobustExcelOle
|
|
340
341
|
end
|
341
342
|
|
342
343
|
it "simple file with default" do
|
343
|
-
Excel.
|
344
|
+
Excel.kill_all
|
344
345
|
direct_excel_creation_helper
|
345
|
-
sleep
|
346
|
-
|
347
|
-
sleep
|
348
|
-
Excel.close_all
|
349
|
-
sleep 0.1
|
346
|
+
sleep 4
|
347
|
+
Excel.kill_all
|
348
|
+
sleep 4
|
350
349
|
expect { WIN32OLE.connect("Excel.Application") }.to raise_error
|
351
350
|
end
|
352
351
|
end
|
@@ -380,93 +379,80 @@ module RobustExcelOle
|
|
380
379
|
|
381
380
|
context "with unsaved_workbooks" do
|
382
381
|
|
383
|
-
before do
|
384
|
-
book1 = Book.open(@
|
385
|
-
book2 = Book.open(@
|
386
|
-
book3 = Book.open(@another_simple_file, :force_excel => book2.excel)
|
387
|
-
book4 = Book.open(@different_file, :force_excel => :new)
|
382
|
+
before do
|
383
|
+
book1 = Book.open(@simple_file1, :force_excel => :new)
|
384
|
+
book2 = Book.open(@different_file, :force_excel => :new)
|
388
385
|
@excel1 = book1.excel
|
386
|
+
sheet1 = book1.sheet(1)
|
387
|
+
@old_cell_value1 = sheet1[1,1].value
|
388
|
+
sheet1[1,1] = sheet1[1,1].value == "foo" ? "bar" : "foo"
|
389
389
|
@excel2 = book2.excel
|
390
|
-
@excel4 = book4.excel
|
391
390
|
sheet2 = book2.sheet(1)
|
392
391
|
@old_cell_value2 = sheet2[1,1].value
|
393
392
|
sheet2[1,1] = sheet2[1,1].value == "foo" ? "bar" : "foo"
|
394
|
-
sheet3 = book3.sheet(1)
|
395
|
-
@old_cell_value3 = sheet3[1,1].value
|
396
|
-
sheet3[1,1] = sheet3[1,1].value == "foo" ? "bar" : "foo"
|
397
393
|
end
|
398
394
|
|
399
395
|
it "should close the first Excel without unsaved workbooks and then raise an error" do
|
400
396
|
expect{
|
401
397
|
Excel.close_all(:if_unsaved => :raise)
|
402
|
-
}.to raise_error(
|
403
|
-
@excel1.
|
398
|
+
}.to raise_error(UnsavedWorkbooks, "Excel contains unsaved workbooks")
|
399
|
+
@excel1.should be_alive
|
404
400
|
@excel2.should be_alive
|
405
|
-
@excel4.should be_alive
|
406
401
|
end
|
407
402
|
|
408
403
|
it "should close the first Excel without unsaved workbooks and then raise an error per default" do
|
409
404
|
expect{
|
410
405
|
Excel.close_all
|
411
|
-
}.to raise_error(
|
412
|
-
@excel1.
|
406
|
+
}.to raise_error(UnsavedWorkbooks, "Excel contains unsaved workbooks")
|
407
|
+
@excel1.should be_alive
|
413
408
|
@excel2.should be_alive
|
414
|
-
@excel4.should be_alive
|
415
409
|
end
|
416
410
|
|
417
|
-
# Error
|
418
411
|
it "should close the Excel instances with saving the unsaved workbooks" do
|
419
412
|
Excel.close_all(:if_unsaved => :save)
|
420
413
|
@excel1.should_not be_alive
|
421
414
|
@excel2.should_not be_alive
|
422
|
-
@
|
423
|
-
|
415
|
+
new_book1 = Book.open(@simple_file1)
|
416
|
+
new_sheet1 = new_book1.sheet(1)
|
417
|
+
new_sheet1[1,1].value.should_not == @old_cell_value1
|
418
|
+
new_book1.close
|
419
|
+
new_book2 = Book.open(@different_file1)
|
424
420
|
new_sheet2 = new_book2.sheet(1)
|
425
421
|
new_sheet2[1,1].value.should_not == @old_cell_value2
|
426
|
-
new_book2.close
|
427
|
-
new_book3 = Book.open(@another_simple_file)
|
428
|
-
new_sheet3 = new_book3.sheet(1)
|
429
|
-
new_sheet3[1,1].value.should_not == @old_cell_value3
|
430
|
-
new_book3.close
|
422
|
+
new_book2.close
|
431
423
|
end
|
432
424
|
|
433
|
-
# Error
|
434
425
|
it "should close the Excel instances without saving the unsaved workbooks" do
|
435
|
-
@excel1.displayalerts = @excel2.displayalerts = @excel4.displayalerts = false
|
436
426
|
Excel.close_all(:if_unsaved => :forget)
|
437
427
|
@excel1.should_not be_alive
|
438
428
|
@excel2.should_not be_alive
|
439
|
-
@
|
440
|
-
|
429
|
+
new_book1 = Book.open(@simple_file1)
|
430
|
+
new_sheet1 = new_book1.sheet(1)
|
431
|
+
new_sheet1[1,1].value.should == @old_cell_value1
|
432
|
+
new_book1.close
|
433
|
+
new_book2 = Book.open(@different_file1)
|
441
434
|
new_sheet2 = new_book2.sheet(1)
|
442
435
|
new_sheet2[1,1].value.should == @old_cell_value2
|
443
436
|
new_book2.close
|
444
|
-
new_book3 = Book.open(@another_simple_file)
|
445
|
-
new_sheet3 = new_book3.sheet(1)
|
446
|
-
new_sheet3[1,1].value.should == @old_cell_value3
|
447
|
-
new_book3.close
|
448
437
|
end
|
449
438
|
|
450
439
|
it "should raise an error for invalid option" do
|
451
440
|
expect {
|
452
441
|
Excel.close_all(:if_unsaved => :invalid_option)
|
453
|
-
}.to raise_error(
|
442
|
+
}.to raise_error(OptionInvalid, ":if_unsaved: invalid option: :invalid_option")
|
454
443
|
end
|
455
444
|
|
456
445
|
end
|
457
446
|
|
458
|
-
context "
|
447
|
+
context "with unsaved workbooks simple" do
|
459
448
|
|
460
|
-
# Error
|
461
449
|
it "should save the unsaved workbook" do
|
462
450
|
book1 = Book.open(@simple_file, :visible => true)
|
463
|
-
excel1 = book1.excel
|
464
451
|
book1.sheet(1)[1,1] = "bar"
|
465
452
|
book1.Saved.should be_false
|
466
453
|
Excel.close_all(:if_unsaved => :save)
|
467
454
|
end
|
468
455
|
|
469
|
-
# Error
|
470
456
|
it "should forget the unsaved workbook" do
|
471
457
|
book1 = Book.open(@simple_file, :visible => true)
|
472
458
|
excel1 = book1.excel
|
@@ -526,27 +512,6 @@ module RobustExcelOle
|
|
526
512
|
# }.to raise_error(ExcelUserCanceled, "close: canceled by user")
|
527
513
|
# end
|
528
514
|
|
529
|
-
it "should save if user answers 'yes'" do
|
530
|
-
@excel1.displayalerts = @excel2.displayalerts = @excel4.displayalerts = true
|
531
|
-
@key_sender.puts "{enter}"
|
532
|
-
Excel.close_all(:if_unsaved => :forget)
|
533
|
-
@excel2.should_not be_alive
|
534
|
-
new_book2 = Book.open(@simple_file)
|
535
|
-
new_sheet2 = new_book2.sheet(1)
|
536
|
-
new_sheet2[1,1].value.should_not == @old_cell_value2
|
537
|
-
new_book2.close
|
538
|
-
end
|
539
|
-
|
540
|
-
it "should not save if user answers 'no'" do
|
541
|
-
@excel1.displayalerts = @excel2.displayalerts = @excel4.displayalerts = true
|
542
|
-
@key_sender.puts "{right}{enter}"
|
543
|
-
@key_sender.puts "{right}{enter}"
|
544
|
-
Excel.close_all(:if_unsaved => :forget)
|
545
|
-
@excel2.should_not be_alive
|
546
|
-
new_book2 = Book.open(@simple_file)
|
547
|
-
new_sheet2 = new_book2.sheet(1)
|
548
|
-
new_sheet2[1,1].value.should == @old_cell_value2
|
549
|
-
new_book2.close
|
550
515
|
end
|
551
516
|
end
|
552
517
|
end
|
@@ -616,9 +581,25 @@ module RobustExcelOle
|
|
616
581
|
@book2.saved.should be_false
|
617
582
|
expect{
|
618
583
|
@excel.close(:if_unsaved => :raise)
|
619
|
-
}.to raise_error(
|
584
|
+
}.to raise_error(UnsavedWorkbooks, "Excel contains unsaved workbooks")
|
620
585
|
end
|
621
586
|
|
587
|
+
it "should close the Excel without saving the workbook even with displayalerts true" do
|
588
|
+
@excel.displayalerts = false
|
589
|
+
@excel.should be_alive
|
590
|
+
@excel.displayalerts = true
|
591
|
+
@excel.close(:if_unsaved => :forget)
|
592
|
+
@excel.should_not be_alive
|
593
|
+
new_book = Book.open(@simple_file)
|
594
|
+
new_sheet = new_book.sheet(1)
|
595
|
+
new_sheet[1,1].value.should == @old_cell_value
|
596
|
+
new_book.close
|
597
|
+
new_book2 = Book.open(@another_simple_file)
|
598
|
+
new_sheet2 = new_book2.sheet(1)
|
599
|
+
new_sheet2[1,1].value.should == @old_cell_value2
|
600
|
+
new_book2.close
|
601
|
+
end
|
602
|
+
|
622
603
|
it "should close the Excel without saving the workbook" do
|
623
604
|
@excel.displayalerts = false
|
624
605
|
@excel.should be_alive
|
@@ -659,14 +640,14 @@ module RobustExcelOle
|
|
659
640
|
it "should raise an error for invalid option" do
|
660
641
|
expect {
|
661
642
|
@excel.close(:if_unsaved => :invalid_option)
|
662
|
-
}.to raise_error(
|
643
|
+
}.to raise_error(OptionInvalid, ":if_unsaved: invalid option: :invalid_option")
|
663
644
|
end
|
664
645
|
|
665
646
|
it "should raise an error by default" do
|
666
647
|
@excel.should be_alive
|
667
648
|
expect{
|
668
649
|
@excel.close
|
669
|
-
}.to raise_error(
|
650
|
+
}.to raise_error(UnsavedWorkbooks, "Excel contains unsaved workbooks")
|
670
651
|
end
|
671
652
|
|
672
653
|
it "should close the Excel without saving the workbook hard" do
|
@@ -742,46 +723,7 @@ module RobustExcelOle
|
|
742
723
|
@key_sender.puts "{left}{enter}"
|
743
724
|
expect{
|
744
725
|
@excel.close(:if_unsaved => :alert)
|
745
|
-
}.
|
746
|
-
end
|
747
|
-
|
748
|
-
it "should save if user answers 'yes'" do
|
749
|
-
# "Yes" is to the left of "No", which is the default. --> language independent
|
750
|
-
@excel.should be_alive
|
751
|
-
@excel.displayalerts = true
|
752
|
-
@key_sender.puts "{enter}"
|
753
|
-
@excel.close(:if_unsaved => :forget)
|
754
|
-
@excel.should_not be_alive
|
755
|
-
new_book = Book.open(@simple_file)
|
756
|
-
new_sheet = new_book.sheet(1)
|
757
|
-
new_sheet[1,1].value.should_not == @old_cell_value
|
758
|
-
new_book.close
|
759
|
-
end
|
760
|
-
|
761
|
-
it "should not save if user answers 'no'" do
|
762
|
-
@excel.should be_alive
|
763
|
-
@excel.displayalerts = true
|
764
|
-
@book.should be_alive
|
765
|
-
@book.saved.should be_false
|
766
|
-
@key_sender.puts "{right}{enter}"
|
767
|
-
@excel.close(:if_unsaved => :forget)
|
768
|
-
@excel.should_not be_alive
|
769
|
-
@book.should_not be_alive
|
770
|
-
new_book = Book.open(@simple_file)
|
771
|
-
new_sheet = new_book.sheet(1)
|
772
|
-
new_sheet[1,1].value.should == @old_cell_value
|
773
|
-
new_book.close
|
774
|
-
end
|
775
|
-
|
776
|
-
it "should not save if user answers 'cancel'" do
|
777
|
-
# strangely, in the "cancel" case, the question will sometimes be repeated twice
|
778
|
-
@excel.should be_alive
|
779
|
-
@excel.displayalerts = true
|
780
|
-
@book.should be_alive
|
781
|
-
@book.saved.should be_false
|
782
|
-
@key_sender.puts "{left}{enter}"
|
783
|
-
@key_sender.puts "{left}{enter}"
|
784
|
-
@excel.close(:if_unsaved => :forget)
|
726
|
+
}.to_not raise_error
|
785
727
|
end
|
786
728
|
|
787
729
|
end
|
@@ -884,7 +826,29 @@ module RobustExcelOle
|
|
884
826
|
|
885
827
|
end
|
886
828
|
|
887
|
-
context "with Visible and DisplayAlerts" do
|
829
|
+
context "with Visible and DisplayAlerts, foremost_window" do
|
830
|
+
|
831
|
+
it "should set Excel in foremost window" do
|
832
|
+
excel1 = Excel.create
|
833
|
+
excel2 = Excel.create
|
834
|
+
excel1.foremost_window
|
835
|
+
excel1.Visible.should be_true
|
836
|
+
excel1.visible.should be_true
|
837
|
+
end
|
838
|
+
|
839
|
+
|
840
|
+
it "should use values of the current Excel when reusing" do
|
841
|
+
excel1 = Excel.create
|
842
|
+
excel1.Visible.should be_false
|
843
|
+
excel1.DisplayAlerts.should be_false
|
844
|
+
excel1.Visible = true
|
845
|
+
excel1.DisplayAlerts = true
|
846
|
+
excel1.Visible.should be_true
|
847
|
+
excel1.DisplayAlerts.should be_true
|
848
|
+
excel2 = Excel.new(:reuse => true)
|
849
|
+
excel2.Visible.should be_true
|
850
|
+
excel2.DisplayAlerts.should be_true
|
851
|
+
end
|
888
852
|
|
889
853
|
it "should set Excel visible and invisible with current" do
|
890
854
|
excel1 = Excel.create
|
@@ -952,8 +916,7 @@ module RobustExcelOle
|
|
952
916
|
excel4.should === excel
|
953
917
|
excel4.Visible.should be_true
|
954
918
|
excel4.visible.should be_true
|
955
|
-
|
956
|
-
#excel4.DisplayAlerts.should be_true
|
919
|
+
excel4.DisplayAlerts.should be_true
|
957
920
|
excel4.displayalerts.should == :if_visible
|
958
921
|
excel5 = Excel.current(:visible => false)
|
959
922
|
excel5.should === excel
|
@@ -1247,7 +1210,7 @@ module RobustExcelOle
|
|
1247
1210
|
|
1248
1211
|
it "should report that Excel is not alive" do
|
1249
1212
|
@excel1.close
|
1250
|
-
expect{ @excel1.Nonexisting_method }.to raise_error(
|
1213
|
+
expect{ @excel1.Nonexisting_method }.to raise_error(ObjectNotAlive, "method missing: Excel not alive")
|
1251
1214
|
end
|
1252
1215
|
|
1253
1216
|
end
|
@@ -1369,8 +1332,7 @@ module RobustExcelOle
|
|
1369
1332
|
expect{
|
1370
1333
|
workbook = @excel1.generate_workbook(@invalid_name_file)
|
1371
1334
|
# not always Unknown ???? ToDo #*#
|
1372
|
-
|
1373
|
-
}.to raise_error(ExcelErrorSave)
|
1335
|
+
}.to raise_error(UnexpectedError)
|
1374
1336
|
end
|
1375
1337
|
|
1376
1338
|
end
|
@@ -1404,18 +1366,18 @@ module RobustExcelOle
|
|
1404
1366
|
it "should raise an error if name not defined" do
|
1405
1367
|
expect {
|
1406
1368
|
@excel1.nameval("foo")
|
1407
|
-
}.to raise_error(
|
1369
|
+
}.to raise_error(NameNotFound, /cannot find name "foo"/)
|
1408
1370
|
expect {
|
1409
1371
|
@excel1["foo"]
|
1410
|
-
}.to raise_error(
|
1372
|
+
}.to raise_error(NameNotFound, /cannot find name "foo"/)
|
1411
1373
|
expect {
|
1412
1374
|
excel2 = Excel.create
|
1413
1375
|
excel2.nameval("one")
|
1414
|
-
}.to raise_error(
|
1376
|
+
}.to raise_error(NameNotFound, /cannot find name "one"/)
|
1415
1377
|
expect {
|
1416
1378
|
excel3 = Excel.create
|
1417
1379
|
excel3["one"]
|
1418
|
-
}.to raise_error(
|
1380
|
+
}.to raise_error(NameNotFound, /cannot find name "one"/)
|
1419
1381
|
end
|
1420
1382
|
|
1421
1383
|
it "should set a range to a value" do
|
@@ -1429,10 +1391,10 @@ module RobustExcelOle
|
|
1429
1391
|
it "should raise an error if name cannot be evaluated" do
|
1430
1392
|
expect{
|
1431
1393
|
@excel1.set_nameval("foo", 1)
|
1432
|
-
}.to raise_error(
|
1394
|
+
}.to raise_error(NameNotFound, /cannot find name "foo"/)
|
1433
1395
|
expect{
|
1434
1396
|
@excel1["foo"] = 1
|
1435
|
-
}.to raise_error(
|
1397
|
+
}.to raise_error(NameNotFound, /cannot find name "foo"/)
|
1436
1398
|
end
|
1437
1399
|
end
|
1438
1400
|
|
@@ -1465,14 +1427,14 @@ module RobustExcelOle
|
|
1465
1427
|
it "should raise an error if name not defined for the sheet" do
|
1466
1428
|
expect {
|
1467
1429
|
@excel1.rangeval("foo")
|
1468
|
-
}.to raise_error(
|
1430
|
+
}.to raise_error(NameNotFound, /cannot find name "foo"/)
|
1469
1431
|
expect {
|
1470
1432
|
@excel1.rangeval("named_formula")
|
1471
|
-
}.to raise_error(
|
1433
|
+
}.to raise_error(NameNotFound, /cannot find name "named_formula"/)
|
1472
1434
|
expect {
|
1473
1435
|
excel2 = Excel.create
|
1474
1436
|
excel2.rangeval("one")
|
1475
|
-
}.to raise_error(
|
1437
|
+
}.to raise_error(NameNotFound, /cannot find name "one"/)
|
1476
1438
|
end
|
1477
1439
|
|
1478
1440
|
it "should set a range to a value" do
|
@@ -1484,7 +1446,7 @@ module RobustExcelOle
|
|
1484
1446
|
it "should raise an error if name cannot be evaluated" do
|
1485
1447
|
expect{
|
1486
1448
|
@excel1.set_nameval("foo", 1)
|
1487
|
-
}.to raise_error(
|
1449
|
+
}.to raise_error(NameNotFound, /cannot find name "foo"/)
|
1488
1450
|
end
|
1489
1451
|
|
1490
1452
|
end
|
data/spec/general_spec.rb
CHANGED
@@ -151,7 +151,7 @@ module RobustExcelOle
|
|
151
151
|
it "should raise an error for no strings" do
|
152
152
|
expect{
|
153
153
|
canonize(1)
|
154
|
-
}.to raise_error(
|
154
|
+
}.to raise_error(TypeErrorREO, "No string given to canonize, but 1")
|
155
155
|
end
|
156
156
|
|
157
157
|
end
|
@@ -171,7 +171,7 @@ module RobustExcelOle
|
|
171
171
|
it "should raise an error when asking excel of a sheet" do
|
172
172
|
expect{
|
173
173
|
@sheet.excel
|
174
|
-
}.to raise_error(
|
174
|
+
}.to raise_error(TypeErrorREO, "receiver instance is neither an Excel nor a Book")
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
data/spec/reo_common_spec.rb
CHANGED
@@ -96,7 +96,7 @@ module RobustExcelOle
|
|
96
96
|
it "should raise an error when asking excel of a sheet" do
|
97
97
|
expect{
|
98
98
|
@sheet.excel
|
99
|
-
}.to raise_error(
|
99
|
+
}.to raise_error(TypeErrorREO, "receiver instance is neither an Excel nor a Book")
|
100
100
|
end
|
101
101
|
|
102
102
|
end
|
data/spec/sheet_spec.rb
CHANGED
@@ -105,7 +105,7 @@ describe Sheet do
|
|
105
105
|
new_sheet = @book.add_sheet @sheet
|
106
106
|
expect{
|
107
107
|
new_sheet.name = 'foo'
|
108
|
-
}.to raise_error(
|
108
|
+
}.to raise_error(NameAlreadyExists, /sheet name "foo" already exists/)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
@@ -445,7 +445,7 @@ describe Sheet do
|
|
445
445
|
it "should raise an error if name not defined" do
|
446
446
|
expect {
|
447
447
|
@sheet1["foo"]
|
448
|
-
}.to raise_error(
|
448
|
+
}.to raise_error(NameNotFound, /name "foo" not in Sheet1/)
|
449
449
|
end
|
450
450
|
|
451
451
|
it "should set a range to a value" do
|
@@ -459,7 +459,7 @@ describe Sheet do
|
|
459
459
|
it "should raise an error if name cannot be evaluated" do
|
460
460
|
expect{
|
461
461
|
@sheet1["foo"] = 1
|
462
|
-
}.to raise_error(
|
462
|
+
}.to raise_error(NameNotFound, /name "foo" not in Sheet1/)
|
463
463
|
end
|
464
464
|
end
|
465
465
|
|
@@ -489,22 +489,22 @@ describe Sheet do
|
|
489
489
|
it "should raise an error if name not defined" do
|
490
490
|
expect {
|
491
491
|
@sheet1.nameval("foo")
|
492
|
-
}.to raise_error(
|
492
|
+
}.to raise_error(NameNotFound, /name "foo" not in Sheet1/)
|
493
493
|
expect {
|
494
494
|
@sheet1.nameval("named_formula")
|
495
|
-
}.to raise_error(
|
495
|
+
}.to raise_error(NameNotFound, /name "named_formula" not in Sheet1/)
|
496
496
|
end
|
497
497
|
|
498
498
|
it "should raise an error of coordinates are given instead of a defined name" do
|
499
499
|
expect {
|
500
500
|
@sheet1.nameval("A1")
|
501
|
-
}.to raise_error(
|
501
|
+
}.to raise_error(NameNotFound, /name "A1" not in Sheet1/)
|
502
502
|
end
|
503
503
|
|
504
504
|
it "should raise an error for a range with empty contents" do
|
505
505
|
expect{
|
506
506
|
@sheet1.nameval("another")
|
507
|
-
}.to raise_error(
|
507
|
+
}.to raise_error(NameNotFound, /name "another" not in Sheet1/)
|
508
508
|
end
|
509
509
|
|
510
510
|
it "should set a range to a value" do
|
@@ -518,7 +518,7 @@ describe Sheet do
|
|
518
518
|
it "should raise an error if name cannot be evaluated" do
|
519
519
|
expect{
|
520
520
|
@sheet1.set_nameval("foo", 1)
|
521
|
-
}.to raise_error(
|
521
|
+
}.to raise_error(NameNotFound, /name "foo" not in Sheet1/)
|
522
522
|
end
|
523
523
|
end
|
524
524
|
|
@@ -560,13 +560,13 @@ describe Sheet do
|
|
560
560
|
it "should raise an error if name not defined for the sheet" do
|
561
561
|
expect {
|
562
562
|
@sheet1.rangeval("foo")
|
563
|
-
}.to raise_error(
|
563
|
+
}.to raise_error(NameNotFound, /name "foo" not in Sheet1/)
|
564
564
|
expect {
|
565
565
|
@sheet1.rangeval("named_formula")
|
566
|
-
}.to raise_error(
|
566
|
+
}.to raise_error(NameNotFound, /name "named_formula" not in Sheet1/)
|
567
567
|
expect {
|
568
568
|
@sheet2.rangeval("firstcell")
|
569
|
-
}.to raise_error(
|
569
|
+
}.to raise_error(NameNotFound, /name "firstcell" not in Sheet2/)
|
570
570
|
end
|
571
571
|
|
572
572
|
it "should set a range to a value" do
|
@@ -580,7 +580,7 @@ describe Sheet do
|
|
580
580
|
it "should raise an error if name cannot be evaluated" do
|
581
581
|
expect{
|
582
582
|
@sheet1.set_nameval("foo", 1)
|
583
|
-
}.to raise_error(
|
583
|
+
}.to raise_error(NameNotFound, /name "foo" not in Sheet1/)
|
584
584
|
end
|
585
585
|
|
586
586
|
end
|
@@ -616,7 +616,7 @@ describe Sheet do
|
|
616
616
|
it "should raise an error" do
|
617
617
|
expect{
|
618
618
|
@sheet1.set_name("foo",-2,1)
|
619
|
-
}.to raise_error(
|
619
|
+
}.to raise_error(RangeNotEvaluatable, /cannot add name "foo" to cell with row -2 and column 1/)
|
620
620
|
end
|
621
621
|
end
|
622
622
|
end
|
@@ -633,10 +633,6 @@ describe Sheet do
|
|
633
633
|
}.to raise_error(VBAMethodMissingError, /unknown VBA property or method :Foo/)
|
634
634
|
end
|
635
635
|
|
636
|
-
# it "should report that worksheet is not alive" do
|
637
|
-
# @book.close
|
638
|
-
# expect{ @sheet.Nonexisting_method }.to raise_error(ExcelError, "method missing: worksheet nil")
|
639
|
-
# end
|
640
636
|
end
|
641
637
|
|
642
638
|
describe "#method_missing" do
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: robust_excel_ole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.6.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- traths
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2016-
|
18
|
+
date: 2016-09-04 00:00:00 +02:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -111,6 +112,9 @@ files:
|
|
111
112
|
- spec/data/merge_cells.xls
|
112
113
|
- spec/data/more_data/workbook.xls
|
113
114
|
- spec/data/protected_sheet.xls
|
115
|
+
- spec/data/refed_wb.xls
|
116
|
+
- spec/data/reference_workbook.xls
|
117
|
+
- spec/data/referencing_wb.xls
|
114
118
|
- spec/data/workbook.xls
|
115
119
|
- spec/data/workbook.xlsm
|
116
120
|
- spec/data/workbook.xlsx
|