axlsx 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/README.md +26 -7
  2. data/Rakefile +2 -1
  3. data/examples/chart_colors.xlsx +0 -0
  4. data/examples/data_validation.rb +50 -0
  5. data/examples/example.xlsx +0 -0
  6. data/examples/example_streamed.xlsx +0 -0
  7. data/examples/examples_saved.xlsx +0 -0
  8. data/examples/fish.xlsx +0 -0
  9. data/examples/no-use_autowidth.xlsx +0 -0
  10. data/examples/pareto.rb +28 -0
  11. data/examples/pareto.xlsx +0 -0
  12. data/examples/pie_chart.rb +16 -0
  13. data/examples/pie_chart.xlsx +0 -0
  14. data/examples/pie_chart_saved.xlsx +0 -0
  15. data/examples/shared_strings_example.xlsx +0 -0
  16. data/examples/sheet_protection.rb +10 -0
  17. data/examples/sheet_protection.xlsx +0 -0
  18. data/examples/two_cell_anchor_image.rb +11 -0
  19. data/examples/two_cell_anchor_image.xlsx +0 -0
  20. data/examples/~$pie_chart_saved.xlsx +0 -0
  21. data/lib/axlsx.rb +7 -0
  22. data/lib/axlsx/content_type/default.rb +15 -9
  23. data/lib/axlsx/content_type/override.rb +10 -6
  24. data/lib/axlsx/doc_props/app.rb +152 -99
  25. data/lib/axlsx/drawing/axis.rb +30 -23
  26. data/lib/axlsx/drawing/bar_series.rb +1 -1
  27. data/lib/axlsx/drawing/drawing.rb +7 -2
  28. data/lib/axlsx/drawing/pic.rb +44 -4
  29. data/lib/axlsx/drawing/two_cell_anchor.rb +6 -1
  30. data/lib/axlsx/drawing/vml_shape.rb +2 -5
  31. data/lib/axlsx/rels/relationships.rb +1 -1
  32. data/lib/axlsx/stylesheet/table_style.rb +3 -3
  33. data/lib/axlsx/util/simple_typed_list.rb +0 -13
  34. data/lib/axlsx/util/validators.rb +21 -0
  35. data/lib/axlsx/version.rb +1 -1
  36. data/lib/axlsx/workbook/workbook.rb +2 -0
  37. data/lib/axlsx/workbook/worksheet/cell.rb +3 -4
  38. data/lib/axlsx/workbook/worksheet/comment.rb +3 -9
  39. data/lib/axlsx/workbook/worksheet/data_validation.rb +245 -0
  40. data/lib/axlsx/workbook/worksheet/page_setup.rb +17 -3
  41. data/lib/axlsx/workbook/worksheet/row.rb +34 -18
  42. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +224 -0
  43. data/lib/axlsx/workbook/worksheet/table.rb +2 -2
  44. data/lib/axlsx/workbook/worksheet/worksheet.rb +57 -22
  45. data/test/doc_props/tc_app.rb +31 -1
  46. data/test/drawing/tc_axis.rb +12 -2
  47. data/test/drawing/tc_chart.rb +21 -3
  48. data/test/drawing/tc_drawing.rb +6 -1
  49. data/test/drawing/tc_hyperlink.rb +0 -5
  50. data/test/drawing/tc_pic.rb +22 -2
  51. data/test/drawing/tc_scatter_chart.rb +6 -1
  52. data/test/drawing/tc_two_cell_anchor.rb +1 -2
  53. data/test/stylesheet/tc_styles.rb +3 -4
  54. data/test/stylesheet/tc_table_style.rb +8 -0
  55. data/test/stylesheet/tc_table_style_element.rb +10 -1
  56. data/test/tc_package.rb +43 -15
  57. data/test/util/tc_simple_typed_list.rb +13 -0
  58. data/test/util/tc_validators.rb +7 -7
  59. data/test/workbook/worksheet/table/tc_table.rb +3 -3
  60. data/test/workbook/worksheet/tc_cell.rb +15 -6
  61. data/test/workbook/worksheet/tc_col.rb +9 -0
  62. data/test/workbook/worksheet/tc_comment.rb +8 -7
  63. data/test/workbook/worksheet/tc_comments.rb +8 -1
  64. data/test/workbook/worksheet/tc_conditional_formatting.rb +44 -0
  65. data/test/workbook/worksheet/tc_data_bar.rb +1 -1
  66. data/test/workbook/worksheet/tc_data_validation.rb +265 -0
  67. data/test/workbook/worksheet/tc_page_setup.rb +22 -4
  68. data/test/workbook/worksheet/tc_row.rb +14 -2
  69. data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
  70. data/test/workbook/worksheet/tc_worksheet.rb +29 -4
  71. metadata +31 -10
