require_relative './../test_helper'
require 'minitest/autorun'
class TestXMLRequired < Minitest::Test
def setup
@full_book = <
This & that
Johnny
BOOK
@book_missing_attr = <
This & that
Johnny
BOOK
@book_missing_text = <
Johnny
BOOK
@book_missing_array = <
This & that
BOOK
@book_missing_hash = <
This & that
Johnny
BOOK
end
def test_required_passes_on_prescence
BookWithRequired.from_xml(@full_book)
end
def test_required_throws_on_attr_absence
assert_raises ROXML::RequiredElementMissing do
BookWithRequired.from_xml(@book_missing_attr)
end
end
def test_required_throws_on_text_absence
assert_raises ROXML::RequiredElementMissing do
BookWithRequired.from_xml(@book_missing_text)
end
end
def test_required_throws_on_array_absence
assert_raises ROXML::RequiredElementMissing do
BookWithRequired.from_xml(@book_missing_array)
end
end
def test_required_throws_on_hash_absence
assert_raises ROXML::RequiredElementMissing do
BookWithRequired.from_xml(@book_missing_hash)
end
end
end