From 43d31eb7c4f04e3ddf3bf865d55e6ce8de7b7a69 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Fri, 23 Mar 2012 00:48:42 +0900 Subject: update add Styles#add_style to allow a simple hash to create a new border style --- test/stylesheet/tc_styles.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb index 1b7365b2..61a87bf7 100644 --- a/test/stylesheet/tc_styles.rb +++ b/test/stylesheet/tc_styles.rb @@ -2,12 +2,12 @@ require 'test/unit' require 'axlsx.rb' class TestStyles < Test::Unit::TestCase - def setup + def setup @styles = Axlsx::Styles.new end def teardown end - + def test_valid_document schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD)) doc = Nokogiri::XML(@styles.to_xml) @@ -18,7 +18,14 @@ class TestStyles < Test::Unit::TestCase end assert(errors.size == 0) end + def test_add_style_border_hash + border_count = @styles.borders.size + s = @styles.add_style :border => {:style=>:thin, :color => "FFFF0000"} + assert_equal(@styles.borders.size, border_count + 1) + assert_equal(@styles.borders.last.prs.last.color.rgb, "FFFF0000") + assert_raise(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"} } + end def test_add_style fill_count = @styles.fills.size @@ -44,9 +51,9 @@ class TestStyles < Test::Unit::TestCase assert_equal(xf.alignment.horizontal, :left, "horizontal alignment applied") assert_equal(xf.protection.hidden, true, "hidden protection set") assert_equal(xf.protection.locked, true, "cell locking set") - assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 } + assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 } + - assert_equal(xf.applyProtection, 1, "protection applied") assert_equal(xf.applyBorder, true, "border applied") assert_equal(xf.applyNumberFormat, true, "number format applied") -- cgit v1.2.3