robust_excel_ole 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +13 -0
  3. data/README.rdoc +107 -73
  4. data/{README_excel.rdoc → docs/README_excel.rdoc} +2 -0
  5. data/{README_open.rdoc → docs/README_open.rdoc} +12 -16
  6. data/{README_ranges.rdoc → docs/README_ranges.rdoc} +1 -1
  7. data/{README_save_close.rdoc → docs/README_save_close.rdoc} +0 -0
  8. data/{README_sheet.rdoc → docs/README_sheet.rdoc} +0 -0
  9. data/examples/open_save_close/example_control_to_excel.rb +3 -3
  10. data/examples/open_save_close/example_default_excel.rb +2 -2
  11. data/examples/open_save_close/example_force_excel.rb +2 -2
  12. data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +2 -2
  13. data/examples/open_save_close/example_if_obstructed_forget.rb +2 -2
  14. data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
  15. data/examples/open_save_close/example_if_unsaved_accept.rb +3 -3
  16. data/examples/open_save_close/example_if_unsaved_forget.rb +7 -3
  17. data/examples/open_save_close/example_if_unsaved_forget_more.rb +1 -1
  18. data/examples/open_save_close/example_read_only.rb +2 -2
  19. data/examples/open_save_close/example_rename_cells.rb +2 -2
  20. data/examples/open_save_close/example_reuse.rb +2 -2
  21. data/examples/open_save_close/example_simple.rb +1 -1
  22. data/examples/open_save_close/example_unobtrusively.rb +2 -2
  23. data/lib/robust_excel_ole/book.rb +75 -76
  24. data/lib/robust_excel_ole/bookstore.rb +9 -9
  25. data/lib/robust_excel_ole/excel.rb +5 -5
  26. data/lib/robust_excel_ole/general.rb +11 -4
  27. data/lib/robust_excel_ole/reo_common.rb +3 -0
  28. data/lib/robust_excel_ole/version.rb +1 -1
  29. data/robust_excel_ole.gemspec +2 -2
  30. data/spec/book_spec.rb +67 -63
  31. data/spec/book_specs/book_close_spec.rb +12 -10
  32. data/spec/book_specs/book_misc_spec.rb +279 -279
  33. data/spec/book_specs/book_open_spec.rb +258 -105
  34. data/spec/book_specs/book_save_spec.rb +28 -28
  35. data/spec/book_specs/book_unobtr_spec.rb +862 -164
  36. data/spec/bookstore_spec.rb +22 -22
  37. data/spec/data/another_workbook.xls +0 -0
  38. data/spec/data/different_workbook.xls +0 -0
  39. data/spec/data/workbook.xls +0 -0
  40. data/spec/excel_spec.rb +256 -254
  41. data/spec/general_spec.rb +7 -7
  42. data/spec/ruby1.8.6_rspec2.14/book_spec.rb +1421 -0
  43. data/spec/ruby1.8.6_rspec2.14/book_specs/book_all_spec.rb +22 -0
  44. data/spec/ruby1.8.6_rspec2.14/book_specs/book_close_spec.rb +252 -0
  45. data/spec/ruby1.8.6_rspec2.14/book_specs/book_misc_spec.rb +1070 -0
  46. data/spec/ruby1.8.6_rspec2.14/book_specs/book_open_spec.rb +1855 -0
  47. data/spec/ruby1.8.6_rspec2.14/book_specs/book_save_spec.rb +514 -0
  48. data/spec/ruby1.8.6_rspec2.14/book_specs/book_sheet_spec.rb +395 -0
  49. data/spec/ruby1.8.6_rspec2.14/book_specs/book_subclass_spec.rb +51 -0
  50. data/spec/ruby1.8.6_rspec2.14/book_specs/book_unobtr_spec.rb +1737 -0
  51. data/spec/ruby1.8.6_rspec2.14/bookstore_spec.rb +495 -0
  52. data/spec/ruby1.8.6_rspec2.14/cell_spec.rb +76 -0
  53. data/spec/ruby1.8.6_rspec2.14/cygwin_spec.rb +42 -0
  54. data/spec/ruby1.8.6_rspec2.14/excel_spec.rb +1820 -0
  55. data/spec/ruby1.8.6_rspec2.14/general_spec.rb +212 -0
  56. data/spec/ruby1.8.6_rspec2.14/range_spec.rb +131 -0
  57. data/spec/ruby1.8.6_rspec2.14/reo_common_spec.rb +130 -0
  58. data/spec/ruby1.8.6_rspec2.14/sheet_spec.rb +663 -0
  59. data/spec/ruby1.8.6_rspec2.14/spec_helper.rb +35 -0
  60. data/spec/sheet_spec.rb +2 -2
  61. metadata +28 -12
  62. data/README_detail.rdoc +0 -852
  63. data/README_development.rdoc +0 -5
@@ -95,7 +95,7 @@ describe Book do
95
95
  Book.open(@simple_file) do |book|
96
96
  book.save_as(@simple_save_file1, :if_exists => :overwrite)
97
97
  end
98
- File.exist?(@simple_save_file1).should be_true
98
+ File.exist?(@simple_save_file1).should be true
99
99
  end
100
100
 
101
101
  it "should raise error if filename is nil" do
@@ -129,7 +129,7 @@ describe Book do
129
129
  simple_save_file = @dir + '/simple_save_file.' + extensions_value
130
130
  File.delete simple_save_file rescue nil
131
131
  @book.save_as(simple_save_file, :if_exists => :overwrite)
132
- File.exist?(simple_save_file).should be_true
132
+ File.exist?(simple_save_file).should be true
133
133
  new_book = Book.open(simple_save_file)
134
134
  new_book.should be_a Book
135
135
  new_book.close
@@ -148,7 +148,7 @@ describe Book do
148
148
  File.open(@simple_file_other_path1,"w") do | file |
149
149
  file.puts "garbage"
150
150
  end
151
- File.exist?(@simple_file_other_path1).should be_true
151
+ File.exist?(@simple_file_other_path1).should be true
152
152
  @book.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :forget)
153
153
  end
154
154
 
@@ -171,7 +171,7 @@ describe Book do
171
171
  File.open(@simple_file_other_path1,"w") do | file |
172
172
  file.puts "garbage"
173
173
  end
174
- File.exist?(@simple_file_other_path1).should be_true
174
+ File.exist?(@simple_file_other_path1).should be true
175
175
  expect{
176
176
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :raise)
177
177
  }.to raise_error(WorkbookBlocked, /blocked by another workbook/)
@@ -184,7 +184,7 @@ describe Book do
184
184
  end
185
185
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :forget)
186
186
  @book.should_not be_alive
187
- File.exist?(@simple_file_other_path1).should be_true
187
+ File.exist?(@simple_file_other_path1).should be true
188
188
  new_book = Book.open(@simple_file_other_path1)
189
189
  new_book.should be_a Book
190
190
  new_book.close
@@ -198,11 +198,11 @@ describe Book do
198
198
  sheet = @book.sheet(1)
199
199
  cell_value = sheet[1,1].value
200
200
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
201
- @book.Saved.should be_false
201
+ @book.Saved.should be false
202
202
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :forget)
203
203
  @book.should_not be_alive
204
204
  @book2.should be_alive
205
- File.exist?(@simple_file_other_path1).should be_true
205
+ File.exist?(@simple_file_other_path1).should be true
206
206
  new_book = Book.open(@simple_file_other_path1)
207
207
  new_book.should be_a Book
208
208
  new_book.close
@@ -220,11 +220,11 @@ describe Book do
220
220
  sheet = @book.sheet(1)
221
221
  cell_value = sheet[1,1].value
222
222
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
223
- @book.Saved.should be_false
223
+ @book.Saved.should be false
224
224
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :save)
225
225
  @book.should_not be_alive
226
226
  @book2.should be_alive
227
- File.exist?(@simple_file_other_path1).should be_true
227
+ File.exist?(@simple_file_other_path1).should be true
228
228
  new_book = Book.open(@simple_file_other_path1)
229
229
  new_book.should be_a Book
230
230
  new_book.close
@@ -239,11 +239,11 @@ describe Book do
239
239
  File.open(@simple_file_other_path1,"w") do | file |
240
240
  file.puts "garbage"
241
241
  end
242
- @book.Saved.should be_true
242
+ @book.Saved.should be true
243
243
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :close_if_saved)
244
244
  @book.should_not be_alive
245
245
  @book2.should be_alive
246
- File.exist?(@simple_file_other_path1).should be_true
246
+ File.exist?(@simple_file_other_path1).should be true
247
247
  new_book = Book.open(@simple_file_other_path1)
248
248
  new_book.should be_a Book
249
249
  new_book.close
@@ -253,7 +253,7 @@ describe Book do
253
253
  sheet = @book.sheet(1)
254
254
  cell_value = sheet[1,1].value
255
255
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
256
- @book.Saved.should be_false
256
+ @book.Saved.should be false
257
257
  expect{
258
258
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :close_if_saved)
259
259
  }.to raise_error(WorkbookBlocked, /blocking workbook is unsaved: "workbook.xls"/)