@@ -1,9 +1,39 @@
1
1
  require 'tc_helper.rb'
2
2
 
3
3
  class TestApp < Test::Unit::TestCase
4
+ def setup
5
+ options = {
6
+ :'Template' => 'Foo.xlt',
7
+ :'Manager' => 'Penny',
8
+ :'Company' => "Bob's Repair",
9
+ :'Pages' => 1,
10
+ :'Words' => 2,
11
+ :'Characters' => 7,
12
+ :'PresentationFormat' => 'any',
13
+ :'Lines' => 1,
14
+ :'Paragraphs' => 1,
15
+ :'Slides' => 4,
16
+ :'Notes' => 1,
17
+ :'TotalTime' => 2,
18
+ :'HidddenSlides' => 3,
19
+ :'MMClips' => 10,
20
+ :'ScaleCrop' => true,
21
+ :'LinksUpToDate' => true,
22
+ :'CharactersWithSpaces' => 9,
23
+ :'SharedDoc' => false,
24
+ :'HyperlinkBase' => 'foo',
25
+ :'HyperlInksChanged' => false,
26
+ :'Application' => 'axlsx',
27
+ :'AppVersion' => '1.1.5',
28
+ :'DocSecurity' => 0
29
+ }
30
+
31
+ @app = Axlsx::App.new options
32
+
33
+ end
4
34
  def test_valid_document
5
35
  schema = Nokogiri::XML::Schema(File.open(Axlsx::APP_XSD))
6
- doc = Nokogiri::XML(Axlsx::App.new.to_xml_string)
36
+ doc = Nokogiri::XML(@app.to_xml_string)
7
37
  errors = []
8
38
  schema.validate(doc).each do |error|
9
39
  errors << error
@@ -2,7 +2,7 @@ require 'tc_helper.rb'
2
2
 
3
3
  class TestAxis < Test::Unit::TestCase
4
4
  def setup
5
- @axis = Axlsx::Axis.new 12345, 54321
5
+ @axis = Axlsx::Axis.new 12345, 54321, :gridlines => false
6
6
  end
7
7
  def teardown
8
8
  end
@@ -13,7 +13,7 @@ class TestAxis < Test::Unit::TestCase
13
13
  assert_equal(@axis.tickLblPos, :nextTo, "tick label position default incorrect")
14
14
  assert_equal(@axis.crosses, :autoZero, "tick label position default incorrect")
15
15
  assert(@axis.scaling.is_a?(Axlsx::Scaling) && @axis.scaling.orientation == :minMax, "scaling default incorrect")
16
- assert_raise(ArgumentError) { Axlsx::Axis.new -1234, 'abcd' }
16
+ assert_raise(ArgumentError) { Axlsx::Axis.new( -1234, 'abcd') }
17
17
  end
18
18
 
19
19
  def test_axis_position
@@ -48,5 +48,15 @@ class TestAxis < Test::Unit::TestCase
48
48
  assert_raise(ArgumentError, "requires valid gridlines") { @axis.gridlines = 'alice' }
49
49
  assert_nothing_raised("accepts valid crosses") { @axis.gridlines = false }
50
50
  end
