robust_excel_ole 0.2.1 → 0.2.2.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.
Files changed (35) hide show
  1. data/README.rdoc +130 -77
  2. data/examples/edit_sheets/example_print_cells.rb +43 -0
  3. data/examples/open_save_close/example_control_to_excel.rb +10 -6
  4. data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +9 -6
  5. data/examples/open_save_close/example_if_obstructed_forget.rb +9 -6
  6. data/examples/open_save_close/example_if_obstructed_save.rb +7 -5
  7. data/examples/open_save_close/example_if_unsaved_accept.rb +6 -3
  8. data/examples/open_save_close/example_if_unsaved_forget.rb +7 -4
  9. data/examples/open_save_close/example_if_unsaved_forget_more.rb +38 -0
  10. data/examples/open_save_close/example_read_only.rb +8 -6
  11. data/examples/open_save_close/example_reuse.rb +7 -4
  12. data/examples/open_save_close/example_simple.rb +9 -5
  13. data/examples/save_sheets/example_save_sheets.rb +22 -14
  14. data/lib/robust_excel_ole.rb +1 -1
  15. data/lib/robust_excel_ole/book.rb +42 -55
  16. data/lib/robust_excel_ole/cell.rb +1 -1
  17. data/lib/robust_excel_ole/{excel_app.rb → excel.rb} +97 -89
  18. data/lib/robust_excel_ole/range.rb +1 -1
  19. data/lib/robust_excel_ole/robustexcelole.sublime-workspace +347 -347
  20. data/lib/robust_excel_ole/sheet.rb +1 -1
  21. data/lib/robust_excel_ole/version.rb +1 -1
  22. data/lib/spec_helper.rb +3 -3
  23. data/spec/book_spec.rb +53 -67
  24. data/spec/cell_spec.rb +10 -2
  25. data/spec/data/merge_cells.xls +0 -0
  26. data/spec/data/simple.xls +0 -0
  27. data/spec/{excel_app_spec.rb → excel_spec.rb} +52 -36
  28. data/spec/helpers/create_temporary_dir.rb +11 -0
  29. data/spec/helpers/key_sender.rb +1 -1
  30. data/spec/range_spec.rb +9 -1
  31. data/spec/sheet_spec.rb +11 -3
  32. data/spec/spec_helper.rb +3 -3
  33. metadata +9 -7
  34. data/examples/print_cells/example_print_cells.rb +0 -43
  35. data/robust_excel_ole_example.rb +0 -29
@@ -81,7 +81,7 @@ module RobustExcelOle
81
81
  RobustExcelOle::Range.new(@sheet.Range(@sheet.Cells(range.min + 1, col + 1), @sheet.Cells(range.max + 1, col + 1)))
82
82
  end
83
83
 
84
- def method_missing(id, *args)
84
+ def method_missing(id, *args) # :nodoc: #
85
85
  @sheet.send(id, *args)
86
86
  end
87
87
 
@@ -1,3 +1,3 @@
1
1
  module RobustExcelOle
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2.1"
3
3
  end
data/lib/spec_helper.rb CHANGED
@@ -5,19 +5,19 @@ require "fileutils"
5
5
  require File.join(File.dirname(__FILE__), '../lib/robust_excel_ole')
6
6
 
7
7
  module RobustExcelOle::SpecHelpers
8
- def create_tmpdir
8
+ def create_tmpdir # :nodoc: #
9
9
  tmpdir = Dir.mktmpdir
10
10
  FileUtils.cp_r(File.join(File.dirname(__FILE__), 'data'), tmpdir)
11
11
  tmpdir + '/data'
12
12
  end
13
13
 
14
- def rm_tmp(tmpdir)
14
+ def rm_tmp(tmpdir) # :nodoc: #
15
15
  FileUtils.remove_entry_secure(File.dirname(tmpdir))
16
16
  end
17
17
 
18
18
  # This method is almost copy of wycats's implementation.
19
19
  # http://pochi.hatenablog.jp/entries/2010/03/24
20
- def capture(stream)
20
+ def capture(stream) # :nodoc: #
21
21
  begin
22
22
  stream = stream.to_s
23
23
  eval "$#{stream} = StringIO.new"
