Sha256: 8492fd229dd7782455fe6b43a6c25c72d97e285070538451cbe9475084cbc094

Contents?: true

Size: 992 Bytes

Versions: 1

Compression:

Stored size: 992 Bytes

Contents

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

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

    it "parses attributes" do
      expect(row.rowsep).to eq(1)
      expect(row.valign).to eq("middle")
    end

    it "parses entries" do
      expect(row.entries.size).to eq(3)
      expect(row.entries.map(&:content)).to eq(["Cell 1", "Cell 2", "Cell 3"])
    end
  end

  describe "#to_xml" do
    subject(:row) do
      described_class.new(
        rowsep: 1,
        valign: "middle",
        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(row.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/row_spec.rb