Sha256: ffa7be05c5564dd2c1cf739bd52a3f3fe56a5b8b327e383840f266d93a5f6b5c

Contents?: true

Size: 858 Bytes

Versions: 16

Compression:

Stored size: 858 Bytes

Contents

require "minitest_helper"

module Hermod
  describe XmlSection do

    DateXml = XmlSection.build(formats: {date: "%Y-%m-%d"}) do |builder|
      builder.date_node :date_of_birth
      builder.date_node :anniversary, optional: true
    end

    describe "Date nodes" do
      subject do
        DateXml.new do |dummy|
          dummy.date_of_birth Date.new(1988, 8, 13)
        end
      end

      it "should format the date with the given date string" do
        value_of_node("DateOfBirth").must_equal "1988-08-13"
      end

      it "should raise an error if given something that isn't a date" do
        proc { subject.anniversary "yesterday" }.must_raise InvalidInputError
      end

      it "should ignore blank dates if the date is optional" do
        subject.anniversary nil
        nodes("Anniversary").must_be_empty
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
hermod-2.6.2 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-2.6.1 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-2.5.3 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-2.5.2 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-2.5.1 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-2.5.0 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-2.4.1 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-2.4.0 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-2.2.0 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-2.1.0 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-1.2.9 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-1.2.8 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-1.2.7 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-1.2.6 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-1.2.5 spec/hermod/xml_section_builder/date_node_spec.rb
hermod-1.2.4 spec/hermod/xml_section_builder/date_node_spec.rb