data/spec/book_spec.rb CHANGED
@@ -9,10 +9,10 @@ $VERBOSE = nil
9
9
  describe RobustExcelOle::Book do
10
10
 
11
11
  before(:all) do
12
- excel_app = RobustExcelOle::ExcelApp.new(:reuse => true)
13
- open_books = excel_app == nil ? 0 : excel_app.Workbooks.Count
12
+ excel = RobustExcelOle::Excel.new(:reuse => true)
13
+ open_books = excel == nil ? 0 : excel.Workbooks.Count
14
14
  puts "*** open books *** : #{open_books}" if open_books > 0
15
- RobustExcelOle::ExcelApp.close_all
15
+ RobustExcelOle::Excel.close_all
16
16
  end
17
17
 
18
18
 
@@ -23,7 +23,7 @@ describe RobustExcelOle::Book do
23
23
  end
24
24
 
25
25
  after do
26
- #RobustExcelOle::ExcelApp.close_all
26
+ #RobustExcelOle::Excel.close_all
27
27
  rm_tmp(@dir)
28
28
  end
29
29
 
@@ -65,7 +65,7 @@ describe RobustExcelOle::Book do
65
65
  end
66
66
  end
67
67
 
68
- context "with attr_reader excel_app" do
68
+ context "with attr_reader excel" do
69
69
  before do
70
70
  @new_book = RobustExcelOle::Book.open(@simple_file)
71
71
  end
@@ -73,31 +73,32 @@ describe RobustExcelOle::Book do
73
73
  @new_book.close
74
74
  end
75
75
  it "should provide the excel application of the book" do
76
- excel_app = @new_book.excel_app
77
- excel_app.class.should == RobustExcelOle::ExcelApp
78
- excel_app.should be_a RobustExcelOle::ExcelApp
76
+ excel = @new_book.excel
77
+ excel.class.should == RobustExcelOle::Excel
78
+ excel.should be_a RobustExcelOle::Excel
79
79
  end
80
80
  end
81
81
 
82
- context "with :excel_app" do
82
+ context "with :excel" do
83
83
  it "should reuse the given excel application of the book" do
84
- book1 = RobustExcelOle::Book.open(@simple_file, :reuse => false)
85
- excel_app1 = book1.excel_app
84
+ RobustExcelOle::Excel.close_all
85
+ book1 = RobustExcelOle::Book.open(@simple_file)
86
+ excel1 = book1.excel
86
87
  book2 = RobustExcelOle::Book.open(@simple_file, :reuse => false)
87
- excel_app2 = book2.excel_app
88
- excel_app2.should_not == excel_app1
88
+ excel2 = book2.excel
89
+ excel2.should_not == excel1
89
90
  book3 = RobustExcelOle::Book.open(@simple_file)
90
- excel_app3 = book3.excel_app
91
- book4 = RobustExcelOle::Book.open(@simple_file, :excel_app => excel_app2)
92
- excel_app4 = book4.excel_app
93
- excel_app3.should == excel_app1
94
- excel_app4.should == excel_app2
95
- excel_app4.class.should == RobustExcelOle::ExcelApp
96
- excel_app4.should be_a RobustExcelOle::ExcelApp
97
- book1.close
98
- book2.close
99
- book3.close
91
+ excel3 = book3.excel
92
+ book4 = RobustExcelOle::Book.open(@simple_file, :excel => excel2)
93
+ excel4 = book4.excel
94
+ excel3.should == excel1
95
+ excel4.should == excel2
96
+ excel4.class.should == RobustExcelOle::Excel
97
+ excel4.should be_a RobustExcelOle::Excel
100
98
  book4.close
99
+ book3.close
100
+ book2.close
101
+ book1.close
101
102
  end
102
103
  end
103
104
 
@@ -177,8 +178,8 @@ describe RobustExcelOle::Book do
177
178
  @different_book.should be_a RobustExcelOle::Book
178
179
  end
179
180
  it "should belong to the same Excel application" do
180
- @new_book.excel_app.should == @book.excel_app
181
- @different_book.excel_app.should == @book.excel_app
181
+ @new_book.excel.should == @book.excel
182
+ @different_book.excel.should == @book.excel
182
183
  end
