Permalink
Browse files

Merge pull request #3 from vanderhoorn/master

Fix bug in sanitize_worksheets if 'sheets' is empty + add a test
  • Loading branch information...
2 parents dbb7915 + 6a1860e commit 1a4035579f6e3b003a3eb7e1cced37a9ee4959ff @zdavatz zdavatz committed Nov 29, 2011
@@ -96,6 +96,7 @@ def number_format_index workbook, format
@number_formats[workbook][format] || 0
end
def sanitize_worksheets sheets
+ return sheets if sheets.empty?
found_selected = false
sheets.each do |sheet|
found_selected ||= sheet.selected
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+# Excel::Writer::TestWorkbook -- Spreadsheet -- 20.07.2011
+
+$: << File.expand_path('../../../lib', File.dirname(__FILE__))
+
+require 'test/unit'
+require 'spreadsheet'
+
+module Spreadsheet
+ module Excel
+ module Writer
+ class TestWorkbook < Test::Unit::TestCase
+ def test_sanitize_worksheets
+ book = Spreadsheet::Excel::Workbook.new
+ assert_instance_of Excel::Workbook, book
+ assert_equal book.worksheets.size, 0
+ workbook_writer = Excel::Writer::Workbook.new book
+ assert_nothing_raised { workbook_writer.sanitize_worksheets book.worksheets }
+ end
+ end
+ end
+ end
+end
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-# Excel::Writer::TestWorksheet -- Spreadheet -- 21.11.2007 -- hwyss@ywesee.com
+# Excel::Writer::TestWorksheet -- Spreadsheet -- 21.11.2007 -- hwyss@ywesee.com
require 'test/unit'
require 'spreadsheet/excel/writer/worksheet'
View
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# encoding: utf-8
-# TestIntegration -- Spreadheet -- 08.10.2007 -- hwyss@ywesee.com
+# TestIntegration -- Spreadsheet -- 08.10.2007 -- hwyss@ywesee.com
$: << File.expand_path('../lib', File.dirname(__FILE__))
View
@@ -2,13 +2,14 @@
# suite.rb -- oddb -- 08.01.2009 -- hwyss@ywesee.com
require 'find'
+require 'rubygems'
here = File.dirname(__FILE__)
$: << here
Find.find(here) do |file|
- if /(?<!suite)\.rb$/o.match(file)
+ if /[^suite\W]\.rb$/o.match(file)
require file
end
end
View
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-# TestWorkbook -- Spreadheet -- 24.09.2008 -- hwyss@ywesee.com
+# TestWorkbook -- Spreadsheet -- 24.09.2008 -- hwyss@ywesee.com
$: << File.expand_path('../lib', File.dirname(__FILE__))
View
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-# TestWorksheet -- Spreadheet -- 30.09.2008 -- hwyss@ywesee.com
+# TestWorksheet -- Spreadsheet -- 30.09.2008 -- hwyss@ywesee.com
$: << File.expand_path('../lib', File.dirname(__FILE__))

0 comments on commit 1a40355

Please sign in to comment.