summaryrefslogtreecommitdiffhomepage
path: root/test/workbook/worksheet/tc_cfvo.rb
blob: dac48b231b2e6d6dc94d064a8312c5931d94045f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require 'tc_helper'

class TestCfvo < Test::Unit::TestCase
  def setup
    @cfvo = Axlsx::Cfvo.new(val: "0", type: :min)
  end

  def test_val
    assert_nothing_raised { @cfvo.val = "abc" }
    assert_equal("abc", @cfvo.val)
  end

  def test_type
    assert_raise(ArgumentError) { @cfvo.type = :invalid_type }
    assert_nothing_raised { @cfvo.type = :max }
    assert_equal(:max, @cfvo.type)
  end

  def test_gte
    assert_raise(ArgumentError) { @cfvo.gte = :bob }
    assert(@cfvo.gte)
    assert_nothing_raised { @cfvo.gte = false }
    refute(@cfvo.gte)
  end

  def test_to_xml_string
    doc = Nokogiri::XML.parse(@cfvo.to_xml_string)

    assert doc.xpath(".//cfvo[@type='min'][@val=0][@gte=true]")
  end
end