51
+
52
+ def test_to_xml_string
53
+ str = '<?xml version="1.0" encoding="UTF-8"?>'
54
+ str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << '">'
55
+ doc = Nokogiri::XML(@axis.to_xml_string(str))
56
+ assert(doc.xpath('//a:noFill'))
57
+ assert(doc.xpath("//c:crosses[@val='#{@axis.crosses.to_s}']"))
58
+ assert(doc.xpath("//c:crossAx[@val='#{@axis.crossAx.to_s}']"))
59
+ assert(doc.xpath("//a:bodyPr[@rot='#{@axis.label_rotation.to_s}']"))
51
60
 
61
+ end
52
62
  end
@@ -22,11 +22,16 @@ class TestChart < Test::Unit::TestCase
22
22
  @chart.title.text = 'wowzer'
23
23
  assert_equal(@chart.title.text, "wowzer", "the title text via a string")
24
24
  assert_equal(@chart.title.cell, nil, "the title cell is nil as we set the title with text.")
25
- @chart.title.cell = @row.cells.first
25
+ @chart.title = @row.cells.first
26
26
  assert_equal(@chart.title.text, "one", "the title text was set via cell reference")
27
27
  assert_equal(@chart.title.cell, @row.cells.first)
28
28
  end
29
29
 
30
+ def test_to_from_marker_access
31
+ assert(@chart.to.is_a?(Axlsx::Marker))
32
+ assert(@chart.from.is_a?(Axlsx::Marker))
33
+ end
34
+
30
35
  def test_style
31
36
  assert_raise(ArgumentError) { @chart.style = 49 }
32
37
  assert_nothing_raised { @chart.style = 2 }
@@ -34,16 +39,29 @@ class TestChart < Test::Unit::TestCase
34
39
  end
35
40
 
36
41
  def test_start_at
37
- @chart.start_at 15,25
42
+ @chart.start_at 15, 25
38
43
  assert_equal(@chart.graphic_frame.anchor.from.col, 15)
39
44
  assert_equal(@chart.graphic_frame.anchor.from.row, 25)
40
-
45
+ @chart.start_at @row.cells.first
46
+ assert_equal(@chart.graphic_frame.anchor.from.col, 0)
47
+ assert_equal(@chart.graphic_frame.anchor.from.row, 0)
48
+ @chart.start_at [5,6]
49
+ assert_equal(@chart.graphic_frame.anchor.from.col, 5)
50
+ assert_equal(@chart.graphic_frame.anchor.from.row, 6)
51
+
41
52
  end
42
53
 
43
54
  def test_end_at
44
55
  @chart.end_at 25, 90
45
56
  assert_equal(@chart.graphic_frame.anchor.to.col, 25)
46
57
  assert_equal(@chart.graphic_frame.anchor.to.row, 90)
58
+ @chart.end_at @row.cells.last
59
+ assert_equal(@chart.graphic_frame.anchor.to.col, 2)
60
+ assert_equal(@chart.graphic_frame.anchor.to.row, 0)
61
+ @chart.end_at [10,11]
62
+ assert_equal(@chart.graphic_frame.anchor.to.col, 10)
63
+ assert_equal(@chart.graphic_frame.anchor.to.row, 11)
64
+
47
65
  end
48
66
 
49
67
  def test_add_series
@@ -32,7 +32,12 @@ class TestDrawing < Test::Unit::TestCase
32
32
  assert_equal(600, image.width)
33
33
  assert_equal(400, image.height)
34
34
  end
35
-
35
+ def test_add_two_cell_anchor_image
36
+ src = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
37
+ image = @ws.add_image(:image_src => src, :start_at=>[0,0], :end_at => [15,0])
38
+ assert(@ws.drawing.anchors.last.is_a?(Axlsx::TwoCellAnchor))
39
+ assert(image.is_a?(Axlsx::Pic))
40
+ end
36
41
  def test_charts
37
42
  assert(@ws.drawing.charts.empty?)
38
43
  chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
@@ -19,11 +19,6 @@ class TestHyperlink < Test::Unit::TestCase
19
19
  assert_equal(@hyperlink.href, "http://axlsx.blogspot.com")
20
20
  end
21
21
 
