diff options
| author | Randy Morgan <[email protected]> | 2012-09-30 18:29:19 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-09-30 18:29:19 +0900 |
| commit | a942008d3b0f4618a3d35541de6f97ad487a463c (patch) | |
| tree | 4444bf99b68d64d1ea072509b70cff8e2d2fd2e2 /test | |
| parent | abc54f36bfd9975c5e2f2968cfac3405c7a4d795 (diff) | |
| download | caxlsx-a942008d3b0f4618a3d35541de6f97ad487a463c.tar.gz caxlsx-a942008d3b0f4618a3d35541de6f97ad487a463c.zip | |
Extracted STRING_ATTRIBUTES and BOOLEAN_ATTRIBUTES into mixin from module
replaced with attr_accessor like methods:
string_attr_accessor
boolean_attr_accessor
defined in module.rb
Diffstat (limited to 'test')
| -rw-r--r-- | test/drawing/tc_d_lbls.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/test/drawing/tc_d_lbls.rb b/test/drawing/tc_d_lbls.rb index 5bd52a92..b8d3d1c4 100644 --- a/test/drawing/tc_d_lbls.rb +++ b/test/drawing/tc_d_lbls.rb @@ -4,19 +4,29 @@ class TestDLbls < Test::Unit::TestCase def setup @d_lbls = Axlsx::DLbls.new(Axlsx::Pie3DChart) + @boolean_attributes =[:show_legend_key, + :show_val, + :show_cat_name, + :show_ser_name, + :show_percent, + :show_bubble_size, + :show_leader_lines] end def test_initialization assert_equal(:bestFit, @d_lbls.d_lbl_pos) - Axlsx::DLbls::BOOLEAN_ATTRIBUTES.each do |attr| + @boolean_attributes.each do |attr| assert_equal(false, @d_lbls.send(attr)) end end def test_initialization_with_optoins - options_hash = Hash[*[Axlsx::DLbls::BOOLEAN_ATTRIBUTES.map { |name| [name, true] }] ] + + options_hash = Hash[*[@boolean_attributes.map { |name| [name, true] }] ] + d_lbls = Axlsx::DLbls.new(Axlsx::Pie3DChart, options_hash.merge( { :d_lbl_pos => :t })) - Axlsx::DLbls::BOOLEAN_ATTRIBUTES.each do |attr| + + @boolean_attributes.each do |attr| assert_equal(true, d_lbls.send(attr), "boolean attributes set by options") end assert_equal(:t, d_lbls.d_lbl_pos, "d_lbl_pos set by options") @@ -27,7 +37,7 @@ class TestDLbls < Test::Unit::TestCase end def test_boolean_attributes - Axlsx::DLbls::BOOLEAN_ATTRIBUTES.each do |attr| + @boolean_attributes.each do |attr| assert_raise(ArgumentError, "rejects non boolean value for #{attr}") { @d_lbls.send("#{attr}=", :foo) } assert_nothing_raised("accepts boolean value for #{attr}") { @d_lbls.send("#{attr}=", true) } assert_nothing_raised("accepts boolean value for #{attr}") { @d_lbls.send("#{attr}=", false) } |
