Sha256: b28bb933bfd3a52a5b62716c5229dcdc04aae307ec7f8b884c549223cd7ffbf6

Contents?: true

Size: 921 Bytes

Versions: 3

Compression:

Stored size: 921 Bytes

Contents

require 'tc_helper.rb'

class TestRelationships < Test::Unit::TestCase
  def setup
  end

  def teardown
  end

  def test_type
    assert_raise(ArgumentError) { Axlsx::Relationship.new 'type', 'target' }
    assert_nothing_raised { Axlsx::Relationship.new Axlsx::WORKSHEET_R, 'target' }
    assert_nothing_raised { Axlsx::Relationship.new Axlsx::COMMENT_R, 'target' }
  end

  def test_target_mode
    assert_raise(ArgumentError) { Axlsx::Relationship.new 'type', 'target', :target_mode => "FISH" }
    assert_nothing_raised { Axlsx::Relationship.new( Axlsx::WORKSHEET_R, 'target', :target_mode => :External) }
  end

  def test_ampersand_escaping_in_target
    r = Axlsx::Relationship.new(Axlsx::HYPERLINK_R, "http://example.com?foo=1&bar=2", :target_mod => :External)
    doc = Nokogiri::XML(r.to_xml_string(1))
    assert_equal(doc.xpath("//Relationship[@Target='http://example.com?foo=1&bar=2']").size, 1)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
axlsx-1.3.6 test/rels/tc_relationship.rb
axlsx-1.3.5 test/rels/tc_relationship.rb
axlsx-1.3.4 test/rels/tc_relationship.rb