22
- def test_invalidUrl
23
- assert_nothing_raised { @hyperlink.invalidUrl = "http://axlsx.blogspot.com" }
24
- assert_equal(@hyperlink.invalidUrl, "http://axlsx.blogspot.com")
25
- end
26
-
27
22
  def test_tgtFrame
28
23
  assert_nothing_raised { @hyperlink.tgtFrame = "http://axlsx.blogspot.com" }
29
24
  assert_equal(@hyperlink.tgtFrame, "http://axlsx.blogspot.com")
@@ -6,7 +6,7 @@ class TestPic < Test::Unit::TestCase
6
6
  @p = Axlsx::Package.new
7
7
  ws = @p.workbook.add_worksheet
8
8
  @test_img = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
9
- @image = ws.add_image :image_src => @test_img
9
+ @image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?"
10
10
  end
11
11
 
12
12
  def teardown
@@ -14,11 +14,31 @@ class TestPic < Test::Unit::TestCase
14
14
 
15
15
  def test_initialization
16
16
  assert_equal(@p.workbook.images.first, @image)
17
+ assert_equal(@image.file_name, 'image1.jpeg')
17
18
  assert_equal(@image.image_src, @test_img)
18
19
  end
19
20
 
21
+ def test_anchor_swapping
22
+ #swap from one cell to two cell when end_at is specified
23
+ assert(@image.anchor.is_a?(Axlsx::OneCellAnchor))
24
+ start_at = @image.anchor.from
25
+ @image.end_at 10,5
26
+ assert(@image.anchor.is_a?(Axlsx::TwoCellAnchor))
27
+ assert_equal(start_at.col, @image.anchor.from.col)
28
+ assert_equal(start_at.row, @image.anchor.from.row)
29
+ assert_equal(10,@image.anchor.to.col)
30
+ assert_equal(5, @image.anchor.to.row)
31
+
32
+ #swap from two cell to one cell when width or height are specified
33
+ @image.width = 200
34
+ assert(@image.anchor.is_a?(Axlsx::OneCellAnchor))
35
+ assert_equal(start_at.col, @image.anchor.from.col)
36
+ assert_equal(start_at.row, @image.anchor.from.row)
37
+ assert_equal(200, @image.width)
38
+
39
+ end
20
40
  def test_hyperlink
21
- assert_equal(@image.hyperlink, nil)
41
+ assert_equal(@image.hyperlink.href, "https://github.com/randym")
22
42
  @image.hyperlink = "http://axlsx.blogspot.com"
23
43
  assert_equal(@image.hyperlink.href, "http://axlsx.blogspot.com")
24
44
  end
@@ -4,7 +4,7 @@ class TestScatterChart < Test::Unit::TestCase
4
4
  def setup
5
5
  @p = Axlsx::Package.new
6
6
  @chart = nil
7
- ws = @p.workbook.add_worksheet do |sheet|
7
+ @p.workbook.add_worksheet do |sheet|
8
8
  sheet.add_row ["First", 1, 5, 7, 9]
9
9
  sheet.add_row ["", 1, 25, 49, 81]
10
10
  sheet.add_row ["Second", 5, 2, 14, 9]
@@ -22,6 +22,11 @@ class TestScatterChart < Test::Unit::TestCase
22
22
  def teardown
23
23
  end
24
24
 
25
+ def test_scatter_style
26
+ @chart.scatterStyle = :marker
27
+ assert(@chart.scatterStyle == :marker)
28
+ assert_raise(ArgumentError) { @chart.scatterStyle = :buckshot }
29
+ end
25
30
  def test_initialization
26
31
  assert_equal(@chart.scatterStyle, :lineMarker, "scatterStyle defualt incorrect")
27
32
  assert_equal(@chart.series_type, Axlsx::ScatterSeries, "series type incorrect")
@@ -5,8 +5,7 @@ class TestTwoCellAnchor < Test::Unit::TestCase
5
5
  def setup
6
6
  p = Axlsx::Package.new
7
7
  @ws = p.workbook.add_worksheet
