From 0c36bf814631bc6dd8c5d7948bf26fe68223ea69 Mon Sep 17 00:00:00 2001 From: Denis Tataurov Date: Sun, 31 May 2015 13:51:21 +0300 Subject: [PATCH] Add specs for RichText which define the behaviour of RichText when row style is set --- test/workbook/worksheet/tc_rich_text.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/test/workbook/worksheet/tc_rich_text.rb b/test/workbook/worksheet/tc_rich_text.rb index d79d3021..24f95f10 100644 --- a/test/workbook/worksheet/tc_rich_text.rb +++ b/test/workbook/worksheet/tc_rich_text.rb @@ -24,7 +24,7 @@ def test_initialize row = @ws.add_row [rt_direct, rt_indirect] assert_equal(row[0].to_xml_string(0,0), row[1].to_xml_string(0,0)) end - + def test_textruns runs = @rt.runs assert_equal(runs.length, 27) @@ -33,7 +33,7 @@ def test_textruns assert_equal(runs[1].b, true) assert_equal(runs[1].i, false) end - + def test_implicit_richtext rt = Axlsx::RichText.new('a', :b => true) row_rt = @ws.add_row [rt] @@ -41,4 +41,22 @@ def test_implicit_richtext row_imp[0].b = true assert_equal(row_rt[0].to_xml_string(0,0), row_imp[0].to_xml_string(0,0)) end + + def test_row_style_is_used_by_default_in_rich_text_run + rt = Axlsx::RichText.new('a', sz: 30) + row = @ws.add_row [rt], style: [add_style(:sz => 52)] + assert_equal(rt.runs.first.sz, 52) + end + + def test_rich_text_options_is_more_relevant_than_row_style + rt = Axlsx::RichText.new('a', sz: 30) + row = @ws.add_row [rt], style: [add_style(:sz => 52)] + assert_equal(rt.runs.first.sz, 30) + end + + private + + def add_style(options={}) + @c.row.worksheet.workbook.styles.add_style options + end end