183
184
  end
184
185
  end
@@ -219,7 +220,7 @@ describe RobustExcelOle::Book do
219
220
  @new_book.filename.downcase.should == @simple_file.downcase
220
221
  end
221
222
 
222
- context "with :if_unsaved => :excel" do
223
+ context "with :if_unsaved => :alert" do
223
224
  before do
224
225
  @key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft Office Excel" ' , "w"
225
226
  end
@@ -231,7 +232,7 @@ describe RobustExcelOle::Book do
231
232
  it "should open the new book and close the unsaved book, if user answers 'yes'" do
232
233
  # "Yes" is the default. --> language independent
233
234
  @key_sender.puts "{enter}"
234
- @new_book = RobustExcelOle::Book.open(@simple_file, :if_unsaved => :excel)
235
+ @new_book = RobustExcelOle::Book.open(@simple_file, :if_unsaved => :alert)
235
236
  @book.should_not be_alive
236
237
  @new_book.should be_alive
237
238
  @new_book.filename.downcase.should == @simple_file.downcase
@@ -240,12 +241,12 @@ describe RobustExcelOle::Book do
240
241
  it "should not open the new book and not close the unsaved book, if user answers 'no'" do
241
242
  # "No" is right to "Yes" (the default). --> language independent
242
243
  # strangely, in the "no" case, the question will sometimes be repeated three times
243
- #@book.excel_app.Visible = true
244
+ #@book.excel.Visible = true
244
245
  @key_sender.puts "{right}{enter}"
245
246
  @key_sender.puts "{right}{enter}"
246
247
  @key_sender.puts "{right}{enter}"
247
248
  expect{
248
- RobustExcelOle::Book.open(@simple_file, :if_unsaved => :excel)
249
+ RobustExcelOle::Book.open(@simple_file, :if_unsaved => :alert)
249
250
  }.to raise_error(ExcelUserCanceled, "open: canceled by user")
250
251
  @book.should be_alive
251
252
  end
@@ -256,7 +257,7 @@ describe RobustExcelOle::Book do
256
257
  @book.should be_alive
257
258
  @new_book.should be_alive
258
259
  @new_book.filename.should == @book.filename
259
- @new_book.excel_app.should_not == @book.excel_app
260
+ @new_book.excel.should_not == @book.excel
260
261
  @new_book.close
261
262
  end
262
263
 
@@ -333,7 +334,7 @@ describe RobustExcelOle::Book do
333
334
  @book.should be_alive
334
335
  @new_book.should be_alive
335
336
  @new_book.filename.should_not == @book.filename
336
- @new_book.excel_app.should_not == @book.excel_app
337
+ @new_book.excel.should_not == @book.excel
337
338
  end
338
339
 
339
340
  it "should raise an error, if :if_obstructed is default" do
@@ -405,10 +406,10 @@ describe RobustExcelOle::Book do
405
406
 
406
407
  it "should close the book and leave its file untouched with option :forget" do
407
408
  ole_workbook = @book.workbook
408
- excel_app = @book.excel_app
409
+ excel = @book.excel
409
410
  expect {
410
411
  @book.close(:if_unsaved => :forget)
411
- }.to change {excel_app.Workbooks.Count }.by(-1)
412
+ }.to change {excel.Workbooks.Count }.by(-1)
412
413
  @book.workbook.should == nil
413
414
  @book.should_not be_alive
414
415
  expect{
@@ -423,10 +424,10 @@ describe RobustExcelOle::Book do
423
424
 
424
425
  it "should save the book before close with option :save" do
425
426
  ole_workbook = @book.workbook
426
- excel_app = @book.excel_app
427
+ excel = @book.excel
427
428
  expect {
428
429
  @book.close(:if_unsaved => :save)
429
- }.to change {excel_app.Workbooks.Count }.by(-1)
430
+ }.to change {excel.Workbooks.Count }.by(-1)
430
431
  @book.workbook.should == nil
431
432
  @book.should_not be_alive