@@ -264,7 +264,7 @@ describe Book do
264
264
  File.open(@simple_file_other_path1,"w") do | file |
265
265
  file.puts "garbage"
266
266
  end
267
- File.exist?(@simple_file_other_path1).should be_true
267
+ File.exist?(@simple_file_other_path1).should be true
268
268
  expect{
269
269
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :invalid)
270
270
  }.to raise_error(OptionInvalid, ":if_obstructed: invalid option: :invalid")
@@ -275,7 +275,7 @@ describe Book do
275
275
  File.open(@simple_file_other_path1,"w") do | file |
276
276
  file.puts "garbage"
277
277
  end
278
- File.exist?(@simple_file_other_path1).should be_true
278
+ File.exist?(@simple_file_other_path1).should be true
279
279
  expect{
280
280
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite)
281
281
  }.to raise_error(WorkbookBlocked, /blocked by another workbook/)
@@ -283,7 +283,7 @@ describe Book do
283
283
 
284
284
  it "should raise an error if the file does not exist and an workbook with the same name and other path exists" do
285
285
  File.delete @simple_file_other_path1 rescue nil
286
- File.exist?(@simple_file_other_path1).should be_false
286
+ File.exist?(@simple_file_other_path1).should be false
287
287
  expect{
288
288
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :raise)
289
289
  }.to raise_error(WorkbookBlocked, /blocked by another workbook/)
@@ -294,7 +294,7 @@ describe Book do
294
294
  File.open(@simple_file_other_path1,"w") do | file |
295
295
  file.puts "garbage"
296
296
  end
297
- File.exist?(@simple_file_other_path1).should be_true
297
+ File.exist?(@simple_file_other_path1).should be true
298
298
  expect{
299
299
  @book.save_as(@simple_file_other_path1, :if_exists => :raise, :if_obstructed => :raise)
300
300
  }.to raise_error(FileAlreadyExists, /file already exists: "workbook.xls"/)
@@ -332,7 +332,7 @@ describe Book do
332
332
  file.puts "garbage"
333
333
  end
334
334
  @book.save_as(@simple_save_file1, :if_exists => :overwrite)
335
- File.exist?(@simple_save_file1).should be_true
335
+ File.exist?(@simple_save_file1).should be true
336
336
  new_book = Book.open(@simple_save_file1)
337
337
  new_book.should be_a Book
338
338
  new_book.close
@@ -355,12 +355,12 @@ describe Book do
355
355
  File.open(@simple_save_file1,"w") do | file |
356
356
  file.puts "garbage"
357
357
  end
358
- File.exist?(@simple_save_file1).should be_true
358
+ File.exist?(@simple_save_file1).should be true
359
359
  booklength = File.size?(@simple_save_file1)
360
360
  expect {
361
361
  @book.save_as(@simple_save_file1, :if_exists => :raise)
362
362
  }.to raise_error(FileAlreadyExists, /file already exists: "workbook_save.xls"/)
363
- File.exist?(@simple_save_file1).should be_true
363
+ File.exist?(@simple_save_file1).should be true
364
364
  File.size?(@simple_save_file1).should == booklength
365
365
  end
366
366
 
@@ -382,7 +382,7 @@ describe Book do
382
382
  # "Yes" is to the left of "No", which is the default. --> language independent
383
383
  @key_sender.puts "{left}{enter}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
384
384
  @book.save_as(@simple_save_file1, :if_exists => :alert)
385
- File.exist?(@simple_save_file1).should be_true
385
+ File.exist?(@simple_save_file1).should be true
386
386
  File.size?(@simple_save_file1).should > @garbage_length
387
387
  @book.excel.DisplayAlerts.should == displayalert_value
388
388
  new_book = Book.open(@simple_save_file1, :excel => :new)
@@ -399,7 +399,7 @@ describe Book do
399
399
  @key_sender.puts "{enter}"
400
400
  #@key_sender.puts "%{n}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
401
401
  @book.save_as(@simple_save_file1, :if_exists => :alert)
402
- File.exist?(@simple_save_file1).should be_true
402
+ File.exist?(@simple_save_file1).should be true
403
403
  File.size?(@simple_save_file1).should == @garbage_length
404
404
  @book.excel.DisplayAlerts.should == displayalert_value
405
405
  end
@@ -412,7 +412,7 @@ describe Book do
412
412
  @key_sender.puts "{right}{enter}"
413
413
  #@key_sender.puts "%{n}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
414
414
  @book.save_as(@simple_save_file1, :if_exists => :alert)
415
- File.exist?(@simple_save_file1).should be_true
415
+ File.exist?(@simple_save_file1).should be true
416
416
  File.size?(@simple_save_file1).should == @garbage_length
417
417
  @book.excel.DisplayAlerts.should == displayalert_value
418
418
  end
@@ -437,7 +437,7 @@ describe Book do
437
437
  # "Yes" is to the left of "No", which is the default. --> language independent
438
438
  @key_sender.puts "{left}{enter}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
439
439
  @book.save_as(@simple_save_file1, :if_exists => :excel)
440
- File.exist?(@simple_save_file1).should be_true
440
+ File.exist?(@simple_save_file1).should be true
441
441
  File.size?(@simple_save_file1).should > @garbage_length
442
442
  @book.excel.DisplayAlerts.should == displayalert_value
443
443
  new_book = Book.open(@simple_save_file1, :excel => :new)
@@ -454,7 +454,7 @@ describe Book do
454
454
  @key_sender.puts "{enter}"
455
455
  #@key_sender.puts "%{n}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
456
456
  @book.save_as(@simple_save_file1, :if_exists => :excel)
457
- File.exist?(@simple_save_file1).should be_true
457
+ File.exist?(@simple_save_file1).should be true
458
458
  File.size?(@simple_save_file1).should == @garbage_length
459
459
  @book.excel.DisplayAlerts.should == displayalert_value
460
460
  end
@@ -467,7 +467,7 @@ describe Book do
467
467
  @key_sender.puts "{right}{enter}"
468
468
  #@key_sender.puts "%{n}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
469
469
  @book.save_as(@simple_save_file1, :if_exists => :excel)
470
- File.exist?(@simple_save_file1).should be_true
470
+ File.exist?(@simple_save_file1).should be true
471
471
  File.size?(@simple_save_file1).should == @garbage_length
472
472
  @book.excel.DisplayAlerts.should == displayalert_value
473
473
  end
@@ -478,7 +478,7 @@ describe Book do
478
478
  expect{
479
479
  @book.save_as(@simple_save_file1, :if_exists => :excel)
480
480
  }.to raise_error(ObjectNotAlive, "workbook is not alive")
481
- File.exist?(@simple_save_file1).should be_true
481
+ File.exist?(@simple_save_file1).should be true
482
482
  File.size?(@simple_save_file1).should == @garbage_length
483
483
  @book.excel.DisplayAlerts.should == displayalert_value
484
484
  end
@@ -491,12 +491,12 @@ describe Book do
491
491
  File.open(@simple_save_file1,"w") do | file |
492
492
  file.puts "garbage"
493
493
  end
494
- File.exist?(@simple_save_file1).should be_true
494
+ File.exist?(@simple_save_file1).should be true
495
495
  booklength = File.size?(@simple_save_file1)
496
496
  expect {
497
497
  @book.save_as(@simple_save_file1)
498
498
  }.to raise_error(FileAlreadyExists, /file already exists: "workbook_save.xls"/)
499
- File.exist?(@simple_save_file1).should be_true
499
+ File.exist?(@simple_save_file1).should be true
500
500
  File.size?(@simple_save_file1).should == booklength
501
501
  end
502
502
 
@@ -44,7 +44,7 @@ describe Book do
44
44
  sheet = book.sheet(1)
45
45
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
46
46
  book.should be_alive
47
- book.Saved.should be_false
47
+ book.Saved.should be false
48
48
  end
49
49
  end
50
50
 
@@ -52,6 +52,749 @@ describe Book do
52
52
  expect{unobtrusively_ok?}.to_not raise_error
53
53
  end
54
54
 