8
- row = @ws.add_row ["one", 1, Time.now]
9
- title = Axlsx::Title.new
8
+ @ws.add_row ["one", 1, Time.now]
10
9
  chart = @ws.add_chart Axlsx::Bar3DChart
11
10
  @anchor = chart.graphic_frame.anchor
12
11
  end
@@ -19,7 +19,7 @@ class TestStyles < Test::Unit::TestCase
19
19
  end
20
20
  def test_add_style_border_hash
21
21
  border_count = @styles.borders.size
22
- s = @styles.add_style :border => {:style => :thin, :color => "FFFF0000"}
22
+ @styles.add_style :border => {:style => :thin, :color => "FFFF0000"}
23
23
  assert_equal(@styles.borders.size, border_count + 1)
24
24
  assert_equal(@styles.borders.last.prs.last.color.rgb, "FFFF0000")
25
25
  assert_raise(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"} }
@@ -27,7 +27,7 @@ class TestStyles < Test::Unit::TestCase
27
27
  end
28
28
 
29
29
  def test_add_style_border_edges
30
- s = @styles.add_style :border => { :style => :thin, :color => "0000FFFF", :edges => [:top, :bottom] }
30
+ @styles.add_style :border => { :style => :thin, :color => "0000FFFF", :edges => [:top, :bottom] }
31
31
  parts = @styles.borders.last.prs
32
32
  parts.each { |pr| assert_equal(pr.color.rgb, "0000FFFF", "Style is applied to #{pr.name} properly") }
33
33
  assert((parts.map { |pr| pr.name.to_s }.sort && ['bottom', 'top']).size == 2, "specify two edges, and you get two border prs")
@@ -44,7 +44,6 @@ class TestStyles < Test::Unit::TestCase
44
44
  def test_parse_num_fmt
45
45
  f_code = {:format_code => "YYYY/MM"}
46
46
  num_fmt = {:num_fmt => 5}
47
- both = { :format_code => "#000", :num_fmt => 0 }
48
47
  assert_equal(@styles.parse_num_fmt_options, nil, 'noop if neither :format_code or :num_fmt exist')
49
48
  max = @styles.numFmts.map{ |nf| nf.numFmtId }.max
50
49
  @styles.parse_num_fmt_options(f_code)
@@ -181,7 +180,7 @@ class TestStyles < Test::Unit::TestCase
181
180
 
182
181
  def test_basic_add_style_dxf
183
182
  border_count = @styles.borders.size
184
- s = @styles.add_style :border => {:style => :thin, :color => "FFFF0000"}, :type => :dxf
183
+ @styles.add_style :border => {:style => :thin, :color => "FFFF0000"}, :type => :dxf
185
184
  assert_equal(@styles.borders.size, border_count, "styles borders not affected")
186
185
  assert_equal(@styles.dxfs.last.border.prs.last.color.rgb, "FFFF0000")
187
186
  assert_raise(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"}, :type => :dxf }
@@ -13,6 +13,10 @@ class TestTableStyle < Test::Unit::TestCase
13
13
  assert_equal(@item.name, "fisher")
14
14
  assert_equal(@item.pivot, nil)
15
15
  assert_equal(@item.table, nil)
16
+ ts = Axlsx::TableStyle.new 'price', :pivot => true, :table => true
17
+ assert_equal(ts.name, 'price')
18
+ assert_equal(ts.pivot, true)
19
+ assert_equal(ts.table, true)
16
20
  end
17
21
 
18
22
  def test_name
@@ -33,4 +37,8 @@ class TestTableStyle < Test::Unit::TestCase
33
37
  assert_equal(@item.table, true)
34
38
  end
35
39
 
40
+ def test_to_xml_string
41
+ doc = Nokogiri::XML(@item.to_xml_string)
42
+ assert(doc.xpath("//tableStyle[@name='#{@item.name}']"))
43
+ end
36
44
  end
@@ -13,6 +13,10 @@ class TestTableStyleElement < Test::Unit::TestCase
13
13
  assert_equal(@item.type, nil)
14
14
  assert_equal(@item.size, nil)
15
15
  assert_equal(@item.dxfId, nil)
16
+ options = { :type => :headerRow, :size => 10, :dxfId => 1 }
17
+
18
+ tse = Axlsx::TableStyleElement.new options
19
+ options.each { |key, value| assert_equal(tse.send(key.to_sym), value) }
16
20
  end
17
21
 
18
22
  def test_type
@@ -32,5 +36,10 @@ class TestTableStyleElement < Test::Unit::TestCase
32
36
  assert_nothing_raised { @item.dxfId = 7 }
33
37
  assert_equal(@item.dxfId, 7)
34
38
  end
35
-
39
+
40
+ def test_to_xml_string
41
+ doc = Nokogiri::XML(@item.to_xml_string)
42
+ @item.type = :headerRow
43
+ assert(doc.xpath("//tableStyleElement[@type='#{@item.type.to_s}']"))
44
+ end
36
45
  end
@@ -1,12 +1,16 @@
1
+ # encoding: UTF-8
1
2
  require 'tc_helper.rb'
2
3
 
3
4
  class TestPackage < Test::Unit::TestCase
4
5
  def setup
5
6
  @package = Axlsx::Package.new
6
7
  ws = @package.workbook.add_worksheet
7
- ws.add_row ['yes', 'we', 'can']
8
- ws.add_comment :author => 'bob', :text => 'penny!', :ref => 'A1'
9
- chart = ws.add_chart Axlsx::Pie3DChart
8
+ ws.add_row ['Can', 'we', 'build it?']
9
+ ws.add_row ['Yes!', 'We', 'can!']
10
+ ws.add_comment :author => 'alice', :text => 'Hi Bob', :ref => 'A12'
11
+ ws.add_comment :author => 'bob', :text => 'Hi Alice', :ref => 'F19'
12
+
13
+ chart = ws.add_chart Axlsx::Pie3DChart, :title => "これは?", :start_at => [0,3]
10
14
  chart.add_series :data=>[1,2,3], :labels=>["a", "b", "c"]
11
15
  @fname = 'axlsx_test_serialization.xlsx'
12
16
  img = File.expand_path('../../examples/image1.jpeg', __FILE__)
@@ -14,8 +18,19 @@ class TestPackage < Test::Unit::TestCase
14
18
  image.width=720
15
19
  image.height=666
16
20
  image.hyperlink.tooltip = "Labeled Link"
17
- image.start_at 2, 2
21
+ image.start_at 5, 5
22
+ end
23
+ ws.add_image :image_src => File.expand_path('../../examples/image1.gif', __FILE__) do |image|
24
+ image.start_at 0, 20
25
+ image.width=360
26
+ image.height=333
18
27
  end
28
+ ws.add_image :image_src => File.expand_path('../../examples/image1.png', __FILE__) do |image|
29
+ image.start_at 9, 20
30
+ image.width = 180
31
+ image.height = 167
32
+ end
33
+ ws.add_table 'A1:C1'
19
34
  end
20
35
 
21
36
  def test_use_autowidth
@@ -48,22 +63,22 @@ class TestPackage < Test::Unit::TestCase
48
63
  end
49
64
 
50
65
  def test_serialization
51
- fname = 'axlsx_test_serialization.xlsx'
52
66
  assert_nothing_raised do
53
67
  begin
54
- z= @package.serialize(@fname)
55
- zf = Zip::ZipFile.open(@fname)
56
- @package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }
57
- File.delete(@fname)
68
+ @package.serialize(@fname)
69
+ zf = Zip::ZipFile.open(@fname)
70
+ @package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }
71
+ File.delete(@fname)
58
72
  rescue Errno::EACCES