432
433
  expect{
@@ -439,7 +440,7 @@ describe RobustExcelOle::Book do
439
440
  end
440
441
  end
441
442
 
442
- context "with :if_unsaved => :excel" do
443
+ context "with :if_unsaved => :alert" do
443
444
  before do
444
445
  @key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft Excel" ' , "w"
445
446
  end
@@ -454,19 +455,19 @@ describe RobustExcelOle::Book do
454
455
  # "Yes" is the default. "No" is right of "Yes", "Cancel" is right of "No" --> language independent
455
456
  @key_sender.puts "{right}" * position + "{enter}"
456
457
  ole_workbook = @book.workbook
457
- excel_app = @book.excel_app
458
- displayalert_value = @book.excel_app.DisplayAlerts
458
+ excel = @book.excel
459
+ displayalert_value = @book.excel.DisplayAlerts
459
460
  if answer == :cancel then
460
461
  expect {
461
- @book.close(:if_unsaved => :excel)
462
+ @book.close(:if_unsaved => :alert)
462
463
  }.to raise_error(ExcelUserCanceled, "close: canceled by user")
463
464
  @book.workbook.Saved.should be_false
464
465
  @book.workbook.should_not == nil
465
466
  @book.should be_alive
466
467
  else
467
468
  expect {
468
- @book.close(:if_unsaved => :excel)
469
- }.to change {@book.excel_app.Workbooks.Count }.by(-1)
469
+ @book.close(:if_unsaved => :alert)
470
+ }.to change {@book.excel.Workbooks.Count }.by(-1)
470
471
  @book.workbook.should == nil
471
472
  @book.should_not be_alive