55
+ describe "writability" do
56
+
57
+ context "with no book" do
58
+
59
+ it "should open read-write" do
60
+ Book.unobtrusively(@simple_file1) do |book|
61
+ book.ReadOnly.should be false
62
+ @old_value = book.sheet(1)[1,1].Value
63
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
64
+ book.Saved.should be false
65
+ end
66
+ Excel.current.Workbooks.Count.should == 0
67
+ b1 = Book.open(@simple_file1)
68
+ b1.sheet(1)[1,1].Value.should_not == @old_value
69
+ end
70
+
71
+ it "should open as read-write" do
72
+ Book.unobtrusively(@simple_file, :read_only => false) do |book|
73
+ book.ReadOnly.should be false
74
+ @old_value = book.sheet(1)[1,1].Value
75
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
76
+ book.Saved.should be false
77
+ end
78
+ Excel.current.Workbooks.Count.should == 0
79
+ b1 = Book.open(@simple_file1)
80
+ b1.sheet(1)[1,1].Value.should_not == @old_value
81
+ end
82
+
83
+ it "should open as read-write" do
84
+ Book.unobtrusively(@simple_file, :read_only => false, :writable => false) do |book|
85
+ book.ReadOnly.should be false
86
+ @old_value = book.sheet(1)[1,1].Value
87
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
88
+ book.Saved.should be false
89
+ end
90
+ Excel.current.Workbooks.Count.should == 0
91
+ b1 = Book.open(@simple_file1)
92
+ b1.sheet(1)[1,1].Value.should_not == @old_value
93
+ end
94
+
95
+ it "should open as read-write" do
96
+ Book.unobtrusively(@simple_file, :writable => true) do |book|
97
+ book.ReadOnly.should be false
98
+ @old_value = book.sheet(1)[1,1].Value
99
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
100
+ book.Saved.should be false
101
+ end
102
+ Excel.current.Workbooks.Count.should == 0
103
+ b1 = Book.open(@simple_file1)
104
+ b1.sheet(1)[1,1].Value.should_not == @old_value
105
+ end
106
+
107
+ it "should open as read-write" do
108
+ Book.unobtrusively(@simple_file, :writable => true, :read_only => false) do |book|
109
+ book.ReadOnly.should be false
110
+ @old_value = book.sheet(1)[1,1].Value
111
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
112
+ book.Saved.should be false
113
+ end
114
+ Excel.current.Workbooks.Count.should == 0
115
+ b1 = Book.open(@simple_file1)
116
+ b1.sheet(1)[1,1].Value.should_not == @old_value
117
+ end
118
+
119
+ it "should open read-only" do
120
+ Book.unobtrusively(@simple_file, :read_only => true) do |book|
121
+ book.ReadOnly.should be true
122
+ @old_value = book.sheet(1)[1,1].Value
123
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
124
+ book.Saved.should be false
125
+ end
126
+ Excel.current.Workbooks.Count.should == 0
127
+ b1 = Book.open(@simple_file1)
128
+ b1.sheet(1)[1,1].Value.should == @old_value
129
+ end
130
+
131
+ it "should open read-only" do
132
+ Book.unobtrusively(@simple_file, :read_only => true, :writable => false) do |book|
133
+ book.ReadOnly.should be true
134
+ @old_value = book.sheet(1)[1,1].Value
135
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
136
+ book.Saved.should be false
137
+ end
138
+ Excel.current.Workbooks.Count.should == 0
139
+ b1 = Book.open(@simple_file1)
140
+ b1.sheet(1)[1,1].Value.should == @old_value
141
+ end
142
+
143
+ it "should open not writable" do
144
+ Book.unobtrusively(@simple_file, :writable => false) do |book|
145
+ book.ReadOnly.should be true
146
+ @old_value = book.sheet(1)[1,1].Value
147
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
148
+ book.Saved.should be false
149
+ end
150
+ Excel.current.Workbooks.Count.should == 0
151
+ b1 = Book.open(@simple_file1)
152
+ b1.sheet(1)[1,1].Value.should == @old_value
153
+ end
154
+
155
+ it "should raise error if both options are true" do
156
+ expect{
157
+ Book.unobtrusively(@simple_file, :writable => true, :read_only => true) {|book|}
158
+ }.to raise_error(OptionInvalid, "contradicting options")
159
+ end
160
+ end
161
+
162
+ context "with open writable book" do
163
+
164
+ before do
165
+ @book = Book.open(@simple_file1)
166
+ @old_value = @book.sheet(1)[1,1].Value
167
+ end
168
+
169
+ it "should open as read-write by default" do
170
+ Book.unobtrusively(@simple_file1) do |book|
171
+ book.Readonly.should be false
172
+ book.should == @book
173
+ book.filename.should == @book.filename
174
+ book.excel.should == @book.excel
175
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
176
+ end
177
+ @book.close
178
+ book2 = Book.open(@simple_file1)
179
+ book2.sheet(1)[1,1].Value.should_not == @old_value
180
+ end
181
+
182
+ it "should open as read-write" do
183
+ Book.unobtrusively(@simple_file1, :read_only => false) do |book|
184
+ book.Readonly.should be false
185
+ book.should == @book
186
+ book.filename.should == @book.filename
187
+ book.excel.should == @book.excel
188
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
189
+ end
190
+ @book.close
191
+ book2 = Book.open(@simple_file1)
192
+ book2.sheet(1)[1,1].Value.should_not == @old_value
193
+ end
194
+
195
+ it "should open as read-write" do
196
+ Book.unobtrusively(@simple_file1, :read_only => false, :writable => false) do |book|
197
+ book.Readonly.should be false
198
+ book.should == @book
199
+ book.filename.should == @book.filename
200
+ book.excel.should == @book.excel
201
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
202
+ end
203
+ @book.close
204
+ book2 = Book.open(@simple_file1)
205
+ book2.sheet(1)[1,1].Value.should_not == @old_value
206
+ end
207
+
208
+ it "should open as read-write" do
209
+ Book.unobtrusively(@simple_file1, :writable => true) do |book|
210
+ book.Readonly.should be false
211
+ book.should == @book
212
+ book.filename.should == @book.filename
213
+ book.excel.should == @book.excel
214
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
215
+ end
216
+ @book.close
217
+ book2 = Book.open(@simple_file1)
218
+ book2.sheet(1)[1,1].Value.should_not == @old_value
219
+ end
220
+
221
+ it "should open as read-write" do
222
+ Book.unobtrusively(@simple_file1, :writable => true, :read_only => false) do |book|
223
+ book.Readonly.should be false
224
+ book.should == @book
225
+ book.filename.should == @book.filename
226
+ book.excel.should == @book.excel
227
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
228
+ end
229
+ @book.close
230
+ book2 = Book.open(@simple_file1)
231
+ book2.sheet(1)[1,1].Value.should_not == @old_value
232
+ end
233
+
234
+ it "should force to read-only" do
235
+ Book.unobtrusively(@simple_file1, :read_only => true) do |book|
236
+ book.ReadOnly.should be true
237
+ book.should == @book
238
+ book.filename.should == @book.filename
239
+ book.excel.should == @book.excel
240
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
241
+ end
242
+ @book.close
243
+ book2 = Book.open(@simple_file1)
244
+ book2.sheet(1)[1,1].Value.should == @old_value
245
+ end
246
+
247
+ it "should force to read-only" do
248
+ Book.unobtrusively(@simple_file1, :read_only => true, :writable => false) do |book|
249
+ book.ReadOnly.should be true
250
+ book.should == @book
251
+ book.filename.should == @book.filename
252
+ book.excel.should == @book.excel
253
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
254
+ end
255
+ @book.close
256
+ book2 = Book.open(@simple_file1)
257
+ book2.sheet(1)[1,1].Value.should == @old_value
258
+ end
259
+
260
+ it "should open not writable" do
261
+ Book.unobtrusively(@simple_file1, :writable => false) do |book|
262
+ book.ReadOnly.should be false
263
+ book.should == @book
264
+ book.filename.should == @book.filename
265
+ book.excel.should == @book.excel
266
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
267
+ end
268
+ @book.close
269
+ book2 = Book.open(@simple_file1)
270
+ book2.sheet(1)[1,1].Value.should == @old_value
271
+ end
272
+ end
273
+
274
+ context "with open read-only book" do
275
+
276
+ before do
277
+ @book = Book.open(@simple_file1, :read_only => true)
278
+ @old_value = @book.sheet(1)[1,1].Value
279
+ end
280
+
281
+ it "should not change the read_only mode" do
282
+ Book.unobtrusively(@simple_file1) do |book|
283
+ book.Readonly.should be true
284
+ book.should == @book
285
+ book.filename.should == @book.filename
286
+ book.excel.should == @book.excel
287
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
288
+ end
289
+ @book.close
290
+ book2 = Book.open(@simple_file1)
291
+ book2.sheet(1)[1,1].Value.should == @old_value
292
+ end
293
+
294
+ it "should open as read-write" do
295
+ Book.unobtrusively(@simple_file1, :read_only => false) do |book|
296
+ book.Readonly.should be true
297
+ book.should == @book
298
+ book.filename.should == @book.filename
299
+ book.excel.should == @book.excel
300
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
301
+ end
302
+ @book.close
303
+ book2 = Book.open(@simple_file1)
304
+ book2.sheet(1)[1,1].Value.should == @old_value
305
+ end
306
+
307
+ it "should open as read-write" do
308
+ Book.unobtrusively(@simple_file1, :read_only => false, :writable => false) do |book|
309
+ book.Readonly.should be true
310
+ book.should == @book
311
+ book.filename.should == @book.filename
312
+ book.excel.should == @book.excel
313
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
314
+ end
315
+ @book.close
316
+ book2 = Book.open(@simple_file1)
317
+ book2.sheet(1)[1,1].Value.should == @old_value
318
+ end
319
+
320
+ it "should force to read-write" do
321
+ Book.unobtrusively(@simple_file1, :writable => true) do |book|
322
+ book.Readonly.should be false
323
+ book.should == @book
324
+ book.filename.should == @book.filename
325
+ book.excel.should == @book.excel
326
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
327
+ end
328
+ @book.close
329
+ book2 = Book.open(@simple_file1)
330
+ book2.sheet(1)[1,1].Value.should_not == @old_value
331
+ end
332
+
333
+ it "should force to read-write" do
334
+ Book.unobtrusively(@simple_file1, :writable => true, :read_only => false) do |book|
335
+ book.Readonly.should be false
336
+ book.should == @book
337
+ book.filename.should == @book.filename
338
+ book.excel.should == @book.excel
339
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
340
+ end
341
+ @book.close
342
+ book2 = Book.open(@simple_file1)
343
+ book2.sheet(1)[1,1].Value.should_not == @old_value
344
+ end
345
+
346
+ it "should force to read-write" do
347
+ e1 = Excel.create
348
+ Book.unobtrusively(@simple_file1, :writable => true, :rw_change_excel => e1) do |book|
349
+ book.Readonly.should be false
350
+ book.filename.should == @book.filename
351
+ book.excel.should == e1
352
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
353
+ end
354
+ @book.close
355
+ book2 = Book.open(@simple_file1)
356
+ book2.sheet(1)[1,1].Value.should_not == @old_value
357
+ end
358
+
359
+ it "should force to read-write" do
360
+ Book.unobtrusively(@simple_file1, :writable => true, :rw_change_excel => :current) do |book|
361
+ book.Readonly.should be false
362
+ book.should == @book
363
+ book.filename.should == @book.filename
364
+ book.excel.should == @book.excel
365
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
366
+ end
367
+ @book.close
368
+ book2 = Book.open(@simple_file1)
369
+ book2.sheet(1)[1,1].Value.should_not == @old_value
370
+ end
371
+
372
+ it "should force to read-write" do
373
+ Book.unobtrusively(@simple_file1, :writable => true, :rw_change_excel => :new) do |book|
374
+ book.Readonly.should be false
375
+ book.filename.should == @book.filename
376
+ book.excel.should_not == @book.excel
377
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
378
+ end
379
+ @book.close
380
+ book2 = Book.open(@simple_file1)
381
+ book2.sheet(1)[1,1].Value.should_not == @old_value
382
+ end
383
+
384
+ it "should force to read-write" do
385
+ Book.unobtrusively(@simple_file1, :writable => true, :read_only => false) do |book|
386
+ book.Readonly.should be false
387
+ book.should == @book
388
+ book.filename.should == @book.filename
389
+ book.excel.should == @book.excel
390
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
391
+ end
392
+ @book.close
393
+ book2 = Book.open(@simple_file1)
394
+ book2.sheet(1)[1,1].Value.should_not == @old_value
395
+ end
396
+
397
+ it "should force to read-only" do
398
+ Book.unobtrusively(@simple_file1, :read_only => true) do |book|
399
+ book.ReadOnly.should be true
400
+ book.should == @book
401
+ book.filename.should == @book.filename
402
+ book.excel.should == @book.excel
403
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
404
+ end
405
+ @book.close
406
+ book2 = Book.open(@simple_file1)
407
+ book2.sheet(1)[1,1].Value.should == @old_value
408
+ end
409
+
410
+ it "should force to read-only" do
411
+ Book.unobtrusively(@simple_file1, :read_only => true, :writable => false) do |book|
412
+ book.ReadOnly.should be true
413
+ book.should == @book
414
+ book.filename.should == @book.filename
415
+ book.excel.should == @book.excel
416
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
417
+ end
418
+ @book.close
419
+ book2 = Book.open(@simple_file1)
420
+ book2.sheet(1)[1,1].Value.should == @old_value
421
+ end
422
+
423
+ it "should open not writable" do
424
+ Book.unobtrusively(@simple_file1, :writable => false) do |book|
425
+ book.ReadOnly.should be true
426
+ book.should == @book
427
+ book.filename.should == @book.filename
428
+ book.excel.should == @book.excel
429
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
430
+ end
431
+ @book.close
432
+ book2 = Book.open(@simple_file1)
433
+ book2.sheet(1)[1,1].Value.should == @old_value
434
+ end
435
+ end
436
+
437
+ context "with open unsaved writable book" do
438
+
439
+ before do
440
+ @book = Book.open(@simple_file1)
441
+ @book.sheet(1)[1,1] = @book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
442
+ @old_value = @book.sheet(1)[1,1].Value
443
+ end
444
+
445
+ it "should open as read-write by default" do
446
+ Book.unobtrusively(@simple_file1) do |book|
447
+ book.Readonly.should be false
448
+ book.should == @book
449
+ book.filename.should == @book.filename
450
+ book.excel.should == @book.excel
451
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
452
+ end
453
+ @book.Saved.should be false
454
+ @book.sheet(1)[1,1].Value.should_not == @old_value
455
+ end
456
+
457
+ it "should open as read-write" do
458
+ Book.unobtrusively(@simple_file1, :read_only => false) do |book|
459
+ book.Readonly.should be false
460
+ book.should == @book
461
+ book.filename.should == @book.filename
462
+ book.excel.should == @book.excel
463
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
464
+ end
465
+ @book.Saved.should be false
466
+ @book.sheet(1)[1,1].Value.should_not == @old_value
467
+ end
468
+
469
+ it "should open as read-write" do
470
+ Book.unobtrusively(@simple_file1, :read_only => false, :writable => false) do |book|
471
+ book.Readonly.should be false
472
+ book.should == @book
473
+ book.filename.should == @book.filename
474
+ book.excel.should == @book.excel
475
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
476
+ end
477
+ @book.Saved.should be false
478
+ @book.sheet(1)[1,1].Value.should_not == @old_value
479
+ end
480
+
481
+ it "should force to read-write" do
482
+ Book.unobtrusively(@simple_file1, :writable => true) do |book|
483
+ book.Readonly.should be false
484
+ book.should == @book
485
+ book.filename.should == @book.filename
486
+ book.excel.should == @book.excel
487
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
488
+ end
489
+ @book.Saved.should be false
490
+ @book.sheet(1)[1,1].Value.should_not == @old_value
491
+ end
492
+
493
+ it "should open as read-write" do
494
+ Book.unobtrusively(@simple_file1, :writable => true, :read_only => false) do |book|
495
+ book.Readonly.should be false
496
+ book.should == @book
497
+ book.filename.should == @book.filename
498
+ book.excel.should == @book.excel
499
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
500
+ end
501
+ @book.Saved.should be false
502
+ @book.sheet(1)[1,1].Value.should_not == @old_value
503
+ end
504
+
505
+ it "should force to read-only (not implemented)" do
506
+ expect{
507
+ Book.unobtrusively(@simple_file1, :read_only => true)
508
+ }.to raise_error(NotImplementedREOError)
509
+ end
510
+
511
+ it "should force to read-only (not implemented)" do
512
+ expect{
513
+ Book.unobtrusively(@simple_file1, :read_only => true, :writable => false)
514
+ }.to raise_error(NotImplementedREOError)
515
+ end
516
+
517
+ #it "should force to read-only (not implemented)" do
518
+ # expect{
519
+ # Book.unobtrusively(@simple_file1, :read_only => true) do |book|
520
+ # book.ReadOnly.should be true
521
+ # book.should == @book
522
+ # book.filename.should == @book.filename
523
+ # book.excel.should == @book.excel
524
+ # book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
525
+ # end
526
+ # @book.Saved.should be false
527
+ # @book.sheet(1)[1,1].Value.should == @old_value
528
+ # end
529
+ # }.to raise_error(NotImplementedREOError)
530
+ #end
531
+
532
+ #it "should force to read-only" do
533
+ # expect{
534
+ # Book.unobtrusively(@simple_file1, :read_only => true, :writable => false) do |book|
535
+ # book.ReadOnly.should be true
536
+ # book.should == @book
537
+ # book.filename.should == @book.filename
538
+ # book.excel.should == @book.excel
539
+ # book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
540
+ # end
541
+ # @book.Saved.should be false
542
+ # @book.sheet(1)[1,1].Value.should == @old_value
543
+ # end
544
+ # }.to raise_error(NotImplementedREOError)
545
+ #end
546
+
547
+ it "should open not writable" do
548
+ Book.unobtrusively(@simple_file1, :writable => false) do |book|
549
+ book.ReadOnly.should be false
550
+ book.should == @book
551
+ book.filename.should == @book.filename
552
+ book.excel.should == @book.excel
553
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
554
+ end
555
+ @book.Saved.should be false
556
+ @book.sheet(1)[1,1].Value.should_not == @old_value
557
+ @book.close(:if_unsaved => :forget)
558
+ book2 = Book.open(@simple_file1)
559
+ book2.sheet(1)[1,1].Value.should_not == @old_value
560
+ end
561
+ end
562
+
563
+ context "with open unsaved read-only book" do
564
+
565
+ before do
566
+ @book = Book.open(@simple_file1, :read_only => true)
567
+ @book.sheet(1)[1,1] = @book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
568
+ @old_value = @book.sheet(1)[1,1].Value
569
+ end
570
+
571
+ it "should open as read-only by default" do
572
+ Book.unobtrusively(@simple_file1) do |book|
573
+ book.Readonly.should be true
574
+ book.should == @book
575
+ book.filename.should == @book.filename
576
+ book.excel.should == @book.excel
577
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
578
+ end
579
+ @book.Saved.should be false
580
+ @book.ReadOnly.should be true
581
+ @book.sheet(1)[1,1].Value.should_not == @old_value
582
+ @book.close
583
+ book2 = Book.open(@simple_file1)
584
+ book2.sheet(1)[1,1].Value.should_not == @old_value
585
+ end
586
+
587
+ it "should open as read-only" do
588
+ Book.unobtrusively(@simple_file1, :read_only => false) do |book|
589
+ book.Readonly.should be true
590
+ book.should == @book
591
+ book.filename.should == @book.filename
592
+ book.excel.should == @book.excel
593
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
594
+ end
595
+ @book.Saved.should be false
596
+ @book.ReadOnly.should be true
597
+ @book.sheet(1)[1,1].Value.should_not == @old_value
598
+ @book.close
599
+ book2 = Book.open(@simple_file1)
600
+ book2.sheet(1)[1,1].Value.should_not == @old_value
601
+ end
602
+
603
+ it "should open as read-only" do
604
+ Book.unobtrusively(@simple_file1, :read_only => false, :writable => false) do |book|
605
+ book.Readonly.should be true
606
+ book.should == @book
607
+ book.filename.should == @book.filename
608
+ book.excel.should == @book.excel
609
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
610
+ end
611
+ @book.Saved.should be false
612
+ @book.ReadOnly.should be true
613
+ @book.sheet(1)[1,1].Value.should_not == @old_value
614
+ @book.close
615
+ book2 = Book.open(@simple_file1)
616
+ book2.sheet(1)[1,1].Value.should_not == @old_value
617
+ end
618
+
619
+ it "should raise an error" do
620
+ expect{
621
+ Book.unobtrusively(@simple_file1, :writable => true)
622
+ }.to raise_error(NotImplementedREOError, "unsaved read-only workbook shall be written")
623
+ end
624
+
625
+ it "should raise an error" do
626
+ expect{
627
+ Book.unobtrusively(@simple_file1, :writable => true)
628
+ }.to raise_error(NotImplementedREOError, "unsaved read-only workbook shall be written")
629
+ end
630
+
631
+ it "should force to read-only" do
632
+ Book.unobtrusively(@simple_file1, :read_only => true) do |book|
633
+ book.ReadOnly.should be true
634
+ book.should == @book
635
+ book.filename.should == @book.filename
636
+ book.excel.should == @book.excel
637
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
638
+ end
639
+ @book.Saved.should be false
640
+ @book.ReadOnly.should be true
641
+ @book.sheet(1)[1,1].Value.should_not == @old_value
642
+ @book.close
643
+ book2 = Book.open(@simple_file1)
644
+ book2.sheet(1)[1,1].Value.should_not == @old_value
645
+ end
646
+
647
+ it "should force to read-only" do
648
+ Book.unobtrusively(@simple_file1, :read_only => true, :writable => false) do |book|
649
+ book.ReadOnly.should be true
650
+ book.should == @book
651
+ book.filename.should == @book.filename
652
+ book.excel.should == @book.excel
653
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
654
+ end
655
+ @book.Saved.should be false
656
+ @book.ReadOnly.should be true
657
+ @book.sheet(1)[1,1].Value.should_not == @old_value
658
+ @book.close
659
+ book2 = Book.open(@simple_file1)
660
+ book2.sheet(1)[1,1].Value.should_not == @old_value
661
+ end
662
+
663
+ it "should open not writable" do
664
+ Book.unobtrusively(@simple_file1, :writable => false) do |book|
665
+ book.ReadOnly.should be true
666
+ book.should == @book
667
+ book.filename.should == @book.filename
668
+ book.excel.should == @book.excel
669
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
670
+ end
671
+ @book.Saved.should be false
672
+ @book.ReadOnly.should be true
673
+ @book.sheet(1)[1,1].Value.should_not == @old_value
674
+ @book.close
675
+ book2 = Book.open(@simple_file1)
676
+ book2.sheet(1)[1,1].Value.should_not == @old_value
677
+ end
678
+ end
679
+
680
+ end
681
+
682
+ describe "intertweened blocks" do
683
+
684
+ context "with no book" do
685
+
686
+ it "should not close the book in the outer block" do
687
+ Book.unobtrusively(@simple_file1) do |book|
688
+ Book.unobtrusively(@simple_file1) do |book2|
689
+ book2.should == book
690
+ end
691
+ book.should be_alive
692
+ Book.unobtrusively(@simple_file1) do |book3|
693
+ book3.should == book
694
+ end
695
+ book.should be_alive
696
+ end
697
+ end
698
+
699
+ it "should write in the outer and inner block" do
700
+ Book.unobtrusively(@simple_file1) do |book|
701
+ @old_value = book.sheet(1)[1,1].Value
702
+ book.ReadOnly.should be false
703
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
704
+ book.Saved.should be false
705
+ book.sheet(1)[1,1].Value.should_not == @old_value
706
+ Book.unobtrusively(@simple_file1) do |book2|
707
+ book2.should == book
708
+ book2.ReadOnly.should be false
709
+ book2.Saved.should be false
710
+ book2.sheet(1)[1,1].Value.should_not == @old_value
711
+ book2.sheet(1)[1,1] = book2.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
712
+ book2.sheet(1)[1,1].Value.should == @old_value
713
+ end
714
+ book.should be_alive
715
+ book.Saved.should be false
716
+ book.sheet(1)[1,1].Value.should == @old_value
717
+ end
718
+ book = Book.open(@simple_file1)
719
+ book.sheet(1)[1,1].Value.should == @old_value
720
+ end
721
+
722
+ it "should write in the outer and not in the inner block" do
723
+ expect{
724
+ Book.unobtrusively(@simple_file1) do |book|
725
+ @old_value = book.sheet(1)[1,1].Value
726
+ book.ReadOnly.should be false
727
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
728
+ book.Saved.should be false
729
+ book.sheet(1)[1,1].Value.should_not == @old_value
730
+ Book.unobtrusively(@simple_file1, :read_only => true) do |book2|
731
+ book2.should == book
732
+ book2.ReadOnly.should be true
733
+ #book2.Saved.should be false
734
+ book2.sheet(1)[1,1].Value.should_not == @old_value
735
+ book2.sheet(1)[1,1] = book2.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
736
+ book2.sheet(1)[1,1].Value.should == @old_value
737
+ end
738
+ book.should be_alive
739
+ book.Saved.should be false
740
+ book.sheet(1)[1,1].Value.should_not == @old_value
741
+ end
742
+ book = Book.open(@simple_file1)
743
+ book.sheet(1)[1,1].Value.should_not == @old_value
744
+ }.to raise_error(NotImplementedREOError)
745
+ end
746
+
747
+ it "should write in the outer and not in the inner block" do
748
+ Book.unobtrusively(@simple_file1) do |book|
749
+ @old_value = book.sheet(1)[1,1].Value
750
+ book.ReadOnly.should be false
751
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
752
+ book.Saved.should be false
753
+ book.sheet(1)[1,1].Value.should_not == @old_value
754
+ Book.unobtrusively(@simple_file1, :writable => false) do |book2|
755
+ book2.should == book
756
+ book2.ReadOnly.should be false
757
+ book2.Saved.should be false
758
+ book2.sheet(1)[1,1].Value.should_not == @old_value
759
+ book2.sheet(1)[1,1] = book2.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
760
+ book2.sheet(1)[1,1].Value.should == @old_value
761
+ end
762
+ book.should be_alive
763
+ book.Saved.should be false
764
+ book.sheet(1)[1,1].Value.should == @old_value
765
+ end
766
+ book = Book.open(@simple_file1)
767
+ book.sheet(1)[1,1].Value.should == @old_value
768
+ end
769
+
770
+ it "should be read-only in the outer and write in the inner block" do
771
+ Book.unobtrusively(@simple_file1, :read_only => true) do |book|
772
+ @old_value = book.sheet(1)[1,1].Value
773
+ book.ReadOnly.should be true
774
+ book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
775
+ book.Saved.should be false
776
+ book.sheet(1)[1,1].Value.should_not == @old_value
777
+ Book.unobtrusively(@simple_file1) do |book2|
778
+ book2.should == book
779
+ book2.ReadOnly.should be true
780
+ book2.Saved.should be false
781
+ book2.sheet(1)[1,1].Value.should_not == @old_value
782
+ book2.sheet(1)[1,1] = book2.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
783
+ book2.sheet(1)[1,1].Value.should == @old_value
784
+ end
785
+ book.should be_alive
786
+ book.Saved.should be false
787
+ book.ReadOnly.should be true
788
+ book.sheet(1)[1,1].Value.should == @old_value
789
+ end
790
+ book = Book.open(@simple_file1)
791
+ book.sheet(1)[1,1].Value.should == @old_value
792
+ end
793
+
794
+ end
795
+
796
+ end
797
+
55
798
  describe "unchanging" do
