robust_excel_ole 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Changelog +15 -0
- data/README.rdoc +128 -63
- data/README_detail.rdoc +130 -60
- data/examples/edit_sheets/example_access_sheets_and_cells.rb +1 -1
- data/examples/edit_sheets/example_adding_sheets.rb +2 -2
- data/examples/edit_sheets/example_copying.rb +1 -1
- data/examples/edit_sheets/example_expanding.rb +1 -1
- data/examples/edit_sheets/example_ranges.rb +1 -1
- data/examples/edit_sheets/example_saving.rb +2 -2
- data/examples/open_save_close/example_control_to_excel.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +2 -2
- data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_forget.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +3 -3
- data/examples/open_save_close/example_read_only.rb +1 -1
- data/examples/open_save_close/example_rename_cells.rb +1 -1
- data/examples/open_save_close/example_simple.rb +1 -1
- data/examples/open_save_close/example_unobtrusively.rb +3 -3
- data/lib/robust_excel_ole.rb +1 -0
- data/lib/robust_excel_ole/book.rb +249 -193
- data/lib/robust_excel_ole/bookstore.rb +1 -1
- data/lib/robust_excel_ole/cell.rb +1 -1
- data/lib/robust_excel_ole/excel.rb +125 -4
- data/lib/robust_excel_ole/general.rb +1 -92
- data/lib/robust_excel_ole/range.rb +1 -1
- data/lib/robust_excel_ole/reo_common.rb +37 -0
- data/lib/robust_excel_ole/sheet.rb +77 -24
- data/lib/robust_excel_ole/version.rb +1 -1
- data/spec/book_spec.rb +112 -82
- data/spec/book_specs/book_close_spec.rb +44 -1
- data/spec/book_specs/book_misc_spec.rb +97 -92
- data/spec/book_specs/book_open_spec.rb +40 -8
- data/spec/book_specs/book_save_spec.rb +77 -7
- data/spec/book_specs/book_sheet_spec.rb +290 -66
- data/spec/book_specs/book_unobtr_spec.rb +99 -73
- data/spec/bookstore_spec.rb +1 -1
- data/spec/cell_spec.rb +2 -2
- data/spec/data/another_workbook.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +174 -23
- data/spec/general_spec.rb +3 -18
- data/spec/range_spec.rb +3 -3
- data/spec/reo_common_spec.rb +104 -0
- data/spec/sheet_spec.rb +101 -60
- metadata +6 -4
data/spec/book_spec.rb
CHANGED
@@ -261,7 +261,7 @@ describe Book do
|
|
261
261
|
|
262
262
|
before do
|
263
263
|
@book = Book.open(@simple_file)
|
264
|
-
@sheet = @book
|
264
|
+
@sheet = @book.sheet(1)
|
265
265
|
@book.add_sheet(@sheet, :as => 'a_name')
|
266
266
|
end
|
267
267
|
|
@@ -285,7 +285,7 @@ describe Book do
|
|
285
285
|
@new_book.should == @book
|
286
286
|
end
|
287
287
|
|
288
|
-
context "with :if_unsaved => :alert" do
|
288
|
+
context "with :if_unsaved => :alert or :if_unsaved => :excel" do
|
289
289
|
before do
|
290
290
|
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft Office Excel" ' , "w"
|
291
291
|
end
|
@@ -315,6 +315,29 @@ describe Book do
|
|
315
315
|
}.to raise_error(ExcelErrorOpen, "open: user canceled or open error")
|
316
316
|
@book.should be_alive
|
317
317
|
end
|
318
|
+
|
319
|
+
it "should open the new book and close the unsaved book, if user answers 'yes'" do
|
320
|
+
# "Yes" is the default. --> language independent
|
321
|
+
@key_sender.puts "{enter}"
|
322
|
+
@new_book = Book.open(@simple_file, :if_unsaved => :excel)
|
323
|
+
@new_book.should be_alive
|
324
|
+
@new_book.filename.downcase.should == @simple_file.downcase
|
325
|
+
@book.should_not be_alive
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should not open the new book and not close the unsaved book, if user answers 'no'" do
|
329
|
+
# "No" is right to "Yes" (the default). --> language independent
|
330
|
+
# strangely, in the "no" case, the question will sometimes be repeated three times
|
331
|
+
#@book.excel.Visible = true
|
332
|
+
@key_sender.puts "{right}{enter}"
|
333
|
+
@key_sender.puts "{right}{enter}"
|
334
|
+
@key_sender.puts "{right}{enter}"
|
335
|
+
expect{
|
336
|
+
Book.open(@simple_file, :if_unsaved => :excel)
|
337
|
+
}.to raise_error(ExcelErrorOpen, "open: user canceled or open error")
|
338
|
+
@book.should be_alive
|
339
|
+
end
|
340
|
+
|
318
341
|
end
|
319
342
|
end
|
320
343
|
|
@@ -324,14 +347,14 @@ describe Book do
|
|
324
347
|
|
325
348
|
context "with and without reopen" do
|
326
349
|
|
327
|
-
before do
|
350
|
+
before do
|
328
351
|
if i == 1 then
|
329
352
|
book_before = Book.open(@simple_file)
|
330
353
|
book_before.close
|
331
354
|
end
|
332
355
|
@book = Book.open(@simple_file_other_path)
|
333
356
|
@sheet_count = @book.ole_workbook.Worksheets.Count
|
334
|
-
@sheet = @book
|
357
|
+
@sheet = @book.sheet(1)
|
335
358
|
@book.add_sheet(@sheet, :as => 'a_name')
|
336
359
|
end
|
337
360
|
|
@@ -354,7 +377,7 @@ describe Book do
|
|
354
377
|
if :if_obstructed is :close_if_saved" do
|
355
378
|
expect{
|
356
379
|
@new_book = Book.open(@simple_file, :if_obstructed => :close_if_saved)
|
357
|
-
}.to raise_error(ExcelErrorOpen, /workbook with the same name in a different path is unsaved
|
380
|
+
}.to raise_error(ExcelErrorOpen, /workbook with the same name in a different path is unsaved/)
|
358
381
|
@book.save
|
359
382
|
@new_book = Book.open(@simple_file, :if_obstructed => :close_if_saved)
|
360
383
|
@book.should_not be_alive
|
@@ -392,7 +415,7 @@ describe Book do
|
|
392
415
|
book = Book.open(@simple_file, :read_only => true)
|
393
416
|
book.ReadOnly.should be_true
|
394
417
|
book.should be_alive
|
395
|
-
sheet = book
|
418
|
+
sheet = book.sheet(1)
|
396
419
|
old_cell_value = sheet[1,1].value
|
397
420
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
398
421
|
book.Saved.should be_false
|
@@ -401,7 +424,7 @@ describe Book do
|
|
401
424
|
new_book.should be_alive
|
402
425
|
book.should be_alive
|
403
426
|
new_book.should == book
|
404
|
-
new_sheet = new_book
|
427
|
+
new_sheet = new_book.sheet(1)
|
405
428
|
new_cell_value = new_sheet[1,1].value
|
406
429
|
new_cell_value.should == old_cell_value
|
407
430
|
end
|
@@ -467,7 +490,7 @@ describe Book do
|
|
467
490
|
def unobtrusively_ok? # :nodoc: #
|
468
491
|
Book.unobtrusively(@simple_file) do |book|
|
469
492
|
book.should be_a Book
|
470
|
-
sheet = book
|
493
|
+
sheet = book.sheet(1)
|
471
494
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
472
495
|
book.should be_alive
|
473
496
|
book.Saved.should be_false
|
@@ -548,17 +571,17 @@ describe Book do
|
|
548
571
|
it "should let a saved book saved" do
|
549
572
|
@book.Saved.should be_true
|
550
573
|
@book.should be_alive
|
551
|
-
sheet = @book
|
574
|
+
sheet = @book.sheet(1)
|
552
575
|
old_cell_value = sheet[1,1].value
|
553
576
|
unobtrusively_ok?
|
554
577
|
@book.Saved.should be_true
|
555
578
|
@book.should be_alive
|
556
|
-
sheet = @book
|
579
|
+
sheet = @book.sheet(1)
|
557
580
|
sheet[1,1].value.should_not == old_cell_value
|
558
581
|
end
|
559
582
|
|
560
583
|
it "should let the unsaved book unsaved" do
|
561
|
-
sheet = @book
|
584
|
+
sheet = @book.sheet(1)
|
562
585
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
563
586
|
old_cell_value = sheet[1,1].value
|
564
587
|
@book.Saved.should be_false
|
@@ -567,7 +590,7 @@ describe Book do
|
|
567
590
|
@book.Saved.should be_false
|
568
591
|
@book.close(:if_unsaved => :forget)
|
569
592
|
@book2 = Book.open(@simple_file)
|
570
|
-
sheet2 = @book2
|
593
|
+
sheet2 = @book2.sheet(1)
|
571
594
|
sheet2[1,1].value.should_not == old_cell_value
|
572
595
|
end
|
573
596
|
end
|
@@ -583,21 +606,21 @@ describe Book do
|
|
583
606
|
end
|
584
607
|
|
585
608
|
it "should let the closed book closed by default" do
|
586
|
-
sheet = @book
|
609
|
+
sheet = @book.sheet(1)
|
587
610
|
old_cell_value = sheet[1,1].value
|
588
611
|
@book.close
|
589
612
|
@book.should_not be_alive
|
590
613
|
unobtrusively_ok?
|
591
614
|
@book.should_not be_alive
|
592
615
|
@book = Book.open(@simple_file)
|
593
|
-
sheet = @book
|
616
|
+
sheet = @book.sheet(1)
|
594
617
|
sheet[1,1].Value.should_not == old_cell_value
|
595
618
|
end
|
596
619
|
|
597
620
|
# The bold reanimation of the @book
|
598
621
|
it "should use the excel of the book and keep open the book" do
|
599
622
|
excel = Excel.new(:reuse => false)
|
600
|
-
sheet = @book
|
623
|
+
sheet = @book.sheet(1)
|
601
624
|
old_cell_value = sheet[1,1].value
|
602
625
|
@book.close
|
603
626
|
@book.should_not be_alive
|
@@ -605,7 +628,7 @@ describe Book do
|
|
605
628
|
book.should be_a Book
|
606
629
|
book.excel.should == @book.excel
|
607
630
|
book.excel.should_not == excel
|
608
|
-
sheet = book
|
631
|
+
sheet = book.sheet(1)
|
609
632
|
cell = sheet[1,1]
|
610
633
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
611
634
|
book.Saved.should be_false
|
@@ -613,14 +636,14 @@ describe Book do
|
|
613
636
|
@book.should be_alive
|
614
637
|
@book.close
|
615
638
|
new_book = Book.open(@simple_file)
|
616
|
-
sheet = new_book
|
639
|
+
sheet = new_book.sheet(1)
|
617
640
|
sheet[1,1].value.should_not == old_cell_value
|
618
641
|
end
|
619
642
|
|
620
643
|
# book shall be reanimated even with :hidden
|
621
644
|
it "should use the excel of the book and keep open the book" do
|
622
645
|
excel = Excel.new(:reuse => false)
|
623
|
-
sheet = @book
|
646
|
+
sheet = @book.sheet(1)
|
624
647
|
old_cell_value = sheet[1,1].value
|
625
648
|
@book.close
|
626
649
|
@book.should_not be_alive
|
@@ -629,14 +652,14 @@ describe Book do
|
|
629
652
|
book.should be_alive
|
630
653
|
book.excel.should_not == @book.excel
|
631
654
|
book.excel.should_not == excel
|
632
|
-
sheet = book
|
655
|
+
sheet = book.sheet(1)
|
633
656
|
cell = sheet[1,1]
|
634
657
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
635
658
|
book.Saved.should be_false
|
636
659
|
end
|
637
660
|
@book.should_not be_alive
|
638
661
|
new_book = Book.open(@simple_file)
|
639
|
-
sheet = new_book
|
662
|
+
sheet = new_book.sheet(1)
|
640
663
|
sheet[1,1].value.should_not == old_cell_value
|
641
664
|
end
|
642
665
|
end
|
@@ -679,13 +702,13 @@ describe Book do
|
|
679
702
|
book2 = Book.open(@simple_file, :force_excel => :new, :read_only => true)
|
680
703
|
@book.ReadOnly.should be_true
|
681
704
|
book2.Readonly.should be_true
|
682
|
-
sheet = @book
|
705
|
+
sheet = @book.sheet(1)
|
683
706
|
cell_value = sheet[1,1].value
|
684
707
|
Book.unobtrusively(@simple_file, :hidden) do |book|
|
685
708
|
book.should be_a Book
|
686
709
|
book.excel.should_not == book2.excel
|
687
710
|
book.excel.should_not == @book.excel
|
688
|
-
sheet = book
|
711
|
+
sheet = book.sheet(1)
|
689
712
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
690
713
|
book.should be_alive
|
691
714
|
book.Saved.should be_false
|
@@ -695,7 +718,7 @@ describe Book do
|
|
695
718
|
@book.close
|
696
719
|
book2.close
|
697
720
|
book3 = Book.open(@simple_file)
|
698
|
-
new_sheet = book3
|
721
|
+
new_sheet = book3.sheet(1)
|
699
722
|
new_sheet[1,1].value.should_not == cell_value
|
700
723
|
book3.close
|
701
724
|
end
|
@@ -749,7 +772,7 @@ describe Book do
|
|
749
772
|
@book2 = Book.open(@simple_file, :force_excel => :new)
|
750
773
|
@book1.Readonly.should == false
|
751
774
|
@book2.Readonly.should == true
|
752
|
-
old_sheet = @book1
|
775
|
+
old_sheet = @book1.sheet(1)
|
753
776
|
@old_cell_value = old_sheet[1,1].value
|
754
777
|
@book1.close
|
755
778
|
@book2.close
|
@@ -762,13 +785,13 @@ describe Book do
|
|
762
785
|
book.excel.should == @book2.excel
|
763
786
|
book.excel.should_not == @book1.excel
|
764
787
|
book.ReadOnly.should == false
|
765
|
-
sheet = book
|
788
|
+
sheet = book.sheet(1)
|
766
789
|
cell = sheet[1,1]
|
767
790
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
768
791
|
book.Saved.should be_false
|
769
792
|
end
|
770
793
|
new_book = Book.open(@simple_file)
|
771
|
-
sheet = new_book
|
794
|
+
sheet = new_book.sheet(1)
|
772
795
|
sheet[1,1].value.should_not == @old_cell_value
|
773
796
|
end
|
774
797
|
|
@@ -777,13 +800,13 @@ describe Book do
|
|
777
800
|
book.excel.should_not == @book2.excel
|
778
801
|
book.excel.should_not == @book1.excel
|
779
802
|
book.ReadOnly.should == false
|
780
|
-
sheet = book
|
803
|
+
sheet = book.sheet(1)
|
781
804
|
cell = sheet[1,1]
|
782
805
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
783
806
|
book.Saved.should be_false
|
784
807
|
end
|
785
808
|
new_book = Book.open(@simple_file)
|
786
|
-
sheet = new_book
|
809
|
+
sheet = new_book.sheet(1)
|
787
810
|
sheet[1,1].Value.should_not == @old_cell_value
|
788
811
|
end
|
789
812
|
end
|
@@ -821,7 +844,7 @@ describe Book do
|
|
821
844
|
|
822
845
|
before do
|
823
846
|
@book = Book.open(@simple_file)
|
824
|
-
sheet = @book
|
847
|
+
sheet = @book.sheet(1)
|
825
848
|
@old_cell_value = sheet[1,1].value
|
826
849
|
@book.close
|
827
850
|
end
|
@@ -831,21 +854,21 @@ describe Book do
|
|
831
854
|
book.should be_a Book
|
832
855
|
book.should be_alive
|
833
856
|
book.Saved.should be_true
|
834
|
-
sheet = book
|
857
|
+
sheet = book.sheet(1)
|
835
858
|
cell = sheet[1,1]
|
836
859
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
837
860
|
book.Saved.should be_false
|
838
861
|
book.excel.should == @book.excel
|
839
862
|
end
|
840
863
|
new_book = Book.open(@simple_file, :visible => true)
|
841
|
-
sheet = new_book
|
864
|
+
sheet = new_book.sheet(1)
|
842
865
|
sheet[1,1].Value.should == @old_cell_value
|
843
866
|
end
|
844
867
|
|
845
868
|
it "should not change the value and use the hidden Excel instance" do
|
846
869
|
new_excel = Excel.new(:reuse => false)
|
847
870
|
Book.for_reading(@simple_file, :hidden) do |book|
|
848
|
-
sheet = book
|
871
|
+
sheet = book.sheet(1)
|
849
872
|
cell = sheet[1,1]
|
850
873
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
851
874
|
book.excel.should_not == @book.excel
|
@@ -854,19 +877,19 @@ describe Book do
|
|
854
877
|
book.excel.displayalerts.should be_false
|
855
878
|
end
|
856
879
|
new_book = Book.open(@simple_file, :visible => true)
|
857
|
-
sheet = new_book
|
880
|
+
sheet = new_book.sheet(1)
|
858
881
|
sheet[1,1].Value.should == @old_cell_value
|
859
882
|
end
|
860
883
|
|
861
884
|
it "should change the value" do
|
862
885
|
Book.for_modifying(@simple_file) do |book|
|
863
|
-
sheet = book
|
886
|
+
sheet = book.sheet(1)
|
864
887
|
cell = sheet[1,1]
|
865
888
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
866
889
|
book.excel.should == @book.excel
|
867
890
|
end
|
868
891
|
new_book = Book.open(@simple_file, :visible => true)
|
869
|
-
sheet = new_book
|
892
|
+
sheet = new_book.sheet(1)
|
870
893
|
sheet[1,1].Value.should_not == @old_cell_value
|
871
894
|
end
|
872
895
|
end
|
@@ -889,49 +912,56 @@ describe Book do
|
|
889
912
|
end
|
890
913
|
end
|
891
914
|
|
892
|
-
describe "
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
@book1 = Book.open(@another_simple_file)
|
898
|
-
end
|
915
|
+
describe "nameval, set_nameval, [], []=" do
|
916
|
+
|
917
|
+
before do
|
918
|
+
@book1 = Book.open(@another_simple_file)
|
919
|
+
end
|
899
920
|
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
@book1["new"].should == "foo"
|
912
|
-
@book1["one"].should == 1
|
913
|
-
@book1["firstrow"].should == [[1,2]]
|
914
|
-
@book1["four"].should == [[1,2],[3,4]]
|
915
|
-
@book1["firstcell"].should == "foo"
|
916
|
-
end
|
921
|
+
after do
|
922
|
+
@book1.close(:if_unsaved => :forget)
|
923
|
+
end
|
924
|
+
|
925
|
+
it "should return value of a range" do
|
926
|
+
@book1.nameval("new").should == "foo"
|
927
|
+
@book1.nameval("one").should == 1
|
928
|
+
@book1.nameval("firstrow").should == [[1,2]]
|
929
|
+
@book1.nameval("four").should == [[1,2],[3,4]]
|
930
|
+
@book1.nameval("firstrow").should_not == "12"
|
931
|
+
@book1.nameval("firstcell").should == "foo"
|
917
932
|
end
|
918
933
|
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
934
|
+
it "should return value of a range via []" do
|
935
|
+
@book1["new"].should == "foo"
|
936
|
+
@book1["one"].should == 1
|
937
|
+
@book1["firstrow"] == [[1,2]]
|
938
|
+
@book1["four"].should == [[1,2],[3,4]]
|
939
|
+
@book1["firstrow"].should_not == "12"
|
940
|
+
@book1["firstcell"].should == "foo"
|
941
|
+
end
|
924
942
|
|
925
|
-
|
926
|
-
|
927
|
-
|
943
|
+
it "should set value of a range" do
|
944
|
+
@book1.set_nameval("new", "bar")
|
945
|
+
@book1.nameval("new").should == "bar"
|
946
|
+
end
|
928
947
|
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
948
|
+
it "should set value of a range via []=" do
|
949
|
+
@book1["new"] = "bar"
|
950
|
+
@book1.nameval("new").should == "bar"
|
951
|
+
end
|
952
|
+
|
953
|
+
it "should evaluate a formula" do
|
954
|
+
@book1.nameval("named_formula").should == 4
|
934
955
|
end
|
956
|
+
|
957
|
+
it "should evaluate a formula via []" do
|
958
|
+
@book1["named_formula"].should == 4
|
959
|
+
end
|
960
|
+
|
961
|
+
it "should return default value if name not defined" do
|
962
|
+
@book1.nameval("foo", :default => 2).should == 2
|
963
|
+
end
|
964
|
+
|
935
965
|
end
|
936
966
|
|
937
967
|
describe "close" do
|
@@ -958,7 +988,7 @@ describe Book do
|
|
958
988
|
@book = Book.open(@simple_file)
|
959
989
|
@sheet_count = @book.ole_workbook.Worksheets.Count
|
960
990
|
@book.add_sheet(@sheet, :as => 'a_name')
|
961
|
-
@sheet = @book
|
991
|
+
@sheet = @book.sheet(1)
|
962
992
|
end
|
963
993
|
|
964
994
|
after do
|
@@ -1091,7 +1121,7 @@ describe Book do
|
|
1091
1121
|
end
|
1092
1122
|
|
1093
1123
|
it "should activate a book" do
|
1094
|
-
sheet = @book
|
1124
|
+
sheet = @book.sheet(2)
|
1095
1125
|
sheet.Activate
|
1096
1126
|
sheet[2,3].Activate
|
1097
1127
|
sheet2 = @book2[2]
|
@@ -1115,7 +1145,7 @@ describe Book do
|
|
1115
1145
|
describe "#add_sheet" do
|
1116
1146
|
before do
|
1117
1147
|
@book = Book.open(@simple_file)
|
1118
|
-
@sheet = @book
|
1148
|
+
@sheet = @book.sheet(1)
|
1119
1149
|
end
|
1120
1150
|
|
1121
1151
|
after do
|
@@ -1139,9 +1169,9 @@ describe Book do
|
|
1139
1169
|
|
1140
1170
|
context "with first argument" do
|
1141
1171
|
|
1142
|
-
context "with second argument is {:before => @book
|
1172
|
+
context "with second argument is {:before => @book.sheet(3), :after => @sheet}" do
|
1143
1173
|
it "should arguments in the first is given priority" do
|
1144
|
-
@book.add_sheet(@sheet, :before => @book
|
1174
|
+
@book.add_sheet(@sheet, :before => @book.sheet(3), :after => @sheet).name.should eq @book.sheet(3).name
|
1145
1175
|
end
|
1146
1176
|
end
|
1147
1177
|
end
|
@@ -1155,13 +1185,13 @@ describe Book do
|
|
1155
1185
|
|
1156
1186
|
context "second argument is {:before => @sheet}" do
|
1157
1187
|
it "should add the first sheet" do
|
1158
|
-
@book.add_sheet(:before => @sheet).name.should eq @book
|
1188
|
+
@book.add_sheet(:before => @sheet).name.should eq @book.sheet(1).name
|
1159
1189
|
end
|
1160
1190
|
end
|
1161
1191
|
|
1162
1192
|
context "second argument is {:after => @sheet}" do
|
1163
1193
|
it "should add the second sheet" do
|
1164
|
-
@book.add_sheet(:after => @sheet).name.should eq @book
|
1194
|
+
@book.add_sheet(:after => @sheet).name.should eq @book.sheet(2).name
|
1165
1195
|
end
|
1166
1196
|
end
|
1167
1197
|
end
|
@@ -1188,11 +1218,11 @@ describe Book do
|
|
1188
1218
|
context "standard" do
|
1189
1219
|
|
1190
1220
|
it 'with sheet name' do
|
1191
|
-
@book
|
1221
|
+
@book.sheet('Sheet1').should be_kind_of Sheet
|
1192
1222
|
end
|
1193
1223
|
|
1194
1224
|
it 'with integer' do
|
1195
|
-
@book
|
1225
|
+
@book.sheet(1).should be_kind_of Sheet
|
1196
1226
|
end
|
1197
1227
|
|
1198
1228
|
it 'with block' do
|
@@ -1205,7 +1235,7 @@ describe Book do
|
|
1205
1235
|
context 'open with block' do
|
1206
1236
|
it {
|
1207
1237
|
Book.open(@simple_file) do |book|
|
1208
|
-
book
|
1238
|
+
book.sheet('Sheet1').should be_a Sheet
|
1209
1239
|
end
|
1210
1240
|
}
|
1211
1241
|
end
|