472
473
  expect{ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
@@ -474,7 +475,7 @@ describe RobustExcelOle::Book do
474
475
  new_book = RobustExcelOle::Book.open(@simple_file, :if_unsaved => :forget)
475
476
  begin
476
477
  new_book.workbook.Worksheets.Count.should == @sheet_count + (answer==:yes ? 1 : 0)
477
- new_book.excel_app.DisplayAlerts.should == displayalert_value
478
+ new_book.excel.DisplayAlerts.should == displayalert_value
478
479
  ensure
479
480
  new_book.close
480
481
  end
@@ -586,7 +587,6 @@ describe RobustExcelOle::Book do
586
587
  it "should raise an error if the book is open" do
587
588
  File.delete @simple_save_file rescue nil
588
589
  FileUtils.copy @simple_file, @simple_save_file
589
- # fails with :reuse => false
590
590
  book_save = RobustExcelOle::Book.open(@simple_save_file, :reuse => false)
591
591
  expect{
592
592
  @book.save_as(@simple_save_file, :if_exists => :overwrite)
@@ -621,7 +621,7 @@ describe RobustExcelOle::Book do
621
621
  (File.size?(@simple_save_file) == booklength).should be_true
622
622
  end
623
623
 
624
- context "with :if_exists => :excel" do
624
+ context "with :if_exists => :alert" do
625
625
  before do
626
626
  File.delete @simple_save_file rescue nil
627
627
  File.open(@simple_save_file,"w") do | file |
@@ -638,12 +638,12 @@ describe RobustExcelOle::Book do
638
638
  it "should save if user answers 'yes'" do
639
639
  # "Yes" is to the left of "No", which is the default. --> language independent
640
640
  @key_sender.puts "{left}{enter}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
641
- @book.save_as(@simple_save_file, :if_exists => :excel)
641
+ @book.save_as(@simple_save_file, :if_exists => :alert)
642
642
  File.exist?(@simple_save_file).should be_true
643
643
  File.size?(@simple_save_file).should > @garbage_length
644
644
  new_book = RobustExcelOle::Book.open(@simple_save_file)
645
645
  new_book.should be_a RobustExcelOle::Book
646
- @book.excel_app.DisplayAlerts.should == displayalert_value
646
+ @book.excel.DisplayAlerts.should == displayalert_value
647
647
  new_book.close
648
648
  end
649
649
 
@@ -655,11 +655,11 @@ describe RobustExcelOle::Book do
655
655
  @key_sender.puts "{enter}"
656
656
  #@key_sender.puts "%{n}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
657
657
  expect{
658
- @book.save_as(@simple_save_file, :if_exists => :excel)
658
+ @book.save_as(@simple_save_file, :if_exists => :alert)
659
659
  }.to raise_error(ExcelErrorSave, "not saved or canceled by user")
660
660
  File.exist?(@simple_save_file).should be_true
661
661
  File.size?(@simple_save_file).should == @garbage_length
662
- @book.excel_app.DisplayAlerts.should == displayalert_value
662
+ @book.excel.DisplayAlerts.should == displayalert_value
663
663
  end
664
664
 
665
665
  it "should not save if user answers 'cancel'" do
@@ -670,22 +670,22 @@ describe RobustExcelOle::Book do
670
670
  @key_sender.puts "{right}{enter}"
671
671
  #@key_sender.puts "%{n}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
672
672
  expect{
673
- @book.save_as(@simple_save_file, :if_exists => :excel)
673
+ @book.save_as(@simple_save_file, :if_exists => :alert)
674
674
  }.to raise_error(ExcelErrorSave, "not saved or canceled by user")
675
675
  File.exist?(@simple_save_file).should be_true
676
676
  File.size?(@simple_save_file).should == @garbage_length
677
- @book.excel_app.DisplayAlerts.should == displayalert_value
677
+ @book.excel.DisplayAlerts.should == displayalert_value
678
678
  end
679
679
 
680
680
  it "should report save errors and leave DisplayAlerts unchanged" do
681
681
  #@key_sender.puts "{left}{enter}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
682
682
  @book.workbook.Close
683
683
  expect{
684
- @book.save_as(@simple_save_file, :if_exists => :excel)
684
+ @book.save_as(@simple_save_file, :if_exists => :alert)
685
685
  }.to raise_error(ExcelErrorSaveUnknown)
686
686
  File.exist?(@simple_save_file).should be_true
687
687
  File.size?(@simple_save_file).should == @garbage_length
688
- @book.excel_app.DisplayAlerts.should == displayalert_value
688
+ @book.excel.DisplayAlerts.should == displayalert_value
689
689
  end
690
690
 
691
691
  end
@@ -716,21 +716,7 @@ describe RobustExcelOle::Book do
716
716
  end
717
717
  end
718
718
 
719
- describe "== , alive?, filename, absolute_path" do
720
-
721
- context "with absolute_path" do
722
- before do
723
- @book = RobustExcelOle::Book.open(@simple_file)
724
- end
725
-
726
- after do
727
- @book.close
728
- end
729
-
730
- it "should return right absoute path name" do
731
- @book.absolute_path(@simple_file).gsub("\\","/").should == @book.filename
732
- end
733
- end
719
+ describe "== , alive?, filename" do
734
720
 
735
721
  context "with alive?" do
736
722
 
data/spec/cell_spec.rb CHANGED
@@ -2,6 +2,14 @@
2
2
  require File.join(File.dirname(__FILE__), './spec_helper')
3
3
 
4
4
  describe RobustExcelOle::Cell do
5
+
6
+ before(:all) do
7
+ excel = RobustExcelOle::Excel.new(:reuse => true)
8
+ open_books = excel == nil ? 0 : excel.Workbooks.Count
9
+ puts "*** open books *** : #{open_books}" if open_books > 0
10
+ RobustExcelOle::Excel.close_all
11
+ end
12
+
5
13
  before do
6
14
  @dir = create_tmpdir
7
15
  end
@@ -12,7 +20,7 @@ describe RobustExcelOle::Cell do
12
20
 
13
21
  context "open simple.xls" do
14
22
  before do
15
- @book = RobustExcelOle::Book.open(@dir + '/simple.xls')
23
+ @book = RobustExcelOle::Book.open(@dir + '/simple.xls', :read_only => true)
16
24
  @sheet = @book[1]
17
25
  @cell = @sheet[0, 0]
18
26
  end
@@ -44,7 +52,7 @@ describe RobustExcelOle::Cell do
44
52
 
45
53
  context "open merge_cells.xls" do
46
54
  before do
47
- @book = RobustExcelOle::Book.open(@dir + '/merge_cells.xls')
55
+ @book = RobustExcelOle::Book.open(@dir + '/merge_cells.xls', :read_only => true)
48
56
  @sheet = @book[0]
49
57
  end
50
58
 
Binary file
data/spec/data/simple.xls CHANGED
Binary file
@@ -6,14 +6,14 @@ $VERBOSE = nil
6
6
 
7
7
  module RobustExcelOle
8
8
 
9
- describe ExcelApp do
9
+ describe Excel do
10
10
 
11
11
  context "app creation" do
12
12
  after do
13
- ExcelApp.close_all
13
+ Excel.close_all
14
14
  end
15
15
 
16
- def creation_ok?
16
+ def creation_ok? # :nodoc: #
17
17
  @app.alive?.should == true
18
18
  @app.Visible.should == false
19
19
  @app.DisplayAlerts.should == false
@@ -21,51 +21,49 @@ module RobustExcelOle
21
21
  end
22
22
 
23
23
  it "should work with 'new' " do
24
- @app = ExcelApp.new
24
+ @app = Excel.new
25
25
  creation_ok?
26
26
  end
27
27
 
28
28
  it "should work with 'new' " do
29
- @app = ExcelApp.new(:reuse => false)
29
+ @app = Excel.new(:reuse => false)
30
30
  creation_ok?
31
31
  end
32
32
 
33
33
  it "should work with 'create' " do
34
- @app = ExcelApp.create
34
+ @app = Excel.create
35
35
  creation_ok?
36
36
  end
37
37
 
38
38
  end
39
39
 
40
-
41
-
42
40
  context "with existing app" do
43
41
 
44
42
  before do
45
- ExcelApp.close_all
46
- @app1 = ExcelApp.create
43
+ Excel.close_all
44
+ @app1 = Excel.create
47
45
  end
48
46
 
49
47
  after do
50
- ExcelApp.close_all
48
+ Excel.close_all
51
49
  end
52
50
 
53
51
  it "should create different app" do
54
- app2 = ExcelApp.create
52
+ app2 = Excel.create
55
53
  #puts "@app1 #{@app1.Hwnd}"
56
54
  #puts "app2 #{app2.Hwnd}"
57
55
  app2.Hwnd.should_not == @app1.Hwnd
58
56
  end
59
57
 
60
58
  it "should reuse existing app" do
61
- app2 = ExcelApp.reuse
59
+ app2 = Excel.current
62
60
  #puts "@app1 #{@app1.Hwnd}"
63
61
  #puts "app2 #{app2.Hwnd}"
64
62
  app2.Hwnd.should == @app1.Hwnd
65
63
  end
66
64
 
67
65
  it "should reuse existing app with default options for 'new'" do
68
- app2 = ExcelApp.new
66
+ app2 = Excel.new
69
67
  #puts "@app1 #{@app1.Hwnd}"
70
68
  #puts "app2 #{app2.Hwnd}"
71
69
  app2.Hwnd.should == @app1.Hwnd
@@ -74,7 +72,7 @@ module RobustExcelOle
74
72
  end
75
73
 
76
74
  context "close excel instances" do
77
- def direct_excel_creation_helper
75
+ def direct_excel_creation_helper # :nodoc: #
78
76
  expect { WIN32OLE.connect("Excel.Application") }.to raise_error
79
77
  sleep 0.1
80
78
  exl1 = WIN32OLE.new("Excel.Application")
@@ -85,9 +83,9 @@ module RobustExcelOle
85
83
  end
86
84
 
87
85
  it "simple file with default" do
88
- RobustExcelOle::ExcelApp.close_all
86
+ RobustExcelOle::Excel.close_all
89
87
  direct_excel_creation_helper
90
- RobustExcelOle::ExcelApp.close_all
88
+ RobustExcelOle::Excel.close_all
91
89
  sleep 0.1
92
90
  expect { WIN32OLE.connect("Excel.Application") }.to raise_error
93
91
  end
@@ -95,25 +93,25 @@ module RobustExcelOle
95
93
 
96
94
  describe "==" do
97
95
  before do
98
- ExcelApp.close_all
99
- @app1 = ExcelApp.create
96
+ Excel.close_all
97
+ @app1 = Excel.create
100
98
  end
101
99
 
102
100
  after do
103
- ExcelApp.close_all
101
+ Excel.close_all
104
102
  end
105
103
 
106
104
  it "should be true with two identical excel applications" do
107
- app2 = ExcelApp.reuse
105
+ app2 = Excel.current
108
106
  app2.should == @app1
109
107
  end
110
108
 
111
109
  it "should be false with two different excel applications" do
112
- app2 = ExcelApp.create
110
+ app2 = Excel.create
113
111
  app2.should_not == @app1
114
112
  end
115
113
 
116
- it "should be false with non-ExcelApp objects" do
114
+ it "should be false with non-Excel objects" do
117
115
  @app1.should_not == "hallo"
118
116
  @app1.should_not == 7
119
117
  @app1.should_not == nil
@@ -122,21 +120,21 @@ module RobustExcelOle
122
120
  end
123
121
 
124
122
 
125
- context "with :excel_app" do
123
+ context "with :excel" do
126
124
 
127
125
  before do
128
- ExcelApp.close_all
126
+ Excel.close_all
129
127
  end
130
128
 
131
129
  after (:each) do
132
- ExcelApp.close_all
130
+ Excel.close_all
133
131
  end
134
132
 
135
133
  it "should reuse in given excel app" do
136
- app1 = ExcelApp.new(:reuse => false)
137
- app2 = ExcelApp.new(:reuse => false)
138
- app3 = ExcelApp.new(:excel_app => app1)
139
- app4 = ExcelApp.new(:excel_app => app2)
134
+ app1 = Excel.new(:reuse => false)
135
+ app2 = Excel.new(:reuse => false)
136
+ app3 = Excel.new(:excel => app1)
137
+ app4 = Excel.new(:excel => app2)
140
138
  app3.should == app1
141
139
  app4.should == app2
142
140
  end
@@ -146,30 +144,30 @@ module RobustExcelOle
146
144
  context "with Visible and DisplayAlerts" do
147
145
 
148
146
  before do
149
- ExcelApp.close_all
147
+ Excel.close_all
150
148
  end
151
149
 
152
150
  after (:each) do
153
- ExcelApp.close_all
151
+ Excel.close_all
154
152
  end
155
153
 
156
154
  it "should be visible" do
157
- app = ExcelApp.new(:visible => true)
155
+ app = Excel.new(:visible => true)
158
156
  app.Visible.should == true
159
157
  app.DisplayAlerts.should == false
160
158
  end
161
159
 
162
160
  it "should displayalerts" do
163
- app = ExcelApp.new(:displayalerts => true)
161
+ app = Excel.new(:displayalerts => true)
164
162
  app.DisplayAlerts.should == true
165
163
  app.Visible.should == false
166
164
  end
167
165
 
168
166
  it "should visible and displayalerts" do
169
- app = ExcelApp.new(:visible => true)
167
+ app = Excel.new(:visible => true)
170
168
  app.Visible.should == true
171
169
  app.DisplayAlerts.should == false
172
- app2 = ExcelApp.new(:displayalerts => true)
170
+ app2 = Excel.new(:displayalerts => true)
173
171
  app2.Visible.should == true
174
172
  app2.DisplayAlerts.should == true
175
173
  end
@@ -177,4 +175,22 @@ module RobustExcelOle
177
175
  end
178
176
 
179
177
  end
178
+
179
+ describe "RobustExcelOle" do
180
+ context "#absolute_path" do
181
+ it "should work" do
182
+ RobustExcelOle::absolute_path("C:/abc").should == "C:\\abc"
183
+ RobustExcelOle::absolute_path("C:\\abc").should == "C:\\abc"
184
+ RobustExcelOle::absolute_path("C:abc").should == Dir.pwd.gsub("/","\\") + "\\abc"
185
+ RobustExcelOle::absolute_path("C:abc").should == File.expand_path("abc").gsub("/","\\")
186
+ end
187
+
188
+ it "should return right absoute path name" do
189
+ @filename = 'C:/Dokumente und Einstellungen/Zauberthomas/Eigene Dateien/robust_excel_ole/spec/book_spec.rb'
190
+ RobustExcelOle::absolute_path(@filename).gsub("\\","/").should == @filename
191
+ end
192
+ end
193
+
194
+ end
195
+
180
196
  end