56
799
 
57
800
  context "with openess" do
@@ -75,18 +818,18 @@ describe Book do
75
818
 
76
819
  context "with writability" do
77
820
 
78
- it "should remain writable" do
79
- book1 = Book.open(@simple_file1, :read_only => false)
821
+ it "should remain read_only" do
822
+ book1 = Book.open(@simple_file1, :read_only => true)
80
823
  Book.unobtrusively(@simple_file1) do |book|
81
824
  end
82
- book1.ReadOnly.should be_false
825
+ book1.ReadOnly.should be true
83
826
  end
84
827
 
85
- it "should remain read_only" do
86
- book1 = Book.open(@simple_file1, :read_only => true)
828
+ it "should remain writable" do
829
+ book1 = Book.open(@simple_file1, :read_only => false)
87
830
  Book.unobtrusively(@simple_file1) do |book|
88
831
  end
89
- book1.ReadOnly.should be_true
832
+ book1.ReadOnly.should be false
90
833
  end
91
834
 
92
835
  it "should write and remain read_only and open the workbook in another Excel" do
@@ -95,23 +838,24 @@ describe Book do
95
838
  Book.unobtrusively(@simple_file1) do |book|
96
839
  sheet = book.sheet(1)
97
840
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
98
- book.excel.should_not == book1.excel
841
+ book.excel.should == book1.excel
99
842
  end
