require 'helper'
require 'peddler/parsers/model'
require 'nokogiri'
class PeddlerModelParserTest < MiniTest::Test
def build(xml)
document = Nokogiri(xml)
Peddler::Parsers::Model.new(document)
end
def test_parses_money
xml = <<-EOF
USD
10.00
EOF
model = build(xml)
money = model.money_at_xpath('Price')
assert_equal '$10.00', money.format
end
def test_parses_japanese_yen
xml = <<-EOF
JPY
1000.00
EOF
model = build(xml)
money = model.money_at_xpath('Price')
assert_equal '¥1,000', money.format
end
def test_parses_truthy_value
xml = <<-EOF
true
EOF
model = build(xml)
assert_equal true, model.boolean_at_xpath('Bool')
xml = <<-EOF
Yes
EOF
model = build(xml)
assert_equal true, model.boolean_at_xpath('Bool')
end
def test_parses_falsy_value
xml = <<-EOF
No
EOF
model = build(xml)
assert_equal false, model.boolean_at_xpath('Bool')
end
end