Sha256: e1c5fe612a2a040dd5b8c53c1c0f0eceaa4ad1ea4049b50ab56f85831a096c89

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

RSpec.describe Oasis::Etm::Tbody do
  let(:xml) do
    <<~XML
      <tbody valign="top">
        <row>
          <entry>Cell 1</entry>
          <entry>Cell 2</entry>
          <entry>Cell 3</entry>
        </row>
      </tbody>
    XML
  end

  describe ".from_xml" do
    subject(:tbody) { described_class.from_xml(xml) }

    it "parses valign attribute" do
      expect(tbody.valign).to eq("top")
    end

    it "parses rows" do
      expect(tbody.rows.size).to eq(1)
      expect(tbody.rows.first.entries.size).to eq(3)
      expect(tbody.rows.first.entries.first.content).to eq("Cell 1")
    end
  end

  describe "#to_xml" do
    subject(:tbody) do
      described_class.new(
        valign: "top",
        rows: [
          Oasis::Etm::Row.new(
            entries: [
              Oasis::Etm::Entry.new(content: "Cell 1"),
              Oasis::Etm::Entry.new(content: "Cell 2"),
              Oasis::Etm::Entry.new(content: "Cell 3"),
            ],
          ),
        ],
      )
    end

    it "generates valid XML" do
      expect(tbody.to_xml).to be_analogous_with(xml)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oasis-etm-0.1.0 spec/oasis/etm/tbody_spec.rb