100
- book1.ReadOnly.should be_true
843
+ book1.ReadOnly.should be true
101
844
  book1.close
102
845
  book2 = Book.open(@simple_file1)
103
- book2.sheet(1)[1,1].Value.should_not == old_value
846
+ book2.sheet(1)[1,1].Value.should == old_value
104
847
  end
105
848
 
106
849
  it "should write and remain read_only and open the workbook in the same Excel" do
107
850
  book1 = Book.open(@simple_file1, :read_only => true)
108
851
  old_value = book1.sheet(1)[1,1].Value
109
- Book.unobtrusively(@simple_file1, :readonly_excel => true) do |book|
852
+ Book.unobtrusively(@simple_file1, :writable => true) do |book|
853
+ book.ReadOnly.should be false
110
854
  sheet = book.sheet(1)
111
855
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
112
856
  book.excel.should == book1.excel
113
857
  end
114
- book1.ReadOnly.should be_true
858
+ book1.ReadOnly.should be true
115
859
  book1.close
116
860
  book2 = Book.open(@simple_file1)
117
861
  book2.sheet(1)[1,1].Value.should_not == old_value
@@ -125,15 +869,15 @@ describe Book do
125
869
  book1 = Book.open(@simple_file1, :visible => false)
126
870
  Book.unobtrusively(@simple_file1) do |book|
