robust_excel_ole 1.3 → 1.4
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.
- checksums.yaml +4 -4
- data/Changelog +6 -0
- data/README.rdoc +1 -1
- data/docs/README_open.rdoc +1 -1
- data/docs/README_ranges.rdoc +60 -57
- data/docs/README_sheet.rdoc +1 -1
- data/examples/introducing_examples/example_introducing.rb +42 -0
- data/examples/introducing_examples/example_open.rb +49 -0
- data/examples/introducing_examples/example_range.rb +67 -0
- data/examples/{edit_sheets → modifying_sheets}/example_access_sheets_and_cells.rb +0 -0
- data/examples/{edit_sheets → modifying_sheets}/example_adding_sheets.rb +0 -0
- data/examples/{edit_sheets → modifying_sheets}/example_concating.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_copying.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_expanding.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_naming.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_ranges.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_saving.rb +1 -1
- data/examples/open_save_close/example_control_to_excel.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 +3 -3
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
- 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 +2 -2
- data/lib/robust_excel_ole/bookstore.rb +1 -1
- data/lib/robust_excel_ole/cell.rb +15 -2
- data/lib/robust_excel_ole/excel.rb +14 -12
- data/lib/robust_excel_ole/general.rb +12 -0
- data/lib/robust_excel_ole/range.rb +37 -20
- data/lib/robust_excel_ole/reo_common.rb +63 -37
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/{book.rb → workbook.rb} +35 -33
- data/lib/robust_excel_ole/{sheet.rb → worksheet.rb} +22 -22
- data/spec/bookstore_spec.rb +38 -38
- data/spec/cell_spec.rb +10 -10
- data/spec/data/another_workbook.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +113 -105
- data/spec/general_spec.rb +37 -5
- data/spec/range_spec.rb +34 -19
- data/spec/reo_common_spec.rb +58 -48
- data/spec/{book_spec.rb → workbook_spec.rb} +198 -198
- data/spec/workbook_specs/workbook_all_spec.rb +33 -0
- data/spec/{book_specs/book_close_spec.rb → workbook_specs/workbook_close_spec.rb} +10 -10
- data/spec/{book_specs/book_misc_spec.rb → workbook_specs/workbook_misc_spec.rb} +148 -128
- data/spec/{book_specs/book_open_spec.rb → workbook_specs/workbook_open_spec.rb} +427 -427
- data/spec/{book_specs/book_save_spec.rb → workbook_specs/workbook_save_spec.rb} +44 -44
- data/spec/{book_specs/book_sheet_spec.rb → workbook_specs/workbook_sheet_spec.rb} +19 -19
- data/spec/{book_specs/book_subclass_spec.rb → workbook_specs/workbook_subclass_spec.rb} +5 -6
- data/spec/{book_specs/book_unobtr_spec.rb → workbook_specs/workbook_unobtr_spec.rb} +339 -344
- data/spec/{sheet_spec.rb → worksheet_spec.rb} +85 -55
- metadata +25 -22
- data/spec/book_specs/book_all_spec.rb +0 -22
@@ -8,7 +8,7 @@ $VERBOSE = nil
|
|
8
8
|
include RobustExcelOle
|
9
9
|
include General
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe Workbook do
|
12
12
|
|
13
13
|
before(:all) do
|
14
14
|
excel = Excel.new(:reuse => true)
|
@@ -52,61 +52,61 @@ describe Book do
|
|
52
52
|
it "should simply open" do
|
53
53
|
book = Workbook.open(@simple_file1, :if_unsaved => :accept)
|
54
54
|
book.should be_alive
|
55
|
-
book.should be_a
|
55
|
+
book.should be_a Workbook
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should open in a new Excel" do
|
59
59
|
book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
60
60
|
book2.should be_alive
|
61
|
-
book2.should be_a
|
61
|
+
book2.should be_a Workbook
|
62
62
|
book2.excel.should_not == @ole_excel1
|
63
63
|
book2.Readonly.should be true
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should fetch the workbook" do
|
67
|
-
new_book =
|
68
|
-
new_book.should be_a
|
67
|
+
new_book = Workbook.new(@ole_workbook1)
|
68
|
+
new_book.should be_a Workbook
|
69
69
|
new_book.should be_alive
|
70
70
|
new_book.ole_workbook.should == @ole_workbook1
|
71
71
|
new_book.excel.ole_excel.Hwnd.should == @ole_excel1.Hwnd
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should fetch a closed workbook" do
|
75
|
-
new_book =
|
75
|
+
new_book = Workbook.new(@ole_workbook1)
|
76
76
|
new_book.close(:if_unsaved => :forget)
|
77
77
|
new_book.should_not be_alive
|
78
|
-
book2 =
|
78
|
+
book2 = Workbook.open(@simple_file1)
|
79
79
|
book2.should === new_book
|
80
80
|
book2.should be_alive
|
81
81
|
book2.close
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should force_excel with :reuse" do
|
85
|
-
book2 =
|
85
|
+
book2 = Workbook.open(@different_file, :force => {:excel => :current})
|
86
86
|
book2.should be_alive
|
87
|
-
book2.should be_a
|
87
|
+
book2.should be_a Workbook
|
88
88
|
book2.excel.ole_excel.Hwnd.should == @ole_excel1.Hwnd
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
92
|
-
book1 =
|
92
|
+
book1 = Workbook.open(@simple_file1, :if_unsaved => :forget)
|
93
93
|
excel2 = Excel.new(:reuse => false)
|
94
94
|
book1.excel.close(:if_unsaved => :forget)
|
95
95
|
sleep 1
|
96
|
-
book2 =
|
96
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :current}, :default => {:excel => :new})
|
97
97
|
book2.should be_alive
|
98
|
-
book2.should be_a
|
98
|
+
book2.should be_a Workbook
|
99
99
|
book2.excel.ole_excel.Hwnd.should == @ole_excel2.Hwnd
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should reopen the closed book" do
|
103
|
-
book1 =
|
103
|
+
book1 = Workbook.open(@simple_file1, :if_unsaved => :accept)
|
104
104
|
book1.should be_alive
|
105
105
|
book2 = book1
|
106
106
|
book1.close(:if_unsaved => :forget)
|
107
107
|
book1.should_not be_alive
|
108
108
|
book1.reopen
|
109
|
-
book1.should be_a
|
109
|
+
book1.should be_a Workbook
|
110
110
|
book1.should be_alive
|
111
111
|
book1.should === book2
|
112
112
|
end
|
@@ -115,10 +115,10 @@ describe Book do
|
|
115
115
|
context "with :if_unsaved" do
|
116
116
|
|
117
117
|
before do
|
118
|
-
@book =
|
118
|
+
@book = Workbook.open(@simple_file1, :if_unsaved => :accept)
|
119
119
|
sheet = @book.sheet(1)
|
120
120
|
@old_value = sheet[1,1].Value
|
121
|
-
sheet[1,1] = (sheet[1,1].
|
121
|
+
sheet[1,1] = (sheet[1,1].Value == "foo" ? "bar" : "foo")
|
122
122
|
@new_value = sheet[1,1].Value
|
123
123
|
@book.Saved.should be false
|
124
124
|
end
|
@@ -128,7 +128,7 @@ describe Book do
|
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should let the book open, if :if_unsaved is :accept" do
|
131
|
-
new_book =
|
131
|
+
new_book = Workbook.open(@simple_file1, :if_unsaved => :accept)
|
132
132
|
@book.should be_alive
|
133
133
|
new_book.should be_alive
|
134
134
|
new_book.Saved.should be false
|
@@ -138,7 +138,7 @@ describe Book do
|
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should open book and close old book, if :if_unsaved is :forget" do
|
141
|
-
new_book =
|
141
|
+
new_book = Workbook.open(@simple_file1, :if_unsaved => :forget)
|
142
142
|
@book.should_not be_alive
|
143
143
|
new_book.should be_alive
|
144
144
|
new_book.Saved.should be true
|
@@ -149,12 +149,12 @@ describe Book do
|
|
149
149
|
|
150
150
|
it "should raise an error, if :if_obstructed is :raise" do
|
151
151
|
expect {
|
152
|
-
new_book =
|
152
|
+
new_book = Workbook.open(@simple_file_other_path1)
|
153
153
|
}.to raise_error(WorkbookBlocked, /blocked by a workbook with the same name in a different path/)
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should close the other book and open the new book, if :if_obstructed is :forget" do
|
157
|
-
new_book =
|
157
|
+
new_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
|
158
158
|
expect{
|
159
159
|
@ole_workbook1.Name
|
160
160
|
}.to raise_error
|
@@ -166,11 +166,11 @@ describe Book do
|
|
166
166
|
context "with :force => {:excel}" do
|
167
167
|
|
168
168
|
it "should open in a provided Excel" do
|
169
|
-
book1 =
|
170
|
-
book2 =
|
171
|
-
book3 =
|
169
|
+
book1 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
170
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
171
|
+
book3 = Workbook.open(@simple_file1, :force => {:excel => book2.excel})
|
172
172
|
book3.should be_alive
|
173
|
-
book3.should be_a
|
173
|
+
book3.should be_a Workbook
|
174
174
|
book3.excel.should == book2.excel
|
175
175
|
book3.Readonly.should be true
|
176
176
|
end
|
@@ -190,19 +190,19 @@ describe Book do
|
|
190
190
|
it "should simply create a new one" do
|
191
191
|
book = Workbook.new(@simple_file)
|
192
192
|
book.should be_alive
|
193
|
-
book.should be_a
|
193
|
+
book.should be_a Workbook
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should set options" do
|
197
197
|
book = Workbook.new(@simple_file, :visible => true, :read_only => true, :force => {:excel => :new})
|
198
198
|
book.should be_alive
|
199
|
-
book.should be_a
|
199
|
+
book.should be_a Workbook
|
200
200
|
book.excel.Visible.should be true
|
201
201
|
book.Windows(book.Name).Visible.should be true
|
202
202
|
book.ReadOnly.should be true
|
203
203
|
book2 = Workbook.new(@different_file, :force => {:excel => :new}, :v => true)
|
204
204
|
book2.should be_alive
|
205
|
-
book2.should be_a
|
205
|
+
book2.should be_a Workbook
|
206
206
|
book2.excel.Visible.should be true
|
207
207
|
book2.Windows(book2.Name).Visible.should be true
|
208
208
|
book2.ReadOnly.should be false
|
@@ -216,12 +216,12 @@ describe Book do
|
|
216
216
|
context "with calculation mode" do
|
217
217
|
|
218
218
|
it "should set calculation mode" do
|
219
|
-
book1 =
|
219
|
+
book1 = Workbook.open(@simple_file1, :visible => true)
|
220
220
|
book1.excel.calculation = :manual
|
221
221
|
book1.excel.Calculation.should == XlCalculationManual
|
222
222
|
book1.save
|
223
223
|
book1.excel.close
|
224
|
-
book2 =
|
224
|
+
book2 = Workbook.open(@simple_file1, :visible => true)
|
225
225
|
book2.excel.calculation = :automatic
|
226
226
|
book2.excel.Calculation.should == XlCalculationAutomatic
|
227
227
|
book2.save
|
@@ -229,28 +229,28 @@ describe Book do
|
|
229
229
|
end
|
230
230
|
|
231
231
|
it "should not set the default value" do
|
232
|
-
book1 =
|
232
|
+
book1 = Workbook.open(@simple_file)
|
233
233
|
book1.excel.calculation.should == nil
|
234
234
|
end
|
235
235
|
|
236
236
|
it "should set the calculation mode to automatic" do
|
237
|
-
book1 =
|
237
|
+
book1 = Workbook.open(@simple_file)
|
238
238
|
book1.excel.calculation = :automatic
|
239
239
|
book1.excel.calculation.should == :automatic
|
240
240
|
book1.excel.Calculation.should == XlCalculationAutomatic
|
241
241
|
end
|
242
242
|
|
243
243
|
it "should set the calculation mode to manual" do
|
244
|
-
book1 =
|
244
|
+
book1 = Workbook.open(@simple_file)
|
245
245
|
book1.excel.calculation = :manual
|
246
246
|
book1.excel.calculation.should == :manual
|
247
247
|
book1.excel.Calculation.should == XlCalculationManual
|
248
248
|
end
|
249
249
|
|
250
250
|
it "should change the calculation mode from manual to automatic" do
|
251
|
-
book1 =
|
251
|
+
book1 = Workbook.open(@simple_file, :visible => true)
|
252
252
|
excel1 = Excel.current(:calculation => :automatic)
|
253
|
-
book2 =
|
253
|
+
book2 = Workbook.open(@different_file, :visible => true)
|
254
254
|
book2.excel.Calculation.should == XlCalculationAutomatic
|
255
255
|
book1.excel.Calculation.should == XlCalculationAutomatic
|
256
256
|
end
|
@@ -260,11 +260,11 @@ describe Book do
|
|
260
260
|
context "with causing warning dead excel without window handle" do
|
261
261
|
|
262
262
|
it "combined" do
|
263
|
-
book1 =
|
264
|
-
book2 =
|
263
|
+
book1 = Workbook.open(@simple_file1)
|
264
|
+
book2 = Workbook.open(@different_file)
|
265
265
|
Excel.kill_all
|
266
266
|
#sleep 1 #then no warning
|
267
|
-
Excel.current # or book3 =
|
267
|
+
Excel.current # or book3 = Workbook.open(@another_simple_file)
|
268
268
|
end
|
269
269
|
|
270
270
|
end
|
@@ -282,7 +282,7 @@ describe Book do
|
|
282
282
|
it "should open in a new Excel" do
|
283
283
|
book2 = Workbook.open(@simple_file, :force => {:excel => :new})
|
284
284
|
book2.should be_alive
|
285
|
-
book2.should be_a
|
285
|
+
book2.should be_a Workbook
|
286
286
|
book2.excel.should_not == @book.excel
|
287
287
|
book2.should_not == @book
|
288
288
|
@book.Readonly.should be false
|
@@ -291,10 +291,10 @@ describe Book do
|
|
291
291
|
end
|
292
292
|
end
|
293
293
|
|
294
|
-
context "lift a workbook to a
|
294
|
+
context "lift a workbook to a Workbook object" do
|
295
295
|
|
296
296
|
before do
|
297
|
-
@book =
|
297
|
+
@book = Workbook.open(@simple_file)
|
298
298
|
end
|
299
299
|
|
300
300
|
after do
|
@@ -303,8 +303,8 @@ describe Book do
|
|
303
303
|
|
304
304
|
it "should fetch the workbook" do
|
305
305
|
workbook = @book.ole_workbook
|
306
|
-
new_book =
|
307
|
-
new_book.should be_a
|
306
|
+
new_book = Workbook.new(workbook)
|
307
|
+
new_book.should be_a Workbook
|
308
308
|
new_book.should be_alive
|
309
309
|
new_book.should == @book
|
310
310
|
new_book.filename.should == @book.filename
|
@@ -317,8 +317,8 @@ describe Book do
|
|
317
317
|
|
318
318
|
it "should fetch the workbook" do
|
319
319
|
workbook = @book.ole_workbook
|
320
|
-
new_book =
|
321
|
-
new_book.should be_a
|
320
|
+
new_book = Workbook.new(workbook, :visible => true)
|
321
|
+
new_book.should be_a Workbook
|
322
322
|
new_book.should be_alive
|
323
323
|
new_book.should == @book
|
324
324
|
new_book.filename.should == @book.filename
|
@@ -329,11 +329,11 @@ describe Book do
|
|
329
329
|
new_book.close
|
330
330
|
end
|
331
331
|
|
332
|
-
it "should yield an identical
|
332
|
+
it "should yield an identical Workbook and set visible value" do
|
333
333
|
workbook = @book.ole_workbook
|
334
|
-
new_book =
|
334
|
+
new_book = Workbook.new(workbook, :visible => true)
|
335
335
|
new_book.excel.displayalerts = true
|
336
|
-
new_book.should be_a
|
336
|
+
new_book.should be_a Workbook
|
337
337
|
new_book.should be_alive
|
338
338
|
new_book.should == @book
|
339
339
|
new_book.filename.should == @book.filename
|
@@ -348,7 +348,7 @@ describe Book do
|
|
348
348
|
|
349
349
|
context "with standard options" do
|
350
350
|
before do
|
351
|
-
@book =
|
351
|
+
@book = Workbook.open(@simple_file)
|
352
352
|
end
|
353
353
|
|
354
354
|
after do
|
@@ -363,69 +363,69 @@ describe Book do
|
|
363
363
|
context "with identity transperence" do
|
364
364
|
|
365
365
|
before do
|
366
|
-
@book =
|
366
|
+
@book = Workbook.open(@simple_file1)
|
367
367
|
end
|
368
368
|
|
369
369
|
after do
|
370
370
|
@book.close
|
371
371
|
end
|
372
372
|
|
373
|
-
it "should yield identical
|
374
|
-
book2 =
|
373
|
+
it "should yield identical Workbook objects for identical Excel books" do
|
374
|
+
book2 = Workbook.open(@simple_file1)
|
375
375
|
book2.should === @book
|
376
376
|
book2.close
|
377
377
|
end
|
378
378
|
|
379
|
-
it "should yield different
|
380
|
-
book2 =
|
379
|
+
it "should yield different Workbook objects for different Excel books" do
|
380
|
+
book2 = Workbook.open(@different_file)
|
381
381
|
book2.should_not === @book
|
382
382
|
book2.close
|
383
383
|
end
|
384
384
|
|
385
|
-
it "should yield different
|
386
|
-
book2 =
|
385
|
+
it "should yield different Workbook objects when opened the same file in different Excel instances" do
|
386
|
+
book2 = Workbook.open(@simple_file, :force => {:excel => :new})
|
387
387
|
book2.should_not === @book
|
388
388
|
book2.close
|
389
389
|
end
|
390
390
|
|
391
|
-
it "should yield identical
|
391
|
+
it "should yield identical Workbook objects for identical Excel books when reopening" do
|
392
392
|
@book.should be_alive
|
393
393
|
@book.close
|
394
394
|
@book.should_not be_alive
|
395
|
-
book2 =
|
395
|
+
book2 = Workbook.open(@simple_file1)
|
396
396
|
book2.should === @book
|
397
397
|
book2.should be_alive
|
398
398
|
book2.close
|
399
399
|
end
|
400
400
|
|
401
|
-
it "should yield identical
|
401
|
+
it "should yield identical Workbook objects when reopening and the Excel is closed" do
|
402
402
|
@book.should be_alive
|
403
403
|
@book.close
|
404
404
|
Excel.close_all
|
405
|
-
book2 =
|
405
|
+
book2 = Workbook.open(@simple_file1)
|
406
406
|
book2.should be_alive
|
407
407
|
book2.should === @book
|
408
408
|
book2.close
|
409
409
|
end
|
410
410
|
|
411
|
-
it "should yield different
|
411
|
+
it "should yield different Workbook objects when reopening in a new Excel" do
|
412
412
|
@book.should be_alive
|
413
413
|
old_excel = @book.excel
|
414
414
|
@book.close
|
415
415
|
@book.should_not be_alive
|
416
|
-
book2 =
|
416
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
417
417
|
book2.should_not === @book
|
418
418
|
book2.should be_alive
|
419
419
|
book2.excel.should_not == old_excel
|
420
420
|
book2.close
|
421
421
|
end
|
422
422
|
|
423
|
-
it "should yield different
|
423
|
+
it "should yield different Workbook objects when reopening in a new given Excel instance" do
|
424
424
|
old_excel = @book.excel
|
425
425
|
new_excel = Excel.new(:reuse => false)
|
426
426
|
@book.close
|
427
427
|
@book.should_not be_alive
|
428
|
-
book2 =
|
428
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => new_excel})
|
429
429
|
#@book.should be_alive
|
430
430
|
#book2.should === @book
|
431
431
|
book2.should be_alive
|
@@ -434,12 +434,12 @@ describe Book do
|
|
434
434
|
book2.close
|
435
435
|
end
|
436
436
|
|
437
|
-
it "should yield identical
|
437
|
+
it "should yield identical Workbook objects when reopening in the old excel" do
|
438
438
|
old_excel = @book.excel
|
439
439
|
new_excel = Excel.new(:reuse => false)
|
440
440
|
@book.close
|
441
441
|
@book.should_not be_alive
|
442
|
-
book2 =
|
442
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => old_excel})
|
443
443
|
book2.should === @book
|
444
444
|
book2.should be_alive
|
445
445
|
book2.excel.should == old_excel
|
@@ -452,7 +452,7 @@ describe Book do
|
|
452
452
|
context "with abbrevations" do
|
453
453
|
|
454
454
|
before do
|
455
|
-
@book =
|
455
|
+
@book = Workbook.open(@simple_file1)
|
456
456
|
end
|
457
457
|
|
458
458
|
after do
|
@@ -460,61 +460,61 @@ describe Book do
|
|
460
460
|
end
|
461
461
|
|
462
462
|
it "should work as force" do
|
463
|
-
book2 =
|
463
|
+
book2 = Workbook.open(@another_simple_file, :excel => :new)
|
464
464
|
book2.excel.should_not == @book.excel
|
465
|
-
book3 =
|
465
|
+
book3 = Workbook.open(@different_file, :excel => book2.excel)
|
466
466
|
book3.excel.should == book2.excel
|
467
467
|
end
|
468
468
|
|
469
469
|
it "should work with abbrevation of force and excel" do
|
470
|
-
book2 =
|
470
|
+
book2 = Workbook.open(@another_simple_file, :f => {:e => :new})
|
471
471
|
book2.excel.should_not == @book.excel
|
472
|
-
book3 =
|
472
|
+
book3 = Workbook.open(@different_file, :f => {:e => book2.excel})
|
473
473
|
book3.excel.should == book2.excel
|
474
474
|
end
|
475
475
|
|
476
476
|
it "should work with abbrevation of force" do
|
477
|
-
book2 =
|
477
|
+
book2 = Workbook.open(@another_simple_file, :f => {:excel => :new})
|
478
478
|
book2.excel.should_not == @book.excel
|
479
|
-
book3 =
|
479
|
+
book3 = Workbook.open(@different_file, :f => {:excel => book2.excel})
|
480
480
|
book3.excel.should == book2.excel
|
481
481
|
end
|
482
482
|
|
483
483
|
it "should work with abbrevation of force" do
|
484
|
-
book2 =
|
484
|
+
book2 = Workbook.open(@another_simple_file, :force => {:e => :new})
|
485
485
|
book2.excel.should_not == @book.excel
|
486
|
-
book3 =
|
486
|
+
book3 = Workbook.open(@different_file, :force => {:e => book2.excel})
|
487
487
|
book3.excel.should == book2.excel
|
488
488
|
end
|
489
489
|
|
490
|
-
it "should open in a given Excel provided as Excel,
|
491
|
-
book2 =
|
492
|
-
book3 =
|
493
|
-
book3 =
|
490
|
+
it "should open in a given Excel provided as Excel, Workbook, or WIN32OLE representing an Excel or Workbook" do
|
491
|
+
book2 = Workbook.open(@another_simple_file)
|
492
|
+
book3 = Workbook.open(@different_file)
|
493
|
+
book3 = Workbook.open(@simple_file1, :excel => book2.excel)
|
494
494
|
book3.excel.should === book2.excel
|
495
|
-
book4 =
|
495
|
+
book4 = Workbook.open(@simple_file1, :excel => @book)
|
496
496
|
book4.excel.should === @book.excel
|
497
497
|
book3.close
|
498
498
|
book4.close
|
499
|
-
book5 =
|
499
|
+
book5 = Workbook.open(@simple_file1, :excel => book2.ole_workbook)
|
500
500
|
book5.excel.should === book2.excel
|
501
501
|
win32ole_excel1 = WIN32OLE.connect(@book.ole_workbook.Fullname).Application
|
502
|
-
book6 =
|
502
|
+
book6 = Workbook.open(@simple_file1, :excel => win32ole_excel1)
|
503
503
|
book6.excel.should === @book.excel
|
504
504
|
end
|
505
505
|
|
506
506
|
it "should use abbreviations of default" do
|
507
|
-
book2 =
|
507
|
+
book2 = Workbook.open(@simple_file1, :d => {:excel => :current})
|
508
508
|
book2.excel.should == @book.excel
|
509
509
|
end
|
510
510
|
|
511
511
|
it "should use abbreviations of default" do
|
512
|
-
book2 =
|
512
|
+
book2 = Workbook.open(@simple_file1, :d => {:e => :current})
|
513
513
|
book2.excel.should == @book.excel
|
514
514
|
end
|
515
515
|
|
516
516
|
it "should use abbreviations of default" do
|
517
|
-
book2 =
|
517
|
+
book2 = Workbook.open(@simple_file1, :default => {:e => :current})
|
518
518
|
book2.excel.should == @book.excel
|
519
519
|
end
|
520
520
|
|
@@ -522,12 +522,12 @@ describe Book do
|
|
522
522
|
excel1 = @book.excel
|
523
523
|
excel2 = Excel.new(:reuse => false)
|
524
524
|
@book.close
|
525
|
-
book2 =
|
525
|
+
book2 = Workbook.open(@simple_file1, :d => {:e => :current})
|
526
526
|
book2.excel.should == excel1
|
527
527
|
book2.close
|
528
|
-
book3 =
|
528
|
+
book3 = Workbook.open(@simple_file1, :e => excel2)
|
529
529
|
book3.close
|
530
|
-
book3 =
|
530
|
+
book3 = Workbook.open(@simple_file1, :d => {:e => :current})
|
531
531
|
book3.excel.should == excel2
|
532
532
|
book3.close
|
533
533
|
end
|
@@ -537,7 +537,7 @@ describe Book do
|
|
537
537
|
context "with :force => {:excel}" do
|
538
538
|
|
539
539
|
before do
|
540
|
-
@book =
|
540
|
+
@book = Workbook.open(@simple_file1)
|
541
541
|
end
|
542
542
|
|
543
543
|
after do
|
@@ -547,30 +547,30 @@ describe Book do
|
|
547
547
|
it "should open not in the reserved Excel instance" do
|
548
548
|
Excel.kill_all
|
549
549
|
sleep 1
|
550
|
-
book2 =
|
550
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :reserved_new})
|
551
551
|
Excel.current.should_not == book2.excel
|
552
|
-
book3 =
|
552
|
+
book3 = Workbook.open(@different_file1, :default => {:excel => :current})
|
553
553
|
book3.excel.should_not == book2.excel
|
554
|
-
book4 =
|
554
|
+
book4 = Workbook.open(@another_simple_file1, :default => {:excel => :new})
|
555
555
|
book4.excel.should_not == book2.excel
|
556
556
|
book4.close
|
557
557
|
sleep 1
|
558
|
-
book5 =
|
558
|
+
book5 = Workbook.open(@another_simple_file1, :default => {:excel => :reserved_new})
|
559
559
|
book5.excel.should_not == book2.excel
|
560
560
|
end
|
561
561
|
|
562
562
|
it "should open in the reserved Excel instance" do
|
563
563
|
excel1 = @book.excel
|
564
564
|
@book.close
|
565
|
-
book2 =
|
565
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :reserved_new})
|
566
566
|
book2.excel.should_not == excel1
|
567
567
|
end
|
568
568
|
|
569
569
|
it "should open in the reserved Excel instance" do
|
570
|
-
book2 =
|
571
|
-
book3 =
|
572
|
-
book4 =
|
573
|
-
book5 =
|
570
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :reserved_new})
|
571
|
+
book3 = Workbook.open(@different_file1, :force => {:excel => :reserved_new})
|
572
|
+
book4 = Workbook.open(@another_simple_file1, :force => {:excel => :new})
|
573
|
+
book5 = Workbook.open(@another_simple_file1, :force => {:excel => :current})
|
574
574
|
book2.excel.should_not == @book.excel
|
575
575
|
book3.excel.should_not == book2.excel
|
576
576
|
book4.excel.should_not == @book.excel
|
@@ -579,33 +579,33 @@ describe Book do
|
|
579
579
|
end
|
580
580
|
|
581
581
|
it "should open in the reserved Excel instance" do
|
582
|
-
book2 =
|
583
|
-
book3 =
|
582
|
+
book2 = Workbook.open(@another_simple_file1, :force => {:excel => :new})
|
583
|
+
book3 = Workbook.open(@different_file1, :force => {:excel => :reserved_new})
|
584
584
|
book2.excel.should_not == @book.excel
|
585
585
|
book3.excel.should_not == @book.excel
|
586
586
|
book3.excel.should_not == book2.excel
|
587
587
|
end
|
588
588
|
|
589
|
-
it "should open in a given Excel provided as Excel,
|
590
|
-
book2 =
|
591
|
-
book3 =
|
592
|
-
book3 =
|
589
|
+
it "should open in a given Excel provided as Excel, Workbook, or WIN32OLE representing an Excel or Workbook" do
|
590
|
+
book2 = Workbook.open(@another_simple_file)
|
591
|
+
book3 = Workbook.open(@different_file)
|
592
|
+
book3 = Workbook.open(@simple_file1, :force => {:excel => book2.excel})
|
593
593
|
book3.excel.should === book2.excel
|
594
|
-
book4 =
|
594
|
+
book4 = Workbook.open(@simple_file1, :force => {:excel => @book})
|
595
595
|
book4.excel.should === @book.excel
|
596
596
|
book3.close
|
597
597
|
book4.close
|
598
|
-
book5 =
|
598
|
+
book5 = Workbook.open(@simple_file1, :force => {:excel => book2.ole_workbook})
|
599
599
|
book5.excel.should === book2.excel
|
600
600
|
win32ole_excel1 = WIN32OLE.connect(@book.ole_workbook.Fullname).Application
|
601
|
-
book6 =
|
601
|
+
book6 = Workbook.open(@simple_file1, :force => {:excel => win32ole_excel1})
|
602
602
|
book6.excel.should === @book.excel
|
603
603
|
end
|
604
604
|
|
605
605
|
it "should open in a new Excel" do
|
606
|
-
book2 =
|
606
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
607
607
|
book2.should be_alive
|
608
|
-
book2.should be_a
|
608
|
+
book2.should be_a Workbook
|
609
609
|
book2.excel.should_not == @book.excel
|
610
610
|
book2.should_not == @book
|
611
611
|
@book.Readonly.should be false
|
@@ -614,22 +614,22 @@ describe Book do
|
|
614
614
|
end
|
615
615
|
|
616
616
|
it "should open in a given Excel, not provide identity transparency, because old book readonly, new book writable" do
|
617
|
-
book2 =
|
617
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
618
618
|
book2.excel.should_not == @book.excel
|
619
|
-
book3 =
|
619
|
+
book3 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
620
620
|
book3.excel.should_not == book2.excel
|
621
621
|
book3.excel.should_not == @book.excel
|
622
622
|
book2.close
|
623
|
-
book4 =
|
623
|
+
book4 = Workbook.open(@simple_file1, :force => {:excel => book2.excel})
|
624
624
|
book4.should be_alive
|
625
|
-
book4.should be_a
|
625
|
+
book4.should be_a Workbook
|
626
626
|
book4.excel.should == book2.excel
|
627
627
|
#book4.Readonly.should == true
|
628
628
|
book4.should_not == book2
|
629
629
|
book4.close
|
630
|
-
book5 =
|
630
|
+
book5 = Workbook.open(@simple_file1, :force => {:excel => book2})
|
631
631
|
book5.should be_alive
|
632
|
-
book5.should be_a
|
632
|
+
book5.should be_a Workbook
|
633
633
|
book5.excel.should == book2.excel
|
634
634
|
#book5.Readonly.should == true
|
635
635
|
book5.should_not == book2
|
@@ -638,24 +638,24 @@ describe Book do
|
|
638
638
|
end
|
639
639
|
|
640
640
|
it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
|
641
|
-
book2 =
|
641
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
642
642
|
book2.excel.should_not == @book.excel
|
643
|
-
book3 =
|
643
|
+
book3 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
644
644
|
book3.excel.should_not == book2.excel
|
645
645
|
book3.excel.should_not == @book.excel
|
646
646
|
book2.close
|
647
647
|
book3.close
|
648
648
|
@book.close
|
649
|
-
book4 =
|
649
|
+
book4 = Workbook.open(@simple_file1, :force => {:excel => book2.excel}, :read_only => true)
|
650
650
|
book4.should be_alive
|
651
|
-
book4.should be_a
|
651
|
+
book4.should be_a Workbook
|
652
652
|
book4.excel.should == book2.excel
|
653
653
|
book4.ReadOnly.should be true
|
654
654
|
book4.should == book2
|
655
655
|
book4.close
|
656
|
-
book5 =
|
656
|
+
book5 = Workbook.open(@simple_file1, :force => {:excel => book2}, :read_only => true)
|
657
657
|
book5.should be_alive
|
658
|
-
book5.should be_a
|
658
|
+
book5.should be_a Workbook
|
659
659
|
book5.excel.should == book2.excel
|
660
660
|
book5.ReadOnly.should be true
|
661
661
|
book5.should == book2
|
@@ -664,69 +664,69 @@ describe Book do
|
|
664
664
|
end
|
665
665
|
|
666
666
|
it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
|
667
|
-
book2 =
|
667
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
|
668
668
|
book2.excel.should_not == @book.excel
|
669
669
|
book2.close
|
670
670
|
@book.close
|
671
|
-
book4 =
|
671
|
+
book4 = Workbook.open(@simple_file1, :force => {:excel => book2}, :read_only => true)
|
672
672
|
book4.should be_alive
|
673
|
-
book4.should be_a
|
673
|
+
book4.should be_a Workbook
|
674
674
|
book4.excel.should == book2.excel
|
675
675
|
book4.ReadOnly.should be true
|
676
676
|
book4.should == book2
|
677
677
|
book4.close
|
678
678
|
end
|
679
679
|
|
680
|
-
it "should raise an error if no Excel or
|
680
|
+
it "should raise an error if no Excel or Workbook is given" do
|
681
681
|
expect{
|
682
|
-
|
682
|
+
Workbook.open(@simple_file1, :force => {:excel => :b})
|
683
683
|
}.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
|
684
684
|
end
|
685
685
|
|
686
686
|
it "should do force_excel even if both force_ and default_excel is given" do
|
687
|
-
book2 =
|
687
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => @book.excel}, :force => {:excel => :new})
|
688
688
|
book2.should be_alive
|
689
|
-
book2.should be_a
|
689
|
+
book2.should be_a Workbook
|
690
690
|
book2.excel.should_not == @book.excel
|
691
691
|
book2.should_not == @book
|
692
692
|
end
|
693
693
|
|
694
694
|
it "should do default_excel if force_excel is nil" do
|
695
|
-
book2 =
|
695
|
+
book2 = Workbook.open(@another_simple_file, :force => {:excel => nil})
|
696
696
|
book2.should be_alive
|
697
|
-
book2.should be_a
|
697
|
+
book2.should be_a Workbook
|
698
698
|
book2.excel.should == @book.excel
|
699
699
|
end
|
700
700
|
|
701
701
|
it "should force_excel with :reuse" do
|
702
|
-
book2 =
|
702
|
+
book2 = Workbook.open(@different_file, :force => {:excel => :current})
|
703
703
|
book2.should be_alive
|
704
|
-
book2.should be_a
|
704
|
+
book2.should be_a Workbook
|
705
705
|
book2.excel.should == @book.excel
|
706
706
|
end
|
707
707
|
|
708
708
|
it "should force_excel with :reuse even if :default_excel says sth. else" do
|
709
|
-
book2 =
|
709
|
+
book2 = Workbook.open(@different_file, :force => {:excel => :current}, :default => {:excel => :new})
|
710
710
|
book2.should be_alive
|
711
|
-
book2.should be_a
|
711
|
+
book2.should be_a Workbook
|
712
712
|
book2.excel.should == @book.excel
|
713
713
|
end
|
714
714
|
|
715
715
|
it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
716
716
|
excel2 = Excel.new(:reuse => false)
|
717
717
|
@book.excel.close
|
718
|
-
book2 =
|
718
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :current}, :default => {:excel => :new})
|
719
719
|
book2.should be_alive
|
720
|
-
book2.should be_a
|
720
|
+
book2.should be_a Workbook
|
721
721
|
book2.excel.should === excel2
|
722
722
|
end
|
723
723
|
|
724
724
|
it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
725
|
-
book2 =
|
725
|
+
book2 = Workbook.open(@different_file1, :force => {:excel => :new})
|
726
726
|
book2.excel.close
|
727
|
-
book3 =
|
727
|
+
book3 = Workbook.open(@different_file1, :force => {:excel => :current}, :default => {:excel => :new})
|
728
728
|
book3.should be_alive
|
729
|
-
book3.should be_a
|
729
|
+
book3.should be_a Workbook
|
730
730
|
book3.excel.should == @book.excel
|
731
731
|
end
|
732
732
|
|
@@ -735,33 +735,33 @@ describe Book do
|
|
735
735
|
context "with leaving out :force => {:excel}" do
|
736
736
|
|
737
737
|
before do
|
738
|
-
@book =
|
738
|
+
@book = Workbook.open(@simple_file1)
|
739
739
|
end
|
740
740
|
|
741
741
|
after do
|
742
742
|
@book.close rescue nil
|
743
743
|
end
|
744
744
|
|
745
|
-
it "should open in a given Excel provided as Excel,
|
746
|
-
book2 =
|
747
|
-
book3 =
|
748
|
-
book3 =
|
745
|
+
it "should open in a given Excel provided as Excel, Workbook, or WIN32OLE representing an Excel or Workbook" do
|
746
|
+
book2 = Workbook.open(@another_simple_file)
|
747
|
+
book3 = Workbook.open(@different_file)
|
748
|
+
book3 = Workbook.open(@simple_file1, :excel => book2.excel)
|
749
749
|
book3.excel.should === book2.excel
|
750
|
-
book4 =
|
750
|
+
book4 = Workbook.open(@simple_file1, :excel => @book)
|
751
751
|
book4.excel.should === @book.excel
|
752
752
|
book3.close
|
753
753
|
book4.close
|
754
|
-
book5 =
|
754
|
+
book5 = Workbook.open(@simple_file1, :excel => book2.ole_workbook)
|
755
755
|
book5.excel.should === book2.excel
|
756
756
|
win32ole_excel1 = WIN32OLE.connect(@book.ole_workbook.Fullname).Application
|
757
|
-
book6 =
|
757
|
+
book6 = Workbook.open(@simple_file1, :excel => win32ole_excel1)
|
758
758
|
book6.excel.should === @book.excel
|
759
759
|
end
|
760
760
|
|
761
761
|
it "should open in a new Excel" do
|
762
|
-
book2 =
|
762
|
+
book2 = Workbook.open(@simple_file1, :excel => :new)
|
763
763
|
book2.should be_alive
|
764
|
-
book2.should be_a
|
764
|
+
book2.should be_a Workbook
|
765
765
|
book2.excel.should_not == @book.excel
|
766
766
|
book2.should_not == @book
|
767
767
|
@book.Readonly.should be false
|
@@ -770,22 +770,22 @@ describe Book do
|
|
770
770
|
end
|
771
771
|
|
772
772
|
it "should open in a given Excel, not provide identity transparency, because old book readonly, new book writable" do
|
773
|
-
book2 =
|
773
|
+
book2 = Workbook.open(@simple_file1, :excel => :new)
|
774
774
|
book2.excel.should_not == @book.excel
|
775
|
-
book3 =
|
775
|
+
book3 = Workbook.open(@simple_file1, :excel => :new)
|
776
776
|
book3.excel.should_not == book2.excel
|
777
777
|
book3.excel.should_not == @book.excel
|
778
778
|
book2.close
|
779
|
-
book4 =
|
779
|
+
book4 = Workbook.open(@simple_file1, :excel => book2.excel)
|
780
780
|
book4.should be_alive
|
781
|
-
book4.should be_a
|
781
|
+
book4.should be_a Workbook
|
782
782
|
book4.excel.should == book2.excel
|
783
783
|
#book4.Readonly.should == true
|
784
784
|
book4.should_not == book2
|
785
785
|
book4.close
|
786
|
-
book5 =
|
786
|
+
book5 = Workbook.open(@simple_file1, :excel => book2)
|
787
787
|
book5.should be_alive
|
788
|
-
book5.should be_a
|
788
|
+
book5.should be_a Workbook
|
789
789
|
book5.excel.should == book2.excel
|
790
790
|
#book5.Readonly.should == true
|
791
791
|
book5.should_not == book2
|
@@ -794,24 +794,24 @@ describe Book do
|
|
794
794
|
end
|
795
795
|
|
796
796
|
it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
|
797
|
-
book2 =
|
797
|
+
book2 = Workbook.open(@simple_file1, :excel => :new)
|
798
798
|
book2.excel.should_not == @book.excel
|
799
|
-
book3 =
|
799
|
+
book3 = Workbook.open(@simple_file1, :excel => :new)
|
800
800
|
book3.excel.should_not == book2.excel
|
801
801
|
book3.excel.should_not == @book.excel
|
802
802
|
book2.close
|
803
803
|
book3.close
|
804
804
|
@book.close
|
805
|
-
book4 =
|
805
|
+
book4 = Workbook.open(@simple_file1, :excel => book2.excel, :read_only => true)
|
806
806
|
book4.should be_alive
|
807
|
-
book4.should be_a
|
807
|
+
book4.should be_a Workbook
|
808
808
|
book4.excel.should == book2.excel
|
809
809
|
book4.ReadOnly.should be true
|
810
810
|
book4.should == book2
|
811
811
|
book4.close
|
812
|
-
book5 =
|
812
|
+
book5 = Workbook.open(@simple_file1, :excel => book2, :read_only => true)
|
813
813
|
book5.should be_alive
|
814
|
-
book5.should be_a
|
814
|
+
book5.should be_a Workbook
|
815
815
|
book5.excel.should == book2.excel
|
816
816
|
book5.ReadOnly.should be true
|
817
817
|
book5.should == book2
|
@@ -820,69 +820,69 @@ describe Book do
|
|
820
820
|
end
|
821
821
|
|
822
822
|
it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
|
823
|
-
book2 =
|
823
|
+
book2 = Workbook.open(@simple_file1, :excel => :new)
|
824
824
|
book2.excel.should_not == @book.excel
|
825
825
|
book2.close
|
826
826
|
@book.close
|
827
|
-
book4 =
|
827
|
+
book4 = Workbook.open(@simple_file1, :excel => book2, :read_only => true)
|
828
828
|
book4.should be_alive
|
829
|
-
book4.should be_a
|
829
|
+
book4.should be_a Workbook
|
830
830
|
book4.excel.should == book2.excel
|
831
831
|
book4.ReadOnly.should be true
|
832
832
|
book4.should == book2
|
833
833
|
book4.close
|
834
834
|
end
|
835
835
|
|
836
|
-
it "should raise an error if no Excel or
|
836
|
+
it "should raise an error if no Excel or Workbook is given" do
|
837
837
|
expect{
|
838
|
-
|
838
|
+
Workbook.open(@simple_file1, :excel => :b)
|
839
839
|
}.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
|
840
840
|
end
|
841
841
|
|
842
842
|
it "should do force_excel even if both force_ and default_excel is given" do
|
843
|
-
book2 =
|
843
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => @book.excel}, :force => {:excel => :new})
|
844
844
|
book2.should be_alive
|
845
|
-
book2.should be_a
|
845
|
+
book2.should be_a Workbook
|
846
846
|
book2.excel.should_not == @book.excel
|
847
847
|
book2.should_not == @book
|
848
848
|
end
|
849
849
|
|
850
850
|
it "should do default_excel if force_excel is nil" do
|
851
|
-
book2 =
|
851
|
+
book2 = Workbook.open(@another_simple_file, :excel => nil)
|
852
852
|
book2.should be_alive
|
853
|
-
book2.should be_a
|
853
|
+
book2.should be_a Workbook
|
854
854
|
book2.excel.should == @book.excel
|
855
855
|
end
|
856
856
|
|
857
857
|
it "should force_excel with :reuse" do
|
858
|
-
book2 =
|
858
|
+
book2 = Workbook.open(@different_file, :excel => :current)
|
859
859
|
book2.should be_alive
|
860
|
-
book2.should be_a
|
860
|
+
book2.should be_a Workbook
|
861
861
|
book2.excel.should == @book.excel
|
862
862
|
end
|
863
863
|
|
864
864
|
it "should force_excel with :reuse even if :default_excel says sth. else" do
|
865
|
-
book2 =
|
865
|
+
book2 = Workbook.open(@different_file, :excel => :current, :default => {:excel => :new})
|
866
866
|
book2.should be_alive
|
867
|
-
book2.should be_a
|
867
|
+
book2.should be_a Workbook
|
868
868
|
book2.excel.should == @book.excel
|
869
869
|
end
|
870
870
|
|
871
871
|
it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
872
872
|
excel2 = Excel.new(:reuse => false)
|
873
873
|
@book.excel.close
|
874
|
-
book2 =
|
874
|
+
book2 = Workbook.open(@simple_file1, :excel => :current, :default => {:excel => :new})
|
875
875
|
book2.should be_alive
|
876
|
-
book2.should be_a
|
876
|
+
book2.should be_a Workbook
|
877
877
|
book2.excel.should === excel2
|
878
878
|
end
|
879
879
|
|
880
880
|
it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
881
|
-
book2 =
|
881
|
+
book2 = Workbook.open(@different_file1, :excel => :new)
|
882
882
|
book2.excel.close
|
883
|
-
book3 =
|
883
|
+
book3 = Workbook.open(@different_file1, :excel => :current, :default => {:excel => :new})
|
884
884
|
book3.should be_alive
|
885
|
-
book3.should be_a
|
885
|
+
book3.should be_a Workbook
|
886
886
|
book3.excel.should == @book.excel
|
887
887
|
end
|
888
888
|
|
@@ -892,34 +892,34 @@ describe Book do
|
|
892
892
|
context "with :force_excel" do
|
893
893
|
|
894
894
|
before do
|
895
|
-
@book =
|
895
|
+
@book = Workbook.open(@simple_file1)
|
896
896
|
end
|
897
897
|
|
898
898
|
after do
|
899
899
|
@book.close rescue nil
|
900
900
|
end
|
901
901
|
|
902
|
-
it "should open in a given Excel provided as Excel,
|
903
|
-
book2 =
|
904
|
-
book3 =
|
905
|
-
book3 =
|
902
|
+
it "should open in a given Excel provided as Excel, Workbook, or WIN32OLE representing an Excel or Workbook" do
|
903
|
+
book2 = Workbook.open(@another_simple_file)
|
904
|
+
book3 = Workbook.open(@different_file)
|
905
|
+
book3 = Workbook.open(@simple_file1, :force_excel => book2.excel)
|
906
906
|
book3.excel.should === book2.excel
|
907
|
-
book4 =
|
907
|
+
book4 = Workbook.open(@simple_file1, :force_excel => @book)
|
908
908
|
book4.excel.should === @book.excel
|
909
909
|
book3.close
|
910
910
|
book4.close
|
911
|
-
book5 =
|
911
|
+
book5 = Workbook.open(@simple_file1, :force_excel => book2.ole_workbook)
|
912
912
|
book5.excel.should === book2.excel
|
913
913
|
win32ole_excel1 = WIN32OLE.connect(@book.ole_workbook.Fullname).Application
|
914
|
-
book6 =
|
914
|
+
book6 = Workbook.open(@simple_file1, :force_excel => win32ole_excel1)
|
915
915
|
book6.excel.should === @book.excel
|
916
916
|
end
|
917
917
|
|
918
918
|
|
919
919
|
it "should open in a new Excel" do
|
920
|
-
book2 =
|
920
|
+
book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
921
921
|
book2.should be_alive
|
922
|
-
book2.should be_a
|
922
|
+
book2.should be_a Workbook
|
923
923
|
book2.excel.should_not == @book.excel
|
924
924
|
book2.should_not == @book
|
925
925
|
@book.Readonly.should be false
|
@@ -928,22 +928,22 @@ describe Book do
|
|
928
928
|
end
|
929
929
|
|
930
930
|
it "should open in a given Excel, not provide identity transparency, because old book readonly, new book writable" do
|
931
|
-
book2 =
|
931
|
+
book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
932
932
|
book2.excel.should_not == @book.excel
|
933
|
-
book3 =
|
933
|
+
book3 = Workbook.open(@simple_file1, :force_excel => :new)
|
934
934
|
book3.excel.should_not == book2.excel
|
935
935
|
book3.excel.should_not == @book.excel
|
936
936
|
book2.close
|
937
|
-
book4 =
|
937
|
+
book4 = Workbook.open(@simple_file1, :force_excel => book2.excel)
|
938
938
|
book4.should be_alive
|
939
|
-
book4.should be_a
|
939
|
+
book4.should be_a Workbook
|
940
940
|
book4.excel.should == book2.excel
|
941
941
|
#book4.Readonly.should == false
|
942
942
|
book4.should_not == book2
|
943
943
|
book4.close
|
944
|
-
book5 =
|
944
|
+
book5 = Workbook.open(@simple_file1, :force_excel => book2)
|
945
945
|
book5.should be_alive
|
946
|
-
book5.should be_a
|
946
|
+
book5.should be_a Workbook
|
947
947
|
book5.excel.should == book2.excel
|
948
948
|
#book5.Readonly.should == false
|
949
949
|
book5.should_not == book2
|
@@ -952,24 +952,24 @@ describe Book do
|
|
952
952
|
end
|
953
953
|
|
954
954
|
it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
|
955
|
-
book2 =
|
955
|
+
book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
956
956
|
book2.excel.should_not == @book.excel
|
957
|
-
book3 =
|
957
|
+
book3 = Workbook.open(@simple_file1, :force_excel => :new)
|
958
958
|
book3.excel.should_not == book2.excel
|
959
959
|
book3.excel.should_not == @book.excel
|
960
960
|
book2.close
|
961
961
|
book3.close
|
962
962
|
@book.close
|
963
|
-
book4 =
|
963
|
+
book4 = Workbook.open(@simple_file1, :force_excel => book2.excel, :read_only => true)
|
964
964
|
book4.should be_alive
|
965
|
-
book4.should be_a
|
965
|
+
book4.should be_a Workbook
|
966
966
|
book4.excel.should == book2.excel
|
967
967
|
book4.ReadOnly.should be true
|
968
968
|
book4.should == book2
|
969
969
|
book4.close
|
970
|
-
book5 =
|
970
|
+
book5 = Workbook.open(@simple_file1, :force_excel => book2, :read_only => true)
|
971
971
|
book5.should be_alive
|
972
|
-
book5.should be_a
|
972
|
+
book5.should be_a Workbook
|
973
973
|
book5.excel.should == book2.excel
|
974
974
|
book5.ReadOnly.should be true
|
975
975
|
book5.should == book2
|
@@ -978,69 +978,69 @@ describe Book do
|
|
978
978
|
end
|
979
979
|
|
980
980
|
it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
|
981
|
-
book2 =
|
981
|
+
book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
982
982
|
book2.excel.should_not == @book.excel
|
983
983
|
book2.close
|
984
984
|
@book.close
|
985
|
-
book4 =
|
985
|
+
book4 = Workbook.open(@simple_file1, :force_excel => book2, :read_only => true)
|
986
986
|
book4.should be_alive
|
987
|
-
book4.should be_a
|
987
|
+
book4.should be_a Workbook
|
988
988
|
book4.excel.should == book2.excel
|
989
989
|
book4.ReadOnly.should be true
|
990
990
|
book4.should == book2
|
991
991
|
book4.close
|
992
992
|
end
|
993
993
|
|
994
|
-
it "should raise an error if no Excel or
|
994
|
+
it "should raise an error if no Excel or Workbook is given" do
|
995
995
|
expect{
|
996
|
-
|
996
|
+
Workbook.open(@simple_file1, :force_excel => :b)
|
997
997
|
}.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
|
998
998
|
end
|
999
999
|
|
1000
1000
|
it "should do force_excel even if both force_ and default_excel is given" do
|
1001
|
-
book2 =
|
1001
|
+
book2 = Workbook.open(@simple_file1, :default_excel => @book.excel, :force_excel => :new)
|
1002
1002
|
book2.should be_alive
|
1003
|
-
book2.should be_a
|
1003
|
+
book2.should be_a Workbook
|
1004
1004
|
book2.excel.should_not == @book.excel
|
1005
1005
|
book2.should_not == @book
|
1006
1006
|
end
|
1007
1007
|
|
1008
1008
|
it "should do default_excel if force_excel is nil" do
|
1009
|
-
book2 =
|
1009
|
+
book2 = Workbook.open(@another_simple_file, :force_excel => nil)
|
1010
1010
|
book2.should be_alive
|
1011
|
-
book2.should be_a
|
1011
|
+
book2.should be_a Workbook
|
1012
1012
|
book2.excel.should == @book.excel
|
1013
1013
|
end
|
1014
1014
|
|
1015
1015
|
it "should force_excel with :reuse" do
|
1016
|
-
book2 =
|
1016
|
+
book2 = Workbook.open(@different_file, :force_excel => :current)
|
1017
1017
|
book2.should be_alive
|
1018
|
-
book2.should be_a
|
1018
|
+
book2.should be_a Workbook
|
1019
1019
|
book2.excel.should == @book.excel
|
1020
1020
|
end
|
1021
1021
|
|
1022
1022
|
it "should force_excel with :reuse even if :default_excel says sth. else" do
|
1023
|
-
book2 =
|
1023
|
+
book2 = Workbook.open(@different_file, :force_excel => :current, :default_excel => :new)
|
1024
1024
|
book2.should be_alive
|
1025
|
-
book2.should be_a
|
1025
|
+
book2.should be_a Workbook
|
1026
1026
|
book2.excel.should == @book.excel
|
1027
1027
|
end
|
1028
1028
|
|
1029
1029
|
it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
1030
1030
|
excel2 = Excel.new(:reuse => false)
|
1031
1031
|
@book.excel.close
|
1032
|
-
book2 =
|
1032
|
+
book2 = Workbook.open(@simple_file1, :force_excel => :current, :default_excel => :new)
|
1033
1033
|
book2.should be_alive
|
1034
|
-
book2.should be_a
|
1034
|
+
book2.should be_a Workbook
|
1035
1035
|
book2.excel.should === excel2
|
1036
1036
|
end
|
1037
1037
|
|
1038
1038
|
it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
1039
|
-
book2 =
|
1039
|
+
book2 = Workbook.open(@different_file1, :force_excel => :new)
|
1040
1040
|
book2.excel.close
|
1041
|
-
book3 =
|
1041
|
+
book3 = Workbook.open(@different_file1, :force_excel => :current, :default_excel => :new)
|
1042
1042
|
book3.should be_alive
|
1043
|
-
book3.should be_a
|
1043
|
+
book3.should be_a Workbook
|
1044
1044
|
book3.excel.should == @book.excel
|
1045
1045
|
end
|
1046
1046
|
|
@@ -1049,7 +1049,7 @@ describe Book do
|
|
1049
1049
|
context "with :default => {:excel}" do
|
1050
1050
|
|
1051
1051
|
before do
|
1052
|
-
@book =
|
1052
|
+
@book = Workbook.open(@simple_file1, :visible => true)
|
1053
1053
|
end
|
1054
1054
|
|
1055
1055
|
after do
|
@@ -1059,62 +1059,62 @@ describe Book do
|
|
1059
1059
|
context "with :default => {:excel => :reserved_new}" do
|
1060
1060
|
|
1061
1061
|
it "should open in the reserved Excel instance" do
|
1062
|
-
book3 =
|
1062
|
+
book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
|
1063
1063
|
book3.excel.should_not == @book.excel
|
1064
1064
|
end
|
1065
1065
|
|
1066
1066
|
it "should open in separate Excel instances" do
|
1067
1067
|
Excel.kill_all
|
1068
1068
|
sleep 1
|
1069
|
-
book2 =
|
1070
|
-
book3 =
|
1069
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
|
1070
|
+
book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
|
1071
1071
|
book2.excel.should_not == book3.excel
|
1072
|
-
book4 =
|
1072
|
+
book4 = Workbook.open(@another_simple_file1, :default => {:excel => :current})
|
1073
1073
|
book4.excel.should_not == book2.excel
|
1074
1074
|
book4.excel.should_not == book3.excel
|
1075
1075
|
end
|
1076
1076
|
|
1077
1077
|
it "should use the open book" do
|
1078
|
-
book2 =
|
1078
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
|
1079
1079
|
book2.excel.should == @book.excel
|
1080
1080
|
book2.should be_alive
|
1081
|
-
book2.should be_a
|
1081
|
+
book2.should be_a Workbook
|
1082
1082
|
book2.should == @book
|
1083
1083
|
book2.close
|
1084
1084
|
end
|
1085
1085
|
|
1086
1086
|
it "should open in the old Excel instance" do
|
1087
1087
|
@book.close
|
1088
|
-
book2 =
|
1088
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
|
1089
1089
|
book2.should be_alive
|
1090
|
-
book2.should be_a
|
1090
|
+
book2.should be_a Workbook
|
1091
1091
|
book2.should == @book
|
1092
1092
|
book2.excel.should == @book.excel
|
1093
1093
|
end
|
1094
1094
|
|
1095
1095
|
it "should open one book in the reserved Excel instance" do
|
1096
|
-
book3 =
|
1096
|
+
book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
|
1097
1097
|
@book.close
|
1098
|
-
book2 =
|
1098
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
|
1099
1099
|
book2.excel.should_not == book3.excel
|
1100
1100
|
end
|
1101
1101
|
|
1102
1102
|
it "should not use the reserved Excel instance" do
|
1103
|
-
book3 =
|
1103
|
+
book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
|
1104
1104
|
@book.close
|
1105
|
-
book2 =
|
1105
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :new})
|
1106
1106
|
book2.excel.should_not == book3.excel
|
1107
1107
|
end
|
1108
1108
|
|
1109
1109
|
it "should not reopen in the reserved Excel instance" do
|
1110
|
-
book3 =
|
1110
|
+
book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
|
1111
1111
|
@book.close
|
1112
1112
|
@book.reopen
|
1113
1113
|
@book.excel.should_not == book3.excel
|
1114
1114
|
end
|
1115
1115
|
|
1116
1116
|
it "should reopen in the reserved Excel instance" do
|
1117
|
-
book3 =
|
1117
|
+
book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
|
1118
1118
|
@book.close
|
1119
1119
|
book3.close
|
1120
1120
|
@book.reopen
|
@@ -1125,10 +1125,10 @@ describe Book do
|
|
1125
1125
|
it "should not reopen in the reserved Excel instance when opened the reserved Excel instance first" do
|
1126
1126
|
Excel.kill_all
|
1127
1127
|
sleep 1
|
1128
|
-
book1 =
|
1129
|
-
book2 =
|
1128
|
+
book1 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
|
1129
|
+
book2 = Workbook.open(@different_file1, :default => {:excel => :new})
|
1130
1130
|
book2.excel.should_not == book1.excel
|
1131
|
-
book3 =
|
1131
|
+
book3 = Workbook.open(@another_simple_file1, :default => {:excel => :current})
|
1132
1132
|
book3.excel.should_not == book1.excel
|
1133
1133
|
book2.close
|
1134
1134
|
book2.reopen
|
@@ -1143,8 +1143,8 @@ describe Book do
|
|
1143
1143
|
end
|
1144
1144
|
|
1145
1145
|
it "should open several workbooks in the reserved Excel instance" do
|
1146
|
-
book2 =
|
1147
|
-
book3 =
|
1146
|
+
book2 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
|
1147
|
+
book3 = Workbook.open(@another_simple_file1, :default => {:excel => :reserved_new})
|
1148
1148
|
book2.excel.should_not == @book.excel
|
1149
1149
|
book3.excel.should_not == @book.excel
|
1150
1150
|
book2.excel.should_not == book3.excel
|
@@ -1152,9 +1152,9 @@ describe Book do
|
|
1152
1152
|
|
1153
1153
|
it "should open several workbooks in the reserved Excel instance" do
|
1154
1154
|
Excel.kill_all
|
1155
|
-
book1 =
|
1156
|
-
book2 =
|
1157
|
-
book3 =
|
1155
|
+
book1 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
|
1156
|
+
book2 = Workbook.open(@different_file1, :default => {:excel => :current})
|
1157
|
+
book3 = Workbook.open(@another_simple_file1, :default => {:excel => :current})
|
1158
1158
|
book2.excel.should_not == book1.excel
|
1159
1159
|
book3.excel.should_not == book1.excel
|
1160
1160
|
book2.excel.should == book3.excel
|
@@ -1165,10 +1165,10 @@ describe Book do
|
|
1165
1165
|
context "with :default => {:excel => :current}" do
|
1166
1166
|
|
1167
1167
|
it "should use the open book" do
|
1168
|
-
book2 =
|
1168
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :current})
|
1169
1169
|
book2.excel.should == @book.excel
|
1170
1170
|
book2.should be_alive
|
1171
|
-
book2.should be_a
|
1171
|
+
book2.should be_a Workbook
|
1172
1172
|
book2.should == @book
|
1173
1173
|
book2.close
|
1174
1174
|
end
|
@@ -1176,9 +1176,9 @@ describe Book do
|
|
1176
1176
|
it "should reopen the book in the excel instance where it was opened before" do
|
1177
1177
|
excel = Excel.new(:reuse => false)
|
1178
1178
|
@book.close
|
1179
|
-
book2 =
|
1179
|
+
book2 = Workbook.open(@simple_file1)
|
1180
1180
|
book2.should be_alive
|
1181
|
-
book2.should be_a
|
1181
|
+
book2.should be_a Workbook
|
1182
1182
|
book2.excel.should == @book.excel
|
1183
1183
|
book2.excel.should_not == excel
|
1184
1184
|
book2.filename.should == @book.filename
|
@@ -1193,9 +1193,9 @@ describe Book do
|
|
1193
1193
|
fn = @book.filename
|
1194
1194
|
@book.close
|
1195
1195
|
Excel.close_all
|
1196
|
-
book2 =
|
1196
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :current})
|
1197
1197
|
book2.should be_alive
|
1198
|
-
book2.should be_a
|
1198
|
+
book2.should be_a Workbook
|
1199
1199
|
book2.filename.should == fn
|
1200
1200
|
@book.should be_alive
|
1201
1201
|
book2.should == @book
|
@@ -1207,9 +1207,9 @@ describe Book do
|
|
1207
1207
|
Excel.close_all
|
1208
1208
|
new_excel = Excel.new(:reuse => false)
|
1209
1209
|
new_excel2 = Excel.new(:reuse => false)
|
1210
|
-
book2 =
|
1210
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :current})
|
1211
1211
|
book2.should be_alive
|
1212
|
-
book2.should be_a
|
1212
|
+
book2.should be_a Workbook
|
1213
1213
|
book2.excel.should_not == excel
|
1214
1214
|
book2.excel.should_not == new_excel2
|
1215
1215
|
book2.excel.should == new_excel
|
@@ -1223,9 +1223,9 @@ describe Book do
|
|
1223
1223
|
Excel.close_all
|
1224
1224
|
excel1 = Excel.new(:reuse => false)
|
1225
1225
|
excel2 = Excel.new(:reuse => false)
|
1226
|
-
book2 =
|
1226
|
+
book2 = Workbook.open(@different_file, :default => {:excel => :current})
|
1227
1227
|
book2.should be_alive
|
1228
|
-
book2.should be_a
|
1228
|
+
book2.should be_a Workbook
|
1229
1229
|
book2.excel.should == excel1
|
1230
1230
|
book2.excel.should_not == excel2
|
1231
1231
|
book2.close
|
@@ -1235,12 +1235,12 @@ describe Book do
|
|
1235
1235
|
excel1 = @book.excel
|
1236
1236
|
excel2 = Excel.new(:reuse => false)
|
1237
1237
|
@book.close
|
1238
|
-
book2 =
|
1238
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :current})
|
1239
1239
|
book2.excel.should == excel1
|
1240
1240
|
book2.close
|
1241
|
-
book3 =
|
1241
|
+
book3 = Workbook.open(@simple_file1, :force => {:excel => excel2})
|
1242
1242
|
book3.close
|
1243
|
-
book3 =
|
1243
|
+
book3 = Workbook.open(@simple_file1, :default => {:excel => :current})
|
1244
1244
|
book3.excel.should == excel2
|
1245
1245
|
book3.close
|
1246
1246
|
end
|
@@ -1250,12 +1250,12 @@ describe Book do
|
|
1250
1250
|
context "with :default => {:excel => :new}" do
|
1251
1251
|
|
1252
1252
|
it "should reopen a book in the excel instance where it was opened most recently" do
|
1253
|
-
book2 =
|
1253
|
+
book2 = Workbook.open(@simple_file, :force => {:excel => :new})
|
1254
1254
|
@book.close
|
1255
1255
|
book2.close
|
1256
|
-
book3 =
|
1256
|
+
book3 = Workbook.open(@simple_file1)
|
1257
1257
|
book2.should be_alive
|
1258
|
-
book2.should be_a
|
1258
|
+
book2.should be_a Workbook
|
1259
1259
|
book3.excel.should == book2.excel
|
1260
1260
|
book3.excel.should_not == @book.excel
|
1261
1261
|
book3.should == book2
|
@@ -1263,9 +1263,9 @@ describe Book do
|
|
1263
1263
|
end
|
1264
1264
|
|
1265
1265
|
it "should open the book in a new excel if the book was not opened before" do
|
1266
|
-
book2 =
|
1266
|
+
book2 = Workbook.open(@different_file, :default => {:excel => :current})
|
1267
1267
|
book2.excel.should == @book.excel
|
1268
|
-
book3 =
|
1268
|
+
book3 = Workbook.open(@another_simple_file, :default => {:excel => :new})
|
1269
1269
|
book3.excel.should_not == @book.excel
|
1270
1270
|
end
|
1271
1271
|
|
@@ -1273,7 +1273,7 @@ describe Book do
|
|
1273
1273
|
excel = @book.excel
|
1274
1274
|
excel2 = Excel.new(:reuse => false)
|
1275
1275
|
excel.close
|
1276
|
-
book2 =
|
1276
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :new})
|
1277
1277
|
book2.excel.should_not == excel2
|
1278
1278
|
book2.close
|
1279
1279
|
end
|
@@ -1283,26 +1283,26 @@ describe Book do
|
|
1283
1283
|
context "with :default => {:excel => <excel-instance>}" do
|
1284
1284
|
|
1285
1285
|
it "should open the book in a given excel if the book was not opened before" do
|
1286
|
-
book2 =
|
1286
|
+
book2 = Workbook.open(@different_file, :default => {:excel => :current})
|
1287
1287
|
book2.excel.should == @book.excel
|
1288
1288
|
excel = Excel.new(:reuse => false)
|
1289
|
-
book3 =
|
1289
|
+
book3 = Workbook.open(@another_simple_file, :default => {:excel => excel})
|
1290
1290
|
book3.excel.should == excel
|
1291
1291
|
end
|
1292
1292
|
|
1293
1293
|
it "should open the book in a given excel if the book was opened before but the excel has been closed" do
|
1294
1294
|
excel2 = Excel.new(:reuse => false, :visible => true)
|
1295
1295
|
@book.excel.close
|
1296
|
-
book2 =
|
1296
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => excel2, :visible => true})
|
1297
1297
|
book2.excel.should == excel2
|
1298
1298
|
end
|
1299
1299
|
|
1300
1300
|
it "should open a new excel, if the book cannot be reopened" do
|
1301
1301
|
@book.close
|
1302
1302
|
new_excel = Excel.new(:reuse => false)
|
1303
|
-
book2 =
|
1303
|
+
book2 = Workbook.open(@different_file, :default => {:excel => :new})
|
1304
1304
|
book2.should be_alive
|
1305
|
-
book2.should be_a
|
1305
|
+
book2.should be_a Workbook
|
1306
1306
|
book2.excel.should_not == new_excel
|
1307
1307
|
book2.excel.should_not == @book.excel
|
1308
1308
|
book2.close
|
@@ -1311,9 +1311,9 @@ describe Book do
|
|
1311
1311
|
it "should open a given excel, if the book cannot be reopened" do
|
1312
1312
|
@book.close
|
1313
1313
|
new_excel = Excel.new(:reuse => false)
|
1314
|
-
book2 =
|
1314
|
+
book2 = Workbook.open(@different_file, :default => {:excel => @book.excel})
|
1315
1315
|
book2.should be_alive
|
1316
|
-
book2.should be_a
|
1316
|
+
book2.should be_a Workbook
|
1317
1317
|
book2.excel.should_not == new_excel
|
1318
1318
|
book2.excel.should == @book.excel
|
1319
1319
|
book2.close
|
@@ -1322,9 +1322,9 @@ describe Book do
|
|
1322
1322
|
it "should open a given excel, if the book cannot be reopened" do
|
1323
1323
|
@book.close
|
1324
1324
|
new_excel = Excel.new(:reuse => false)
|
1325
|
-
book2 =
|
1325
|
+
book2 = Workbook.open(@different_file, :default => {:excel => @book})
|
1326
1326
|
book2.should be_alive
|
1327
|
-
book2.should be_a
|
1327
|
+
book2.should be_a Workbook
|
1328
1328
|
book2.excel.should_not == new_excel
|
1329
1329
|
book2.excel.should == @book.excel
|
1330
1330
|
book2.close
|
@@ -1333,14 +1333,14 @@ describe Book do
|
|
1333
1333
|
end
|
1334
1334
|
|
1335
1335
|
it "should reuse an open book by default" do
|
1336
|
-
book2 =
|
1336
|
+
book2 = Workbook.open(@simple_file1)
|
1337
1337
|
book2.excel.should == @book.excel
|
1338
1338
|
book2.should == @book
|
1339
1339
|
end
|
1340
1340
|
|
1341
|
-
it "should raise an error if no Excel or
|
1341
|
+
it "should raise an error if no Excel or Workbook is given" do
|
1342
1342
|
expect{
|
1343
|
-
|
1343
|
+
Workbook.open(@different_file, :default => {:excel => :a})
|
1344
1344
|
}.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
|
1345
1345
|
end
|
1346
1346
|
|
@@ -1349,7 +1349,7 @@ describe Book do
|
|
1349
1349
|
context "with :default_excel" do
|
1350
1350
|
|
1351
1351
|
before do
|
1352
|
-
@book =
|
1352
|
+
@book = Workbook.open(@simple_file1, :visible => true)
|
1353
1353
|
end
|
1354
1354
|
|
1355
1355
|
after do
|
@@ -1357,10 +1357,10 @@ describe Book do
|
|
1357
1357
|
end
|
1358
1358
|
|
1359
1359
|
it "should use the open book" do
|
1360
|
-
book2 =
|
1360
|
+
book2 = Workbook.open(@simple_file1, :default_excel => :current)
|
1361
1361
|
book2.excel.should == @book.excel
|
1362
1362
|
book2.should be_alive
|
1363
|
-
book2.should be_a
|
1363
|
+
book2.should be_a Workbook
|
1364
1364
|
book2.should == @book
|
1365
1365
|
book2.close
|
1366
1366
|
end
|
@@ -1368,9 +1368,9 @@ describe Book do
|
|
1368
1368
|
it "should reopen the book in the excel instance where it was opened before" do
|
1369
1369
|
excel = Excel.new(:reuse => false)
|
1370
1370
|
@book.close
|
1371
|
-
book2 =
|
1371
|
+
book2 = Workbook.open(@simple_file1)
|
1372
1372
|
book2.should be_alive
|
1373
|
-
book2.should be_a
|
1373
|
+
book2.should be_a Workbook
|
1374
1374
|
book2.excel.should == @book.excel
|
1375
1375
|
book2.excel.should_not == excel
|
1376
1376
|
book2.filename.should == @book.filename
|
@@ -1385,9 +1385,9 @@ describe Book do
|
|
1385
1385
|
fn = @book.filename
|
1386
1386
|
@book.close
|
1387
1387
|
Excel.close_all
|
1388
|
-
book2 =
|
1388
|
+
book2 = Workbook.open(@simple_file1, :default_excel => :current)
|
1389
1389
|
book2.should be_alive
|
1390
|
-
book2.should be_a
|
1390
|
+
book2.should be_a Workbook
|
1391
1391
|
book2.filename.should == fn
|
1392
1392
|
@book.should be_alive
|
1393
1393
|
book2.should == @book
|
@@ -1399,9 +1399,9 @@ describe Book do
|
|
1399
1399
|
Excel.close_all
|
1400
1400
|
new_excel = Excel.new(:reuse => false)
|
1401
1401
|
new_excel2 = Excel.new(:reuse => false)
|
1402
|
-
book2 =
|
1402
|
+
book2 = Workbook.open(@simple_file1, :default_excel => :current)
|
1403
1403
|
book2.should be_alive
|
1404
|
-
book2.should be_a
|
1404
|
+
book2.should be_a Workbook
|
1405
1405
|
book2.excel.should_not == excel
|
1406
1406
|
book2.excel.should_not == new_excel2
|
1407
1407
|
book2.excel.should == new_excel
|
@@ -1415,9 +1415,9 @@ describe Book do
|
|
1415
1415
|
Excel.close_all
|
1416
1416
|
excel1 = Excel.new(:reuse => false)
|
1417
1417
|
excel2 = Excel.new(:reuse => false)
|
1418
|
-
book2 =
|
1418
|
+
book2 = Workbook.open(@different_file, :default_excel => :current)
|
1419
1419
|
book2.should be_alive
|
1420
|
-
book2.should be_a
|
1420
|
+
book2.should be_a Workbook
|
1421
1421
|
book2.excel.should == excel1
|
1422
1422
|
book2.excel.should_not == excel2
|
1423
1423
|
book2.close
|
@@ -1427,23 +1427,23 @@ describe Book do
|
|
1427
1427
|
excel1 = @book.excel
|
1428
1428
|
excel2 = Excel.new(:reuse => false)
|
1429
1429
|
@book.close
|
1430
|
-
book2 =
|
1430
|
+
book2 = Workbook.open(@simple_file1, :default_excel => :current)
|
1431
1431
|
book2.excel.should == excel1
|
1432
1432
|
book2.close
|
1433
|
-
book3 =
|
1433
|
+
book3 = Workbook.open(@simple_file1, :force_excel => excel2)
|
1434
1434
|
book3.close
|
1435
|
-
book3 =
|
1435
|
+
book3 = Workbook.open(@simple_file1, :default_excel => :current)
|
1436
1436
|
book3.excel.should == excel2
|
1437
1437
|
book3.close
|
1438
1438
|
end
|
1439
1439
|
|
1440
1440
|
it "should reopen a book in the excel instance where it was opened most recently" do
|
1441
|
-
book2 =
|
1441
|
+
book2 = Workbook.open(@simple_file, :force_excel => :new)
|
1442
1442
|
@book.close
|
1443
1443
|
book2.close
|
1444
|
-
book3 =
|
1444
|
+
book3 = Workbook.open(@simple_file1)
|
1445
1445
|
book2.should be_alive
|
1446
|
-
book2.should be_a
|
1446
|
+
book2.should be_a Workbook
|
1447
1447
|
book3.excel.should == book2.excel
|
1448
1448
|
book3.excel.should_not == @book.excel
|
1449
1449
|
book3.should == book2
|
@@ -1451,9 +1451,9 @@ describe Book do
|
|
1451
1451
|
end
|
1452
1452
|
|
1453
1453
|
it "should open the book in a new excel if the book was not opened before" do
|
1454
|
-
book2 =
|
1454
|
+
book2 = Workbook.open(@different_file, :default_excel => :current)
|
1455
1455
|
book2.excel.should == @book.excel
|
1456
|
-
book3 =
|
1456
|
+
book3 = Workbook.open(@another_simple_file, :default_excel => :new)
|
1457
1457
|
book3.excel.should_not == @book.excel
|
1458
1458
|
end
|
1459
1459
|
|
@@ -1461,32 +1461,32 @@ describe Book do
|
|
1461
1461
|
excel = @book.excel
|
1462
1462
|
excel2 = Excel.new(:reuse => false)
|
1463
1463
|
excel.close
|
1464
|
-
book2 =
|
1464
|
+
book2 = Workbook.open(@simple_file1, :default_excel => :new)
|
1465
1465
|
book2.excel.should_not == excel2
|
1466
1466
|
book2.close
|
1467
1467
|
end
|
1468
1468
|
|
1469
1469
|
it "should open the book in a given excel if the book was not opened before" do
|
1470
|
-
book2 =
|
1470
|
+
book2 = Workbook.open(@different_file, :default_excel => :current)
|
1471
1471
|
book2.excel.should == @book.excel
|
1472
1472
|
excel = Excel.new(:reuse => false)
|
1473
|
-
book3 =
|
1473
|
+
book3 = Workbook.open(@another_simple_file, :default_excel => excel)
|
1474
1474
|
book3.excel.should == excel
|
1475
1475
|
end
|
1476
1476
|
|
1477
1477
|
it "should open the book in a given excel if the book was opened before but the excel has been closed" do
|
1478
1478
|
excel2 = Excel.new(:reuse => false, :visible => true)
|
1479
1479
|
@book.excel.close
|
1480
|
-
book2 =
|
1480
|
+
book2 = Workbook.open(@simple_file1, :visible => true, :default_excel => excel2)
|
1481
1481
|
book2.excel.should == excel2
|
1482
1482
|
end
|
1483
1483
|
|
1484
1484
|
it "should open a new excel, if the book cannot be reopened" do
|
1485
1485
|
@book.close
|
1486
1486
|
new_excel = Excel.new(:reuse => false)
|
1487
|
-
book2 =
|
1487
|
+
book2 = Workbook.open(@different_file, :default_excel => :new)
|
1488
1488
|
book2.should be_alive
|
1489
|
-
book2.should be_a
|
1489
|
+
book2.should be_a Workbook
|
1490
1490
|
book2.excel.should_not == new_excel
|
1491
1491
|
book2.excel.should_not == @book.excel
|
1492
1492
|
book2.close
|
@@ -1495,9 +1495,9 @@ describe Book do
|
|
1495
1495
|
it "should open a given excel, if the book cannot be reopened" do
|
1496
1496
|
@book.close
|
1497
1497
|
new_excel = Excel.new(:reuse => false)
|
1498
|
-
book2 =
|
1498
|
+
book2 = Workbook.open(@different_file, :default_excel => @book.excel)
|
1499
1499
|
book2.should be_alive
|
1500
|
-
book2.should be_a
|
1500
|
+
book2.should be_a Workbook
|
1501
1501
|
book2.excel.should_not == new_excel
|
1502
1502
|
book2.excel.should == @book.excel
|
1503
1503
|
book2.close
|
@@ -1506,23 +1506,23 @@ describe Book do
|
|
1506
1506
|
it "should open a given excel, if the book cannot be reopened" do
|
1507
1507
|
@book.close
|
1508
1508
|
new_excel = Excel.new(:reuse => false)
|
1509
|
-
book2 =
|
1509
|
+
book2 = Workbook.open(@different_file, :default_excel => @book)
|
1510
1510
|
book2.should be_alive
|
1511
|
-
book2.should be_a
|
1511
|
+
book2.should be_a Workbook
|
1512
1512
|
book2.excel.should_not == new_excel
|
1513
1513
|
book2.excel.should == @book.excel
|
1514
1514
|
book2.close
|
1515
1515
|
end
|
1516
1516
|
|
1517
1517
|
it "should reuse an open book by default" do
|
1518
|
-
book2 =
|
1518
|
+
book2 = Workbook.open(@simple_file1)
|
1519
1519
|
book2.excel.should == @book.excel
|
1520
1520
|
book2.should == @book
|
1521
1521
|
end
|
1522
1522
|
|
1523
|
-
it "should raise an error if no Excel or
|
1523
|
+
it "should raise an error if no Excel or Workbook is given" do
|
1524
1524
|
expect{
|
1525
|
-
|
1525
|
+
Workbook.open(@different_file, :default_excel => :a)
|
1526
1526
|
}.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
|
1527
1527
|
end
|
1528
1528
|
|
@@ -1531,7 +1531,7 @@ describe Book do
|
|
1531
1531
|
context "with :active instead of :current" do
|
1532
1532
|
|
1533
1533
|
before do
|
1534
|
-
@book =
|
1534
|
+
@book = Workbook.open(@simple_file1)
|
1535
1535
|
end
|
1536
1536
|
|
1537
1537
|
after do
|
@@ -1539,42 +1539,42 @@ describe Book do
|
|
1539
1539
|
end
|
1540
1540
|
|
1541
1541
|
it "should force_excel with :active" do
|
1542
|
-
book2 =
|
1542
|
+
book2 = Workbook.open(@different_file, :force => {:excel => :active})
|
1543
1543
|
book2.should be_alive
|
1544
|
-
book2.should be_a
|
1544
|
+
book2.should be_a Workbook
|
1545
1545
|
book2.excel.should == @book.excel
|
1546
1546
|
end
|
1547
1547
|
|
1548
1548
|
it "should force_excel with :reuse even if :default_excel says sth. else" do
|
1549
|
-
book2 =
|
1549
|
+
book2 = Workbook.open(@different_file, :force => {:excel => :active}, :default => {:excel => :new})
|
1550
1550
|
book2.should be_alive
|
1551
|
-
book2.should be_a
|
1551
|
+
book2.should be_a Workbook
|
1552
1552
|
book2.excel.should == @book.excel
|
1553
1553
|
end
|
1554
1554
|
|
1555
1555
|
it "should open force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
1556
1556
|
excel2 = Excel.new(:reuse => false)
|
1557
1557
|
@book.excel.close
|
1558
|
-
book2 =
|
1558
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :active}, :default => {:excel => :new})
|
1559
1559
|
book2.should be_alive
|
1560
|
-
book2.should be_a
|
1560
|
+
book2.should be_a Workbook
|
1561
1561
|
book2.excel.should === excel2
|
1562
1562
|
end
|
1563
1563
|
|
1564
1564
|
it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
1565
|
-
book2 =
|
1565
|
+
book2 = Workbook.open(@different_file1, :force => {:excel => :new})
|
1566
1566
|
book2.excel.close
|
1567
|
-
book3 =
|
1567
|
+
book3 = Workbook.open(@different_file1, :force => {:excel => :active}, :default => {:excel => :new})
|
1568
1568
|
book3.should be_alive
|
1569
|
-
book3.should be_a
|
1569
|
+
book3.should be_a Workbook
|
1570
1570
|
book3.excel.should == @book.excel
|
1571
1571
|
end
|
1572
1572
|
|
1573
1573
|
it "should use the open book" do
|
1574
|
-
book2 =
|
1574
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :active})
|
1575
1575
|
book2.excel.should == @book.excel
|
1576
1576
|
book2.should be_alive
|
1577
|
-
book2.should be_a
|
1577
|
+
book2.should be_a Workbook
|
1578
1578
|
book2.should == @book
|
1579
1579
|
book2.close
|
1580
1580
|
end
|
@@ -1585,9 +1585,9 @@ describe Book do
|
|
1585
1585
|
fn = @book.filename
|
1586
1586
|
@book.close
|
1587
1587
|
Excel.close_all
|
1588
|
-
book2 =
|
1588
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :active})
|
1589
1589
|
book2.should be_alive
|
1590
|
-
book2.should be_a
|
1590
|
+
book2.should be_a Workbook
|
1591
1591
|
book2.filename.should == fn
|
1592
1592
|
@book.should be_alive
|
1593
1593
|
book2.should == @book
|
@@ -1599,9 +1599,9 @@ describe Book do
|
|
1599
1599
|
Excel.close_all
|
1600
1600
|
new_excel = Excel.new(:reuse => false)
|
1601
1601
|
new_excel2 = Excel.new(:reuse => false)
|
1602
|
-
book2 =
|
1602
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :active})
|
1603
1603
|
book2.should be_alive
|
1604
|
-
book2.should be_a
|
1604
|
+
book2.should be_a Workbook
|
1605
1605
|
book2.excel.should_not == excel
|
1606
1606
|
book2.excel.should_not == new_excel2
|
1607
1607
|
book2.excel.should == new_excel
|
@@ -1615,9 +1615,9 @@ describe Book do
|
|
1615
1615
|
Excel.close_all
|
1616
1616
|
excel1 = Excel.new(:reuse => false)
|
1617
1617
|
excel2 = Excel.new(:reuse => false)
|
1618
|
-
book2 =
|
1618
|
+
book2 = Workbook.open(@different_file, :default => {:excel => :active})
|
1619
1619
|
book2.should be_alive
|
1620
|
-
book2.should be_a
|
1620
|
+
book2.should be_a Workbook
|
1621
1621
|
book2.excel.should == excel1
|
1622
1622
|
book2.excel.should_not == excel2
|
1623
1623
|
book2.close
|
@@ -1627,12 +1627,12 @@ describe Book do
|
|
1627
1627
|
excel1 = @book.excel
|
1628
1628
|
excel2 = Excel.new(:reuse => false)
|
1629
1629
|
@book.close
|
1630
|
-
book2 =
|
1630
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :active})
|
1631
1631
|
book2.excel.should == excel1
|
1632
1632
|
book2.close
|
1633
|
-
book3 =
|
1633
|
+
book3 = Workbook.open(@simple_file1, :force => {:excel => excel2})
|
1634
1634
|
book3.close
|
1635
|
-
book3 =
|
1635
|
+
book3 = Workbook.open(@simple_file1, :default => {:excel => :active})
|
1636
1636
|
book3.excel.should == excel2
|
1637
1637
|
book3.close
|
1638
1638
|
end
|
@@ -1642,7 +1642,7 @@ describe Book do
|
|
1642
1642
|
context "with :reuse instead of :current" do
|
1643
1643
|
|
1644
1644
|
before do
|
1645
|
-
@book =
|
1645
|
+
@book = Workbook.open(@simple_file1)
|
1646
1646
|
end
|
1647
1647
|
|
1648
1648
|
after do
|
@@ -1650,42 +1650,42 @@ describe Book do
|
|
1650
1650
|
end
|
1651
1651
|
|
1652
1652
|
it "should force_excel with :reuse" do
|
1653
|
-
book2 =
|
1653
|
+
book2 = Workbook.open(@different_file, :force => {:excel => :reuse})
|
1654
1654
|
book2.should be_alive
|
1655
|
-
book2.should be_a
|
1655
|
+
book2.should be_a Workbook
|
1656
1656
|
book2.excel.should == @book.excel
|
1657
1657
|
end
|
1658
1658
|
|
1659
1659
|
it "should force_excel with :reuse even if :default_excel says sth. else" do
|
1660
|
-
book2 =
|
1660
|
+
book2 = Workbook.open(@different_file, :force => {:excel => :reuse}, :default => {:excel => :new})
|
1661
1661
|
book2.should be_alive
|
1662
|
-
book2.should be_a
|
1662
|
+
book2.should be_a Workbook
|
1663
1663
|
book2.excel.should == @book.excel
|
1664
1664
|
end
|
1665
1665
|
|
1666
1666
|
it "should open force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
1667
1667
|
excel2 = Excel.new(:reuse => false)
|
1668
1668
|
@book.excel.close
|
1669
|
-
book2 =
|
1669
|
+
book2 = Workbook.open(@simple_file1, :force => {:excel => :reuse}, :default => {:excel => :new})
|
1670
1670
|
book2.should be_alive
|
1671
|
-
book2.should be_a
|
1671
|
+
book2.should be_a Workbook
|
1672
1672
|
book2.excel.should === excel2
|
1673
1673
|
end
|
1674
1674
|
|
1675
1675
|
it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
|
1676
|
-
book2 =
|
1676
|
+
book2 = Workbook.open(@different_file1, :force => {:excel => :new})
|
1677
1677
|
book2.excel.close
|
1678
|
-
book3 =
|
1678
|
+
book3 = Workbook.open(@different_file1, :force => {:excel => :reuse}, :default => {:excel => :new})
|
1679
1679
|
book3.should be_alive
|
1680
|
-
book3.should be_a
|
1680
|
+
book3.should be_a Workbook
|
1681
1681
|
book3.excel.should == @book.excel
|
1682
1682
|
end
|
1683
1683
|
|
1684
1684
|
it "should use the open book" do
|
1685
|
-
book2 =
|
1685
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
|
1686
1686
|
book2.excel.should == @book.excel
|
1687
1687
|
book2.should be_alive
|
1688
|
-
book2.should be_a
|
1688
|
+
book2.should be_a Workbook
|
1689
1689
|
book2.should == @book
|
1690
1690
|
book2.close
|
1691
1691
|
end
|
@@ -1696,9 +1696,9 @@ describe Book do
|
|
1696
1696
|
fn = @book.filename
|
1697
1697
|
@book.close
|
1698
1698
|
Excel.close_all
|
1699
|
-
book2 =
|
1699
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
|
1700
1700
|
book2.should be_alive
|
1701
|
-
book2.should be_a
|
1701
|
+
book2.should be_a Workbook
|
1702
1702
|
book2.filename.should == fn
|
1703
1703
|
@book.should be_alive
|
1704
1704
|
book2.should == @book
|
@@ -1710,9 +1710,9 @@ describe Book do
|
|
1710
1710
|
Excel.close_all
|
1711
1711
|
new_excel = Excel.new(:reuse => false)
|
1712
1712
|
new_excel2 = Excel.new(:reuse => false)
|
1713
|
-
book2 =
|
1713
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
|
1714
1714
|
book2.should be_alive
|
1715
|
-
book2.should be_a
|
1715
|
+
book2.should be_a Workbook
|
1716
1716
|
book2.excel.should_not == excel
|
1717
1717
|
book2.excel.should_not == new_excel2
|
1718
1718
|
book2.excel.should == new_excel
|
@@ -1726,9 +1726,9 @@ describe Book do
|
|
1726
1726
|
Excel.close_all
|
1727
1727
|
excel1 = Excel.new(:reuse => false)
|
1728
1728
|
excel2 = Excel.new(:reuse => false)
|
1729
|
-
book2 =
|
1729
|
+
book2 = Workbook.open(@different_file, :default => {:excel => :reuse})
|
1730
1730
|
book2.should be_alive
|
1731
|
-
book2.should be_a
|
1731
|
+
book2.should be_a Workbook
|
1732
1732
|
book2.excel.should == excel1
|
1733
1733
|
book2.excel.should_not == excel2
|
1734
1734
|
book2.close
|
@@ -1738,12 +1738,12 @@ describe Book do
|
|
1738
1738
|
excel1 = @book.excel
|
1739
1739
|
excel2 = Excel.new(:reuse => false)
|
1740
1740
|
@book.close
|
1741
|
-
book2 =
|
1741
|
+
book2 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
|
1742
1742
|
book2.excel.should == excel1
|
1743
1743
|
book2.close
|
1744
|
-
book3 =
|
1744
|
+
book3 = Workbook.open(@simple_file1, :force => {:excel => excel2})
|
1745
1745
|
book3.close
|
1746
|
-
book3 =
|
1746
|
+
book3 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
|
1747
1747
|
book3.excel.should == excel2
|
1748
1748
|
book3.close
|
1749
1749
|
end
|
@@ -1751,16 +1751,16 @@ describe Book do
|
|
1751
1751
|
end
|
1752
1752
|
|
1753
1753
|
it "should new_excel" do
|
1754
|
-
book =
|
1754
|
+
book = Workbook.open(@simple_file1)
|
1755
1755
|
book.sheet(1)[1,1].Value = "f"
|
1756
1756
|
book.Saved.should be false
|
1757
|
-
book2 =
|
1757
|
+
book2 = Workbook.open(@simple_file1, :if_unsaved => :new_excel)
|
1758
1758
|
end
|
1759
1759
|
|
1760
1760
|
context "with :if_unsaved" do
|
1761
1761
|
|
1762
1762
|
before do
|
1763
|
-
@book =
|
1763
|
+
@book = Workbook.open(@simple_file)
|
1764
1764
|
@sheet = @book.sheet(1)
|
1765
1765
|
@book.add_sheet(@sheet, :as => 'a_name')
|
1766
1766
|
end
|
@@ -1772,13 +1772,13 @@ describe Book do
|
|
1772
1772
|
|
1773
1773
|
it "should raise an error, if :if_unsaved is :raise" do
|
1774
1774
|
expect {
|
1775
|
-
@new_book =
|
1775
|
+
@new_book = Workbook.open(@simple_file, :if_unsaved => :raise)
|
1776
1776
|
}.to raise_error(WorkbookNotSaved, /workbook is already open but not saved: "workbook.xls"/)
|
1777
1777
|
end
|
1778
1778
|
|
1779
1779
|
it "should let the book open, if :if_unsaved is :accept" do
|
1780
1780
|
expect {
|
1781
|
-
@new_book =
|
1781
|
+
@new_book = Workbook.open(@simple_file, :if_unsaved => :accept)
|
1782
1782
|
}.to_not raise_error
|
1783
1783
|
@book.should be_alive
|
1784
1784
|
@new_book.should be_alive
|
@@ -1797,7 +1797,7 @@ describe Book do
|
|
1797
1797
|
it "should open the new book and close the unsaved book, if user answers 'yes'" do
|
1798
1798
|
# "Yes" is the default. --> language independent
|
1799
1799
|
@key_sender.puts "{enter}"
|
1800
|
-
@new_book =
|
1800
|
+
@new_book = Workbook.open(@simple_file1, :if_unsaved => :alert)
|
1801
1801
|
@new_book.should be_alive
|
1802
1802
|
@new_book.filename.downcase.should == @simple_file1.downcase
|
1803
1803
|
@book.should_not be_alive
|
@@ -1811,7 +1811,7 @@ describe Book do
|
|
1811
1811
|
@key_sender.puts "{right}{enter}"
|
1812
1812
|
@key_sender.puts "{right}{enter}"
|
1813
1813
|
expect{
|
1814
|
-
|
1814
|
+
Workbook.open(@simple_file, :if_unsaved => :alert)
|
1815
1815
|
}.to raise_error(UnexpectedREOError)
|
1816
1816
|
@book.should be_alive
|
1817
1817
|
end
|
@@ -1819,7 +1819,7 @@ describe Book do
|
|
1819
1819
|
it "should open the new book and close the unsaved book, if user answers 'yes'" do
|
1820
1820
|
# "Yes" is the default. --> language independent
|
1821
1821
|
@key_sender.puts "{enter}"
|
1822
|
-
@new_book =
|
1822
|
+
@new_book = Workbook.open(@simple_file1, :if_unsaved => :excel)
|
1823
1823
|
@new_book.should be_alive
|
1824
1824
|
@new_book.filename.downcase.should == @simple_file1.downcase
|
1825
1825
|
#@book.should_not be_alive
|
@@ -1833,7 +1833,7 @@ describe Book do
|
|
1833
1833
|
@key_sender.puts "{right}{enter}"
|
1834
1834
|
@key_sender.puts "{right}{enter}"
|
1835
1835
|
expect{
|
1836
|
-
|
1836
|
+
Workbook.open(@simple_file, :if_unsaved => :excel)
|
1837
1837
|
}.to raise_error(UnexpectedREOError)
|
1838
1838
|
@book.should be_alive
|
1839
1839
|
end
|
@@ -1849,16 +1849,16 @@ describe Book do
|
|
1849
1849
|
|
1850
1850
|
before do
|
1851
1851
|
if i == 1 then
|
1852
|
-
book_before =
|
1852
|
+
book_before = Workbook.open(@simple_file1)
|
1853
1853
|
book_before.close
|
1854
1854
|
end
|
1855
|
-
@book =
|
1855
|
+
@book = Workbook.open(@simple_file_other_path1)
|
1856
1856
|
#@book.Windows(@book.Name).Visible = true
|
1857
1857
|
#@sheet_count = @book.ole_workbook.Worksheets.Count
|
1858
1858
|
sheet = @book.sheet(1)
|
1859
1859
|
#@book.add_sheet(@sheet, :as => 'a_name')
|
1860
1860
|
@old_value = sheet[1,1].Value
|
1861
|
-
sheet[1,1] = (sheet[1,1].
|
1861
|
+
sheet[1,1] = (sheet[1,1].Value == "foo" ? "bar" : "foo")
|
1862
1862
|
@new_value = sheet[1,1].Value
|
1863
1863
|
@book.Saved.should be false
|
1864
1864
|
end
|
@@ -1870,25 +1870,25 @@ describe Book do
|
|
1870
1870
|
|
1871
1871
|
it "should raise an error, if :if_obstructed is :raise" do
|
1872
1872
|
expect {
|
1873
|
-
new_book =
|
1873
|
+
new_book = Workbook.open(@simple_file1, :if_obstructed => :raise)
|
1874
1874
|
}.to raise_error(WorkbookBlocked, /blocked by a workbook with the same name in a different path/)
|
1875
1875
|
end
|
1876
1876
|
|
1877
1877
|
it "should close the other book and open the new book, if :if_obstructed is :forget" do
|
1878
|
-
new_book =
|
1878
|
+
new_book = Workbook.open(@simple_file1, :if_obstructed => :forget)
|
1879
1879
|
@book.should_not be_alive
|
1880
1880
|
new_book.should be_alive
|
1881
1881
|
new_book.filename.downcase.should == @simple_file.downcase
|
1882
|
-
old_book =
|
1882
|
+
old_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
|
1883
1883
|
old_book.sheet(1)[1,1].Value.should == @old_value
|
1884
1884
|
end
|
1885
1885
|
|
1886
1886
|
it "should save the old book, close it, and open the new book, if :if_obstructed is :save" do
|
1887
|
-
new_book =
|
1887
|
+
new_book = Workbook.open(@simple_file1, :if_obstructed => :save)
|
1888
1888
|
@book.should_not be_alive
|
1889
1889
|
new_book.should be_alive
|
1890
1890
|
new_book.filename.downcase.should == @simple_file1.downcase
|
1891
|
-
old_book =
|
1891
|
+
old_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
|
1892
1892
|
old_book.sheet(1)[1,1].Value.should == @new_value
|
1893
1893
|
#old_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
|
1894
1894
|
old_book.close
|
@@ -1897,14 +1897,14 @@ describe Book do
|
|
1897
1897
|
it "should raise an error, if the old book is unsaved, and close the old book and open the new book,
|
1898
1898
|
if :if_obstructed is :close_if_saved" do
|
1899
1899
|
expect{
|
1900
|
-
new_book =
|
1900
|
+
new_book = Workbook.open(@simple_file1, :if_obstructed => :close_if_saved)
|
1901
1901
|
}.to raise_error(WorkbookBlocked, /workbook with the same name in a different path is unsaved/)
|
1902
1902
|
@book.save
|
1903
|
-
new_book =
|
1903
|
+
new_book = Workbook.open(@simple_file1, :if_obstructed => :close_if_saved)
|
1904
1904
|
@book.should_not be_alive
|
1905
1905
|
new_book.should be_alive
|
1906
1906
|
new_book.filename.downcase.should == @simple_file1.downcase
|
1907
|
-
old_book =
|
1907
|
+
old_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
|
1908
1908
|
old_book.sheet(1)[1,1].Value.should == @new_value
|
1909
1909
|
#old_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
|
1910
1910
|
old_book.close
|
@@ -1912,12 +1912,12 @@ describe Book do
|
|
1912
1912
|
|
1913
1913
|
it "should close the old book and open the new book, if :if_obstructed is :close_if_saved" do
|
1914
1914
|
@book.close(:if_unsaved => :forget)
|
1915
|
-
book =
|
1916
|
-
book2 =
|
1915
|
+
book = Workbook.open(@simple_file_other_path)
|
1916
|
+
book2 = Workbook.open(@simple_file1, :if_obstructed => :close_if_saved)
|
1917
1917
|
end
|
1918
1918
|
|
1919
1919
|
it "should open the book in a new excel instance, if :if_obstructed is :new_excel" do
|
1920
|
-
new_book =
|
1920
|
+
new_book = Workbook.open(@simple_file1, :if_obstructed => :new_excel)
|
1921
1921
|
@book.should be_alive
|
1922
1922
|
@book.Saved.should be false
|
1923
1923
|
@book.sheet(1)[1,1].Value.should == @new_value
|
@@ -1929,13 +1929,13 @@ describe Book do
|
|
1929
1929
|
|
1930
1930
|
it "should raise an error, if :if_obstructed is default" do
|
1931
1931
|
expect {
|
1932
|
-
new_book =
|
1932
|
+
new_book = Workbook.open(@simple_file1)
|
1933
1933
|
}.to raise_error(WorkbookBlocked, /blocked by a workbook with the same name in a different path/)
|
1934
1934
|
end
|
1935
1935
|
|
1936
1936
|
it "should raise an error, if :if_obstructed is invalid option" do
|
1937
1937
|
expect {
|
1938
|
-
new_book =
|
1938
|
+
new_book = Workbook.open(@simple_file1, :if_obstructed => :invalid_option)
|
1939
1939
|
}.to raise_error(OptionInvalid, ":if_obstructed: invalid option: :invalid_option")
|
1940
1940
|
end
|
1941
1941
|
end
|
@@ -1944,7 +1944,7 @@ describe Book do
|
|
1944
1944
|
|
1945
1945
|
context "with an already saved book" do
|
1946
1946
|
before do
|
1947
|
-
@book =
|
1947
|
+
@book = Workbook.open(@simple_file)
|
1948
1948
|
end
|
1949
1949
|
|
1950
1950
|
after do
|
@@ -1955,16 +1955,16 @@ describe Book do
|
|
1955
1955
|
possible_options.each do |options_value|
|
1956
1956
|
context "with :if_unsaved => #{options_value} and in the same and different path" do
|
1957
1957
|
before do
|
1958
|
-
@new_book =
|
1959
|
-
@different_book =
|
1958
|
+
@new_book = Workbook.open(@simple_file1, :reuse => true, :if_unsaved => options_value)
|
1959
|
+
@different_book = Workbook.open(@different_file, :reuse => true, :if_unsaved => options_value)
|
1960
1960
|
end
|
1961
1961
|
after do
|
1962
1962
|
@new_book.close
|
1963
1963
|
@different_book.close
|
1964
1964
|
end
|
1965
1965
|
it "should open without problems " do
|
1966
|
-
@new_book.should be_a
|
1967
|
-
@different_book.should be_a
|
1966
|
+
@new_book.should be_a Workbook
|
1967
|
+
@different_book.should be_a Workbook
|
1968
1968
|
end
|
1969
1969
|
it "should belong to the same Excel instance" do
|
1970
1970
|
@new_book.excel.should == @book.excel
|
@@ -1978,27 +1978,27 @@ describe Book do
|
|
1978
1978
|
|
1979
1979
|
it "should raise error if filename is nil" do
|
1980
1980
|
expect{
|
1981
|
-
|
1981
|
+
Workbook.open(@nonexisting)
|
1982
1982
|
}.to raise_error(FileNameNotGiven, "filename is nil")
|
1983
1983
|
end
|
1984
1984
|
|
1985
1985
|
it "should raise error if file is a directory" do
|
1986
1986
|
expect{
|
1987
|
-
|
1987
|
+
Workbook.open(@dir)
|
1988
1988
|
}.to raise_error(FileNotFound, "file #{General::absolute_path(@dir).gsub("/","\\").inspect} is a directory")
|
1989
1989
|
end
|
1990
1990
|
|
1991
1991
|
it "should raise error if file does not exist" do
|
1992
1992
|
File.delete @simple_save_file rescue nil
|
1993
1993
|
expect {
|
1994
|
-
|
1994
|
+
Workbook.open(@simple_save_file, :if_absent => :raise)
|
1995
1995
|
}.to raise_error(FileNotFound, "file #{General::absolute_path(@simple_save_file).gsub("/","\\").inspect} not found")
|
1996
1996
|
end
|
1997
1997
|
|
1998
1998
|
it "should create a workbook" do
|
1999
1999
|
File.delete @simple_save_file rescue nil
|
2000
|
-
book =
|
2001
|
-
book.should be_a
|
2000
|
+
book = Workbook.open(@simple_save_file, :if_absent => :create)
|
2001
|
+
book.should be_a Workbook
|
2002
2002
|
book.close
|
2003
2003
|
File.exist?(@simple_save_file).should be true
|
2004
2004
|
end
|
@@ -2006,7 +2006,7 @@ describe Book do
|
|
2006
2006
|
it "should raise an exception by default" do
|
2007
2007
|
File.delete @simple_save_file rescue nil
|
2008
2008
|
expect {
|
2009
|
-
|
2009
|
+
Workbook.open(@simple_save_file)
|
2010
2010
|
}.to raise_error(FileNotFound, "file #{General::absolute_path(@simple_save_file).gsub("/","\\").inspect} not found")
|
2011
2011
|
end
|
2012
2012
|
|
@@ -2015,7 +2015,7 @@ describe Book do
|
|
2015
2015
|
context "with attr_reader excel" do
|
2016
2016
|
|
2017
2017
|
before do
|
2018
|
-
@new_book =
|
2018
|
+
@new_book = Workbook.open(@simple_file)
|
2019
2019
|
end
|
2020
2020
|
after do
|
2021
2021
|
@new_book.close
|
@@ -2032,25 +2032,25 @@ describe Book do
|
|
2032
2032
|
context "with :update_links" do
|
2033
2033
|
|
2034
2034
|
it "should set update_links to :alert" do
|
2035
|
-
book =
|
2035
|
+
book = Workbook.open(@simple_file, :update_links => :alert)
|
2036
2036
|
book.UpdateLinks.should == XlUpdateLinksUserSetting
|
2037
2037
|
book.Saved.should be true
|
2038
2038
|
end
|
2039
2039
|
|
2040
2040
|
it "should set update_links to :never" do
|
2041
|
-
book =
|
2041
|
+
book = Workbook.open(@simple_file, :update_links => :never)
|
2042
2042
|
book.UpdateLinks.should == XlUpdateLinksNever
|
2043
|
-
book =
|
2043
|
+
book = Workbook.open(@simple_file, :update_links => :foo)
|
2044
2044
|
book.UpdateLinks.should == XlUpdateLinksNever
|
2045
2045
|
end
|
2046
2046
|
|
2047
2047
|
it "should set update_links to :always" do
|
2048
|
-
book =
|
2048
|
+
book = Workbook.open(@simple_file, :update_links => :always)
|
2049
2049
|
book.UpdateLinks.should == XlUpdateLinksAlways
|
2050
2050
|
end
|
2051
2051
|
|
2052
2052
|
it "should set update_links to :never per default" do
|
2053
|
-
book =
|
2053
|
+
book = Workbook.open(@simple_file)
|
2054
2054
|
book.UpdateLinks.should == XlUpdateLinksNever
|
2055
2055
|
end
|
2056
2056
|
|
@@ -2060,84 +2060,84 @@ describe Book do
|
|
2060
2060
|
context "with :read_only" do
|
2061
2061
|
|
2062
2062
|
it "should reopen the book with writable (unsaved changes from readonly will not be saved)" do
|
2063
|
-
book =
|
2063
|
+
book = Workbook.open(@simple_file1, :read_only => true)
|
2064
2064
|
book.ReadOnly.should be true
|
2065
2065
|
book.should be_alive
|
2066
2066
|
sheet = book.sheet(1)
|
2067
|
-
old_cell_value = sheet[1,1].
|
2068
|
-
sheet[1,1] = sheet[1,1].
|
2067
|
+
old_cell_value = sheet[1,1].Value
|
2068
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
2069
2069
|
book.Saved.should be false
|
2070
|
-
new_book =
|
2070
|
+
new_book = Workbook.open(@simple_file1, :read_only => false, :if_unsaved => :accept)
|
2071
2071
|
new_book.ReadOnly.should be false
|
2072
2072
|
new_book.should be_alive
|
2073
2073
|
book.should be_alive
|
2074
2074
|
new_book.should == book
|
2075
2075
|
new_sheet = new_book.sheet(1)
|
2076
|
-
new_cell_value = new_sheet[1,1].
|
2076
|
+
new_cell_value = new_sheet[1,1].Value
|
2077
2077
|
new_cell_value.should == old_cell_value
|
2078
2078
|
end
|
2079
2079
|
|
2080
2080
|
it "should not raise an error when trying to reopen the book as read_only while the writable book had unsaved changes" do
|
2081
|
-
book =
|
2081
|
+
book = Workbook.open(@simple_file1, :read_only => false)
|
2082
2082
|
book.ReadOnly.should be false
|
2083
2083
|
book.should be_alive
|
2084
2084
|
sheet = book.sheet(1)
|
2085
|
-
old_cell_value = sheet[1,1].
|
2086
|
-
sheet[1,1] = sheet[1,1].
|
2085
|
+
old_cell_value = sheet[1,1].Value
|
2086
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
2087
2087
|
book.Saved.should be false
|
2088
|
-
new_book =
|
2088
|
+
new_book = Workbook.open(@simple_file1, :read_only => true, :if_unsaved => :accept)
|
2089
2089
|
new_book.ReadOnly.should be true
|
2090
2090
|
new_book.Saved.should be true
|
2091
2091
|
new_book.should == book
|
2092
2092
|
end
|
2093
2093
|
|
2094
2094
|
it "should reopen the book with writable in the same Excel instance (unsaved changes from readonly will not be saved)" do
|
2095
|
-
book =
|
2095
|
+
book = Workbook.open(@simple_file1, :read_only => true)
|
2096
2096
|
book.ReadOnly.should be true
|
2097
2097
|
book.should be_alive
|
2098
2098
|
sheet = book.sheet(1)
|
2099
|
-
old_cell_value = sheet[1,1].
|
2100
|
-
sheet[1,1] = sheet[1,1].
|
2099
|
+
old_cell_value = sheet[1,1].Value
|
2100
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
2101
2101
|
book.Saved.should be false
|
2102
|
-
new_book =
|
2102
|
+
new_book = Workbook.open(@simple_file1, :if_unsaved => :accept, :force => {:excel => book.excel}, :read_only => false)
|
2103
2103
|
new_book.ReadOnly.should be false
|
2104
2104
|
new_book.should be_alive
|
2105
2105
|
book.should be_alive
|
2106
2106
|
new_book.should == book
|
2107
2107
|
new_sheet = new_book.sheet(1)
|
2108
|
-
new_cell_value = new_sheet[1,1].
|
2108
|
+
new_cell_value = new_sheet[1,1].Value
|
2109
2109
|
new_cell_value.should == old_cell_value
|
2110
2110
|
end
|
2111
2111
|
|
2112
2112
|
it "should reopen the book with readonly (unsaved changes of the writable should be saved)" do
|
2113
|
-
book =
|
2113
|
+
book = Workbook.open(@simple_file1, :force => {:excel => :new}, :read_only => false)
|
2114
2114
|
book.ReadOnly.should be false
|
2115
2115
|
book.should be_alive
|
2116
2116
|
sheet = book.sheet(1)
|
2117
|
-
old_cell_value = sheet[1,1].
|
2118
|
-
sheet[1,1] = sheet[1,1].
|
2117
|
+
old_cell_value = sheet[1,1].Value
|
2118
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
2119
2119
|
book.Saved.should be false
|
2120
|
-
new_book =
|
2120
|
+
new_book = Workbook.open(@simple_file1, :force => {:excel => book.excel}, :read_only => true, :if_unsaved => :accept)
|
2121
2121
|
new_book.ReadOnly.should be true
|
2122
2122
|
new_book.Saved.should be true
|
2123
2123
|
new_book.should == book
|
2124
2124
|
new_sheet = new_book.sheet(1)
|
2125
|
-
new_cell_value = new_sheet[1,1].
|
2125
|
+
new_cell_value = new_sheet[1,1].Value
|
2126
2126
|
new_cell_value.should_not == old_cell_value
|
2127
2127
|
end
|
2128
2128
|
|
2129
2129
|
it "should open the second book in another Excel as writable" do
|
2130
|
-
book =
|
2130
|
+
book = Workbook.open(@simple_file1, :read_only => true)
|
2131
2131
|
book.ReadOnly.should be true
|
2132
|
-
new_book =
|
2132
|
+
new_book = Workbook.open(@simple_file1, :force => {:excel => :new}, :read_only => false)
|
2133
2133
|
new_book.ReadOnly.should be false
|
2134
2134
|
new_book.close
|
2135
2135
|
book.close
|
2136
2136
|
end
|
2137
2137
|
|
2138
2138
|
it "should be able to save, if :read_only => false" do
|
2139
|
-
book =
|
2140
|
-
book.should be_a
|
2139
|
+
book = Workbook.open(@simple_file1, :read_only => false)
|
2140
|
+
book.should be_a Workbook
|
2141
2141
|
expect {
|
2142
2142
|
book.save_as(@simple_save_file, :if_exists => :overwrite)
|
2143
2143
|
}.to_not raise_error
|
@@ -2145,8 +2145,8 @@ describe Book do
|
|
2145
2145
|
end
|
2146
2146
|
|
2147
2147
|
it "should be able to save, if :read_only is default" do
|
2148
|
-
book =
|
2149
|
-
book.should be_a
|
2148
|
+
book = Workbook.open(@simple_file1)
|
2149
|
+
book.should be_a Workbook
|
2150
2150
|
expect {
|
2151
2151
|
book.save_as(@simple_save_file, :if_exists => :overwrite)
|
2152
2152
|
}.to_not raise_error
|
@@ -2154,8 +2154,8 @@ describe Book do
|
|
2154
2154
|
end
|
2155
2155
|
|
2156
2156
|
it "should raise an error, if :read_only => true" do
|
2157
|
-
book =
|
2158
|
-
book.should be_a
|
2157
|
+
book = Workbook.open(@simple_file, :read_only => true)
|
2158
|
+
book.should be_a Workbook
|
2159
2159
|
expect {
|
2160
2160
|
book.save_as(@simple_save_file, :if_exists => :overwrite)
|
2161
2161
|
}.to raise_error
|
@@ -2166,26 +2166,26 @@ describe Book do
|
|
2166
2166
|
context "with various file formats" do
|
2167
2167
|
|
2168
2168
|
it "should open linked workbook" do
|
2169
|
-
book =
|
2169
|
+
book = Workbook.open(@linked_file, :visible => true)
|
2170
2170
|
book.close
|
2171
2171
|
end
|
2172
2172
|
|
2173
2173
|
#it "should open xlsm file" do
|
2174
|
-
# book =
|
2174
|
+
# book = Workbook.open(@simple_file_xlsm, :visible => true)
|
2175
2175
|
# book.close
|
2176
2176
|
#end
|
2177
2177
|
|
2178
2178
|
it "should open xlsx file" do
|
2179
|
-
book =
|
2179
|
+
book = Workbook.open(@simple_file_xlsx, :visible => true)
|
2180
2180
|
book.close
|
2181
2181
|
end
|
2182
2182
|
end
|
2183
2183
|
|
2184
2184
|
|
2185
2185
|
context "with block" do
|
2186
|
-
it 'block parameter should be instance of
|
2187
|
-
|
2188
|
-
book.should be_a
|
2186
|
+
it 'block parameter should be instance of Workbook' do
|
2187
|
+
Workbook.open(@simple_file) do |book|
|
2188
|
+
book.should be_a Workbook
|
2189
2189
|
end
|
2190
2190
|
end
|
2191
2191
|
end
|
@@ -2195,7 +2195,7 @@ describe Book do
|
|
2195
2195
|
path = '~/Abrakadabra.xlsx'
|
2196
2196
|
expected_path = Regexp.new(File.expand_path(path).gsub(/\//, "."))
|
2197
2197
|
expect {
|
2198
|
-
|
2198
|
+
Workbook.open(path)
|
2199
2199
|
}.to raise_error(FileNotFound, "file #{General::absolute_path(path).gsub("/","\\").inspect} not found")
|
2200
2200
|
end
|
2201
2201
|
end
|
@@ -2206,7 +2206,7 @@ describe Book do
|
|
2206
2206
|
context "with standard" do
|
2207
2207
|
|
2208
2208
|
before do
|
2209
|
-
@book =
|
2209
|
+
@book = Workbook.open(@simple_file)
|
2210
2210
|
end
|
2211
2211
|
|
2212
2212
|
after do
|
@@ -2219,7 +2219,7 @@ describe Book do
|
|
2219
2219
|
@book.close
|
2220
2220
|
@book.should_not be_alive
|
2221
2221
|
@book.reopen
|
2222
|
-
@book.should be_a
|
2222
|
+
@book.should be_a Workbook
|
2223
2223
|
@book.should be_alive
|
2224
2224
|
@book.should === book1
|
2225
2225
|
end
|
@@ -2231,7 +2231,7 @@ describe Book do
|
|
2231
2231
|
context "with standard" do
|
2232
2232
|
|
2233
2233
|
before do
|
2234
|
-
@book =
|
2234
|
+
@book = Workbook.open(@simple_file)
|
2235
2235
|
end
|
2236
2236
|
|
2237
2237
|
after do
|
@@ -2240,8 +2240,8 @@ describe Book do
|
|
2240
2240
|
|
2241
2241
|
it "should uplift a workbook to a book with an open book" do
|
2242
2242
|
workbook = @book.ole_workbook
|
2243
|
-
book1 =
|
2244
|
-
book1.should be_a
|
2243
|
+
book1 = Workbook.new(workbook)
|
2244
|
+
book1.should be_a Workbook
|
2245
2245
|
book1.should be_alive
|
2246
2246
|
book1.should == @book
|
2247
2247
|
end
|