59
- puts "WARNING:: test_serialization requires write access."
73
+ puts "WARNING:: test_serialization requires write access."
60
74
  end
61
- end
62
- end
75
+ end
76
+ end
63
77
 
64
78
  def test_validation
65
79
  assert_equal(@package.validate.size, 0, @package.validate)
66
- #how to test for failure? the internal validations on the models are so strict I cant break anthing.....
80
+ Axlsx::Workbook.send(:class_variable_set, :@@date1904, 9900)
81
+ assert(@package.validate.size > 0)
67
82
  end
68
83
 
69
84
  def test_parts
@@ -85,7 +100,7 @@ class TestPackage < Test::Unit::TestCase
85
100
 
86
101
 
87
102
  #no mystery parts
88
- assert_equal(p.size, 15)
103
+ assert_equal(p.size, 18)
89
104
 
90
105
  end
91
106
 
@@ -113,11 +128,24 @@ class TestPackage < Test::Unit::TestCase
113
128
  def test_content_type_added_with_shared_strings
114
129
  @package.use_shared_strings = true
115
130
  ct = @package.send(:content_types)
116
- assert(ct.select { |ct| ct.ContentType == Axlsx::SHARED_STRINGS_CT }.size == 1)
131
+ assert(ct.select { |type| type.ContentType == Axlsx::SHARED_STRINGS_CT }.size == 1)
117
132
  end