127
871
  end
128
- book1.excel.Visible.should be_false
872
+ book1.excel.Visible.should be false
129
873
  end
130
874
 
131
875
  it "should remain visible" do
132
876
  book1 = Book.open(@simple_file1, :visible => true)
133
877
  Book.unobtrusively(@simple_file1) do |book|
134
878
  end
135
- book1.excel.Visible.should be_true
136
- book1.Windows(book1.Name).Visible.should be_true
879
+ book1.excel.Visible.should be true
880
+ book1.Windows(book1.Name).Visible.should be true
137
881
  end
138
882
 
139
883
  end
@@ -144,14 +888,14 @@ describe Book do
144
888
  book1 = Book.open(@simple_file1, :check_compatibility => false)
145
889
  Book.unobtrusively(@simple_file1) do |book|
146
890
  end
147
- book1.CheckCompatibility.should be_false
891
+ book1.CheckCompatibility.should be false
148
892
  end
149
893
 
150
894
  it "should remain check-compatibility true" do
151
895
  book1 = Book.open(@simple_file1, :check_compatibility => true)
152
896
  Book.unobtrusively(@simple_file1) do |book|
153
897
  end
154
- book1.CheckCompatibility.should be_true
898
+ book1.CheckCompatibility.should be true
155
899
  end
156
900
 
157
901
  end
@@ -189,62 +933,65 @@ describe Book do
189
933
  Excel.close_all
190
934
  Book.unobtrusively(@simple_file) do |book|
191
935
  book.should be_a Book
192
- book.excel.Visible.should be_false
193
- book.CheckCompatibility.should be_false
194
- book.ReadOnly.should be_false
936
+ book.excel.Visible.should be false
937
+ book.CheckCompatibility.should be false
938
+ book.ReadOnly.should be false
195
939
  end
196
940
  end
197
941
 
198
942
  it "should open unobtrusively in a new Excel" do
199
943
  expect{ unobtrusively_ok? }.to_not raise_error
200
944
  end
201
-
202
- context "with two running excel instances" do
203
- before :all do
204
- Excel.close_all
205
- end
945
+ end
206
946
 
207
- before do
208
- @excel1 = Excel.new(:reuse => false)
209
- @excel2 = Excel.new(:reuse => false)
210
- end
947
+ context "with two running excel instances" do
948
+
949
+ before :all do
950
+ Excel.close_all
951
+ end
211
952
 
212
- after do
213
- Excel.kill_all
214
- end
953
+ before do
954
+ @excel1 = Excel.new(:reuse => false)
955
+ @excel2 = Excel.new(:reuse => false)
956
+ end
957
+
958
+ after do
959
+ Excel.kill_all
960
+ end
215
961
 
216
962
  it "should open unobtrusively in the first opened Excel" do
217
963
  Book.unobtrusively(@simple_file) do |book|
218
- book.excel.should == @excel1
219
- book.excel.should_not == @excel2
220
- end
964
+ book.excel.should == @excel1
965
+ book.excel.should_not == @excel2
966
+ end
221
967
  end
222
968
 
223
969
  it "should open unobtrusively in a new Excel" do
224
970
  Book.unobtrusively(@simple_file, :if_closed => :new) do |book|
225
971
  book.should be_a Book
226
972
  book.should be_alive
227
- book.excel.should_not == @excel1
228
- book.excel.should_not == @excel2
229
- end
973
+ book.excel.should_not == @excel1
974
+ book.excel.should_not == @excel2
975
+ end
230
976
  end
231
977
 
232
978
  it "should open unobtrusively in a given Excel" do
233
979
  Book.unobtrusively(@simple_file, :if_closed => @excel2) do |book|
234
980
  book.should be_a Book
235
981
  book.should be_alive
236
- book.excel.should_not == @excel1
237
- book.excel.should == @excel2
982
+ book.excel.should_not == @excel1
983
+ book.excel.should == @excel2
238
984
  end
239
985
  end
240
-
241
- it "should raise an error if the excel instance is not alive" do
242
- Excel.close_all
986
+
987
+ it "should open in another Excel instance if the given Excel instance is not alive" do
988
+ Excel.kill_all
989
+ sleep 2
243
990
  expect{
244
991
  Book.unobtrusively(@simple_file, :if_closed => @excel2) do |book|
992
+ book.should be_alive
245
993
  end
246
994
  }.to_not raise_error
247
- end
248
995
  end
249
996
 
250
997
  it "should raise an error if the option is invalid" do
@@ -305,12 +1052,12 @@ describe Book do
305
1052
  end
306
1053
 
307
1054
  it "should let a saved book saved" do
308
- @book.Saved.should be_true
1055
+ @book.Saved.should be true
309
1056
  @book.should be_alive
310
1057
  sheet = @book.sheet(1)
311
1058
  old_cell_value = sheet[1,1].value
312
1059
  unobtrusively_ok?
313
- @book.Saved.should be_true
1060
+ @book.Saved.should be true
314
1061
  @book.should be_alive
315
1062
  sheet = @book.sheet(1)
316
1063
  sheet[1,1].value.should_not == old_cell_value
@@ -320,35 +1067,35 @@ describe Book do
320
1067
  sheet = @book.sheet(1)
321
1068
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
322
1069
  old_cell_value = sheet[1,1].value
323
- @book.Saved.should be_false
1070
+ @book.Saved.should be false
324
1071
  unobtrusively_ok?
325
1072
  @book.should be_alive
326
- @book.Saved.should be_false
1073
+ @book.Saved.should be false
327
1074
  @book.close(:if_unsaved => :forget)
328
- @book2 = Book.open(@simple_file)
1075
+ @book2 = Book.open(@simple_file1)
329
1076
  sheet2 = @book2.sheet(1)
330
1077
  sheet2[1,1].value.should_not == old_cell_value
331
1078
  end
332
1079
 
333
1080
  it "should modify unobtrusively the second, writable book" do
334
- @book2 = Book.open(@simple_file, :force_excel => :new)
335
- @book.ReadOnly.should be_false
336
- @book2.ReadOnly.should be_true
1081
+ @book2 = Book.open(@simple_file1, :force_excel => :new)
1082
+ @book.ReadOnly.should be false
1083
+ @book2.ReadOnly.should be true
337
1084
  sheet = @book2.sheet(1)
