File: parse_error_test.rb

package info (click to toggle)
ruby-multi-xml 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 472 kB
  • sloc: ruby: 2,822; sh: 4; makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,402 bytes parent folder | download
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require "test_helper"

# Tests for ParseErrorTest
class ParseErrorTest < Minitest::Test
  cover "MultiXml*"

  def test_parse_error_stores_message
    error = MultiXml::ParseError.new("Test message")

    assert_equal "Test message", error.message
  end

  def test_parse_error_with_nil_message_has_default_message
    error = MultiXml::ParseError.new

    assert_equal "MultiXml::ParseError", error.message
  end

  def test_parse_error_stores_xml
    error = MultiXml::ParseError.new("msg", xml: "<bad>")

    assert_equal "<bad>", error.xml
  end

  def test_parse_error_stores_cause
    cause = StandardError.new("original")
    error = MultiXml::ParseError.new("msg", cause: cause)

    assert_equal cause, error.cause
  end

  def test_parse_error_xml_defaults_to_nil
    error = MultiXml::ParseError.new("msg")

    assert_nil error.xml
  end

  def test_parse_error_cause_defaults_to_nil
    error = MultiXml::ParseError.new("msg")

    assert_nil error.cause
  end

  def test_parse_error_with_all_parameters
    cause = StandardError.new("original")
    error = MultiXml::ParseError.new("Test", xml: "<xml/>", cause: cause)

    assert_equal "Test", error.message
    assert_equal "<xml/>", error.xml
    assert_equal cause, error.cause
  end

  def test_parse_error_inherits_from_standard_error
    error = MultiXml::ParseError.new("test")

    assert_kind_of StandardError, error
  end
end