118
133
 
119
134
  def test_name_to_indices
120
135
  assert(Axlsx::name_to_indices('A1') == [0,0])
121
136
  assert(Axlsx::name_to_indices('A100') == [0,99], 'needs to axcept rows that contain 0')
122
137
  end
138
+
139
+ def test_to_stream
140
+ stream = @package.to_stream
141
+ assert(stream.is_a?(StringIO))
142
+ # this is just a roundabout guess for a package as it is build now
143
+ # in testing.
144
+ assert(stream.size > 80000)
145
+ end
146
+
147
+ def test_encrypt
148
+ # this is no where near close to ready yet
149
+ assert(@package.encrypt('your_mom.xlsxl', 'has a password') == false)
150
+ end
123
151
  end
@@ -61,5 +61,18 @@ class TestSimpleTypedList < Test::Unit::TestCase
61
61
  assert_nothing_raised { @list.delete 0 }
62
62
  assert_nothing_raised { @list.delete 9 }
63
63
  end
64
+
65
+ def test_delete
66
+ @list.push 1
67
+ assert(@list.size == 1)
68
+ @list.delete 1
69
+ assert(@list.empty?)
70
+ end
64
71
 
72
+ def test_equality
73
+ @list.push 1
74
+ @list.push 2
75
+ assert_equal(@list, [1,2])
76
+
77
+ end
65
78
  end
@@ -8,15 +8,15 @@ class TestValidators < Test::Unit::TestCase
8
8
  def test_validators
9
9
  #unsigned_int
10
10
  assert_nothing_raised { Axlsx.validate_unsigned_int 1 }
11
- assert_nothing_raised { Axlsx.validate_unsigned_int +1 }
12
- assert_raise(ArgumentError) { Axlsx.validate_unsigned_int -1 }
13
- assert_raise(ArgumentError) { Axlsx.validate_unsigned_int '1' }
11
+ assert_nothing_raised { Axlsx.validate_unsigned_int(+1) }
12
+ assert_raise(ArgumentError) { Axlsx.validate_unsigned_int(-1)}
13
+ assert_raise(ArgumentError) { Axlsx.validate_unsigned_int('1') }
14
14
 
15
15
  #int
16
- assert_nothing_raised { Axlsx.validate_int 1 }
17
- assert_nothing_raised { Axlsx.validate_int -1 }
18
- assert_raise(ArgumentError) { Axlsx.validate_int 'a' }
19
- assert_raise(ArgumentError) { Axlsx.validate_int Array }
16
+ assert_nothing_raised { Axlsx.validate_int(1) }
17
+ assert_nothing_raised { Axlsx.validate_int(-1) }
18
+ assert_raise(ArgumentError) { Axlsx.validate_int('a')}
19
+ assert_raise(ArgumentError) { Axlsx.validate_int(Array) }
20
20
 
21
21
  #boolean (as 0 or 1, :true, :false, true, false, or "true," "false")
22
22
  [0,1,:true, :false, true, false, "true", "false"].each do |v|