338
1085
  old_cell_value = sheet[1,1].value
339
1086
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
340
1087
  unobtrusively_ok?
341
1088
  @book2.should be_alive
342
- @book2.Saved.should be_false
1089
+ @book2.Saved.should be false
343
1090
  @book2.close(:if_unsaved => :forget)
344
1091
  @book.close
345
1092
  new_book = Book.open(@simple_file1)
346
1093
  sheet2 = new_book.sheet(1)
347
1094
  sheet2[1,1].value.should_not == old_cell_value
348
1095
  end
349
-
350
1096
  end
351
1097
 
1098
+
352
1099
  context "with a closed book" do
353
1100
 
354
1101
  before do
@@ -385,7 +1132,7 @@ describe Book do
385
1132
  sheet = book.sheet(1)
386
1133
  cell = sheet[1,1]
387
1134
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
388
- book.Saved.should be_false
1135
+ book.Saved.should be false
389
1136
  end
390
1137
  @book.should be_alive
391
1138
  @book.close
@@ -409,7 +1156,7 @@ describe Book do
409
1156
  sheet = book.sheet(1)
410
1157
  cell = sheet[1,1]
411
1158
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
412
- book.Saved.should be_false
1159
+ book.Saved.should be false
413
1160
  end
414
1161
  @book.should_not be_alive
415
1162
  new_book = Book.open(@simple_file1)
@@ -427,7 +1174,7 @@ describe Book do
427
1174
  sheet = book.sheet(1)
428
1175
  cell = sheet[1,1]
429
1176
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
430
- book.Saved.should be_false
1177
+ book.Saved.should be false
431
1178
  end
432
1179
  @book.should be_alive
433
1180
  @book.close
@@ -450,7 +1197,7 @@ describe Book do
450
1197
  sheet = book.sheet(1)
451
1198
  cell = sheet[1,1]
452
1199
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
453
- book.Saved.should be_false
1200
+ book.Saved.should be false
454
1201
  end
455
1202
  @book.should_not be_alive
456
1203
  new_book = Book.open(@simple_file1)
@@ -496,11 +1243,11 @@ describe Book do
496
1243
  book.should be_a Book
497
1244
  book.should be_alive
498
1245
  book.excel.should == @book.excel
499
- book.excel.Visible.should be_true
1246
+ book.excel.Visible.should be true
500
1247
  end
501
1248
  @book.should be_alive
502
1249
  @book.should be_a Book
503
- @book.excel.Visible.should be_true
1250
+ @book.excel.Visible.should be true
504
1251
  end
505
1252
 
506
1253
  end
@@ -527,14 +1274,14 @@ describe Book do
527
1274
  Book.unobtrusively(@simple_file1, :if_closed => :new) do |book|
528
1275
  book.excel.should_not == @book.excel
529
1276
  book.excel.should_not == new_excel
530
- book.excel.visible.should be_false
1277
+ book.excel.visible.should be false
531
1278
  book.excel.displayalerts.should == :if_visible
532
1279
  @another_excel = book.excel
533
1280
  end
534
1281
  Book.unobtrusively(@simple_file1, :if_closed => :reuse) do |book|
535
1282
  book.excel.should == @book.excel
536
1283
  book.excel.should_not == new_excel
537
- book.excel.visible.should be_false
1284
+ book.excel.visible.should be false
538
1285
  book.excel.displayalerts.should == :if_visible
539
1286
  book.excel.should_not == @another_excel
540
1287
  end
@@ -569,25 +1316,25 @@ describe Book do
569
1316
  end
570
1317
 
571
1318
  it "should let the saved book saved" do
572
- @book.ReadOnly.should be_true
573
- @book.Saved.should be_true
1319
+ @book.ReadOnly.should be true
1320
+ @book.Saved.should be true
574
1321
  sheet = @book.sheet(1)
575
1322
  old_cell_value = sheet[1,1].value
576
1323
  unobtrusively_ok?
577
1324
  @book.should be_alive
578
- @book.Saved.should be_true
579
- @book.ReadOnly.should be_true
1325
+ @book.Saved.should be true
1326
+ @book.ReadOnly.should be true
580
1327
  @book.close
581
1328
  book2 = Book.open(@simple_file1)
582
1329
  sheet2 = book2.sheet(1)
583
- sheet2[1,1].value.should_not == old_cell_value
1330
+ sheet2[1,1].value.should == old_cell_value
584
1331
  end
585
1332
 
586
1333
  it "should let the unsaved book unsaved" do
587
- @book.ReadOnly.should be_true
1334
+ @book.ReadOnly.should be true
588
1335
  sheet = @book.sheet(1)
589
1336
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
590
- @book.Saved.should be_false
1337
+ @book.Saved.should be false
591
1338
  @book.should be_alive
592
1339
  Book.unobtrusively(@simple_file1) do |book|
593
1340
  book.should be_a Book
@@ -595,11 +1342,11 @@ describe Book do
595
1342
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
596
1343
  @cell_value = sheet[1,1].Value
597
1344
  book.should be_alive
598
- book.Saved.should be_false
1345
+ book.Saved.should be false
599
1346
  end
600
1347
  @book.should be_alive
601
- @book.Saved.should be_false
602
- @book.ReadOnly.should be_true
1348
+ @book.Saved.should be false
1349
+ @book.ReadOnly.should be true
603
1350
  @book.close
604
1351
  book2 = Book.open(@simple_file1)
605
1352
  sheet2 = book2.sheet(1)
@@ -608,9 +1355,9 @@ describe Book do
608
1355
  end
609
1356
 
610
1357
  it "should open unobtrusively by default the writable book" do
611
- book2 = Book.open(@simple_file, :force_excel => :new, :read_only => false)
612
- @book.ReadOnly.should be_true
613
- book2.Readonly.should be_false
1358
+ book2 = Book.open(@simple_file1, :force_excel => :new, :read_only => false)
1359
+ @book.ReadOnly.should be true
1360
+ book2.Readonly.should be false
614
1361
  sheet = @book.sheet(1)
615
1362
  cell_value = sheet[1,1].value
616
1363
  Book.unobtrusively(@simple_file1, :if_closed => :new) do |book|
@@ -620,60 +1367,10 @@ describe Book do
620
1367
  sheet = book.sheet(1)
621
1368
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
622
1369
  book.should be_alive
623
- book.Saved.should be_false
624
- end
625
- @book.Saved.should be_true
626
- @book.ReadOnly.should be_true
627
- @book.close
628
- book2.close
629
- book3 = Book.open(@simple_file1)
630
- new_sheet = book3.sheet(1)
631
- new_sheet[1,1].value.should_not == cell_value
632
- book3.close
633
- end
634
-
635
- it "should open unobtrusively by default the book in a new Excel such that the book is writable" do
636
- book2 = Book.open(@simple_file1, :force_excel => :new, :read_only => true)
637
- @book.ReadOnly.should be_true
638
- book2.Readonly.should be_true
639
- sheet = @book.sheet(1)
640
- cell_value = sheet[1,1].value
641
- Book.unobtrusively(@simple_file, :if_closed => :new) do |book|
642
- book.should be_a Book
643
- book.excel.should_not == book2.excel
644
- book.excel.should_not == @book.excel
645
- sheet = book.sheet(1)
646
- sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
647
- book.should be_alive
648
- book.Saved.should be_false
1370
+ book.Saved.should be false
649
1371
  end
650
- @book.Saved.should be_true
651
- @book.ReadOnly.should be_true
652
- @book.close
653
- book2.close
654
- book3 = Book.open(@simple_file1)
655
- new_sheet = book3.sheet(1)
656
- new_sheet[1,1].value.should_not == cell_value
657
- book3.close
658
- end
659
-
660
- it "should open unobtrusively the book in a new Excel such that the book is writable" do
661
- book2 = Book.open(@simple_file1, :force_excel => :new, :read_only => true)
662
- @book.ReadOnly.should be_true
663
- book2.Readonly.should be_true
664
- sheet = @book.sheet(1)
665
- cell_value = sheet[1,1].value
666
- Book.unobtrusively(@simple_file, :if_closed => :new) do |book|
667
- book.should be_a Book
668
- book.excel.should_not == book2.excel
669
- book.excel.should_not == @book.excel
670
- sheet = book.sheet(1)
671
- sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
672
- book.should be_alive
673
- book.Saved.should be_false
674
- end
675
- @book.Saved.should be_true
676
- @book.ReadOnly.should be_true
1372
+ @book.Saved.should be true
1373
+ @book.ReadOnly.should be true
677
1374
  @book.close
678
1375
  book2.close
679
1376
  book3 = Book.open(@simple_file1)
@@ -686,13 +1383,13 @@ describe Book do
686
1383
  excel1 = Excel.new(:reuse => false)
687
1384
  excel2 = Excel.new(:reuse => false)
