Sha256: cf0c428d52dd8ae76f6654826b7628fc8e708a4d6d215f656044308a1bcd0f1b
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
require 'tc_helper.rb' class TestBarSeries < Test::Unit::TestCase def setup p = Axlsx::Package.new @ws = p.workbook.add_worksheet :name=>"hmmm" @chart = @ws.add_chart Axlsx::Bar3DChart, :title => "fishery" @series = @chart.add_series( data: [0, 1, 2], labels: ['zero', 'one', 'two'], title: 'bob', colors: ['FF0000', '00FF00', '0000FF'], shape: :cone, series_color: '5A5A5A' ) end def test_initialize assert_equal(@series.title.text, "bob", "series title has been applied") assert_equal(@series.data.class, Axlsx::NumDataSource, "data option applied") assert_equal(@series.shape, :cone, "series shape has been applied") assert_equal(@series.series_color, '5A5A5A', 'series color has been applied') assert(@series.data.is_a?(Axlsx::NumDataSource)) assert(@series.labels.is_a?(Axlsx::AxDataSource)) end def test_colors assert_equal(@series.colors.size, 3) end def test_shape assert_raise(ArgumentError, "require valid shape") { @series.shape = :teardropt } assert_nothing_raised("allow valid shape") { @series.shape = :box } assert(@series.shape == :box) end def test_to_xml_string doc = Nokogiri::XML(@chart.to_xml_string) @series.colors.each_with_index do |color, index| assert_equal(doc.xpath("//c:dPt/c:idx[@val='#{index}']").size,1) assert_equal(doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size,1) end assert_equal(doc.xpath('//c:spPr[not(ancestor::c:dPt)]/a:solidFill/a:srgbClr').first.get_attribute('val'), '5A5A5A', 'series color has been applied') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
caxlsx-3.2.0 | test/drawing/tc_bar_series.rb |