688
1385
  book2 = Book.open(@simple_file1, :force_excel => :new, :read_only => true)
689
- @book.ReadOnly.should be_true
690
- book2.Readonly.should be_true
1386
+ @book.ReadOnly.should be true
1387
+ book2.Readonly.should be true
691
1388
  sheet = @book.sheet(1)
692
1389
  cell_value = sheet[1,1].value
693
- Book.unobtrusively(@simple_file1, :if_closed => :new, :readonly_excel => false) do |book|
1390
+ Book.unobtrusively(@simple_file1, :writable => true, :if_closed => :new, :rw_change_excel => :new) do |book|
694
1391
  book.should be_a Book
695
- book.ReadOnly.should be_false
1392
+ book.ReadOnly.should be false
696
1393
  book.excel.should_not == book2.excel
697
1394
  book.excel.should_not == @book.excel
698
1395
  book.excel.should_not == excel1
@@ -700,10 +1397,10 @@ describe Book do
700
1397
  sheet = book.sheet(1)
701
1398
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
702
1399
  book.should be_alive
703
- book.Saved.should be_false
1400
+ book.Saved.should be false
704
1401
  end
705
- @book.Saved.should be_true
706
- @book.ReadOnly.should be_true
1402
+ @book.Saved.should be true
1403
+ @book.ReadOnly.should be true
707
1404
  @book.close
708
1405
  book2.close
709
1406
  book3 = Book.open(@simple_file1)
@@ -716,21 +1413,21 @@ describe Book do
716
1413
  excel1 = Excel.new(:reuse => false)
717
1414
  excel2 = Excel.new(:reuse => false)
718
1415
  book2 = Book.open(@simple_file1, :force_excel => :new, :read_only => true)
719
- @book.ReadOnly.should be_true
720
- book2.Readonly.should be_true
1416
+ @book.ReadOnly.should be true
1417
+ book2.Readonly.should be true
721
1418
  sheet = @book.sheet(1)
722
1419
  cell_value = sheet[1,1].value
723
- Book.unobtrusively(@simple_file1, :if_closed => :new, :readonly_excel => true) do |book|
1420
+ Book.unobtrusively(@simple_file1, :writable => true, :if_closed => :new, :rw_change_excel => :current) do |book|
724
1421
  book.should be_a Book
725
1422
  book.excel.should == book2.excel
726
- book.ReadOnly.should be_false
1423
+ book.ReadOnly.should be false
727
1424
  sheet = book.sheet(1)
728
1425
  sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
729
1426
  book.should be_alive
730
- book.Saved.should be_false
1427
+ book.Saved.should be false
731
1428
  end
732
- book2.Saved.should be_true
733
- book2.ReadOnly.should be_true
1429
+ book2.Saved.should be true
1430
+ book2.ReadOnly.should be true
734
1431
  @book.close
735
1432
  book2.close
736
1433
  book3 = Book.open(@simple_file1)
@@ -741,8 +1438,8 @@ describe Book do
741
1438
 
742
1439
  it "should open unobtrusively the book in the Excel where it was opened most recently" do
743
1440
  book2 = Book.open(@simple_file1, :force_excel => :new, :read_only => true)
744
- @book.ReadOnly.should be_true
745
- book2.Readonly.should be_true
1441
+ @book.ReadOnly.should be true
1442
+ book2.Readonly.should be true
746
1443
  sheet = @book.sheet(1)
747
1444
  cell_value = sheet[1,1].value
748
1445
  Book.unobtrusively(@simple_file1, :if_closed => :new, :read_only => true) do |book|
@@ -750,10 +1447,10 @@ describe Book do
750
1447
  book.excel.should == book2.excel
751
1448
  book.excel.should_not == @book.excel
752
1449
  book.should be_alive
753
- book.Saved.should be_true
1450
+ book.Saved.should be true
754
1451
  end
755
- @book.Saved.should be_true
756
- @book.ReadOnly.should be_true
1452
+ @book.Saved.should be true
1453
+ @book.ReadOnly.should be true
757
1454
  @book.close
758
1455
  book2.close
759
1456
  end
@@ -796,16 +1493,16 @@ describe Book do
796
1493
  it "should save if the book was modified during unobtrusively" do
797
1494
  m_time = File.mtime(@book1.stored_filename)
798
1495
  Book.unobtrusively(@simple_file1, :if_closed => :new) do |book|
799
- @book1.Saved.should be_true
800
- book.Saved.should be_true
1496
+ @book1.Saved.should be true
1497
+ book.Saved.should be true
801
1498
  sheet = book.sheet(1)
802
1499
  cell = sheet[1,1]
803
1500
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
804
- @book1.Saved.should be_false
805
- book.Saved.should be_false
1501
+ @book1.Saved.should be false
1502
+ book.Saved.should be false
806
1503
  sleep 1
807
1504
  end
808
- @book1.Saved.should be_true
1505
+ @book1.Saved.should be true
809
1506
  m_time2 = File.mtime(@book1.stored_filename)
810
1507
  m_time2.should_not == m_time
811
1508
  end
@@ -813,8 +1510,8 @@ describe Book do
813
1510
  it "should not save the book if it was not modified during unobtrusively" do
814
1511
  m_time = File.mtime(@book1.stored_filename)
815
1512
  Book.unobtrusively(@simple_file1) do |book|
816
- @book1.Saved.should be_true
817
- book.Saved.should be_true
1513
+ @book1.Saved.should be true
1514
+ book.Saved.should be true
818
1515
  sleep 1
819
1516
  end
820
1517
  m_time2 = File.mtime(@book1.stored_filename)
@@ -834,7 +1531,7 @@ describe Book do
834
1531
  it "should yield the block result true" do
835
1532
  result =
836
1533
  Book.unobtrusively(@simple_file1) do |book|
837
- @book1.Saved.should be_true
1534
+ @book1.Saved.should be true
838
1535
  end
839
1536
  result.should == true
840
1537
  end
@@ -864,11 +1561,11 @@ describe Book do
864
1561
  Book.unobtrusively(@simple_file1) do |book|
865
1562
  sheet = book.sheet(1)
866
1563
  sheet[1,1] = 22
867
- @book1.Saved.should be_false
1564
+ @book1.Saved.should be false
868
1565
  42
869
1566
  end
870
1567
  result.should == 42
871
- @book1.Saved.should be_true
1568
+ @book1.Saved.should be true
872
1569
  end
873
1570
  end
874
1571
 
@@ -895,7 +1592,7 @@ describe Book do
895
1592
  sheet = book.sheet(1)
896
1593
  cell = sheet[1,1]
897
1594
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
898
- book.Saved.should be_false
1595
+ book.Saved.should be false
899
1596
  end
900
1597
  new_book = Book.open(@simple_file1)
901
1598
  sheet = new_book.sheet(1)
@@ -910,7 +1607,7 @@ describe Book do
910
1607
  sheet = book.sheet(1)
911
1608
  cell = sheet[1,1]
912
1609
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
913
- book.Saved.should be_false
1610
+ book.Saved.should be false
914
1611
  end
915
1612
  new_book = Book.open(@simple_file1)
916
1613
  sheet = new_book.sheet(1)
@@ -926,7 +1623,7 @@ describe Book do
926
1623
  sheet = book.sheet(1)
927
1624
  cell = sheet[1,1]
928
1625
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
929
- book.Saved.should be_false
1626
+ book.Saved.should be false
930
1627
  end
931
1628
  new_book = Book.open(@simple_file1)
932
1629
  sheet = new_book.sheet(1)
@@ -950,11 +1647,11 @@ describe Book do
950
1647
  Book.for_reading(@simple_file1) do |book|
951
1648
  book.should be_a Book
952
1649
  book.should be_alive
953
- book.Saved.should be_true
1650
+ book.Saved.should be true
954
1651
  sheet = book.sheet(1)
955
1652
  cell = sheet[1,1]
956
1653
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
957
- book.Saved.should be_false
1654
+ book.Saved.should be false
958
1655
  book.excel.should == @book.excel
959
1656
  end
960
1657
  new_book = Book.open(@simple_file1, :visible => true)
@@ -984,7 +1681,7 @@ describe Book do
984
1681
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
985
1682
  book.excel.should_not == @book.excel
986
1683
  book.excel.should_not == new_excel
987
- book.excel.visible.should be_false
1684
+ book.excel.visible.should be false
988
1685
  book.excel.displayalerts.should == :if_visible
989
1686
  end
990
1687
  new_book = Book.open(@simple_file1, :visible => true)
@@ -1026,7 +1723,7 @@ describe Book do
1026
1723
  sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
1027
1724
  book.excel.should_not == @book.excel
1028
1725
  book.excel.should_not == new_excel
1029
- book.excel.visible.should be_false
1726
+ book.excel.visible.should be false
1030
1727
  book.excel.displayalerts.should == :if_visible
1031
1728
  end
1032
1729
  new_book = Book.open(@simple_file1, :visible => true)
@@ -1037,3 +1734,4 @@ describe Book do
1037
1734
  end
1038
1735
 
1039
1736
  end
1737
+