Sha256: e2032617c294a2b87a06e880266f3ded3568efb973aa5773d7433bdb0b8ff3a5

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "SAXMachine inheritance" do
  before do
    class A
      include SAXMachine
      element :title
    end

    class B < A
      element :b
    end

    class C < B
      element :c
    end

    xml = "<top><title>Test</title><b>Matched!</b><c>And Again</c></top>"
    @a = A.new
    @a.parse xml
    @b = B.new
    @b.parse xml
    @c = C.new
    @c.parse xml
  end

  after do
    Object.send(:remove_const, :A)
    Object.send(:remove_const, :B)
    Object.send(:remove_const, :C)
  end

  it { expect(@a).to be_a(A) }
  it { expect(@a).not_to be_a(B) }
  it { expect(@a).to be_a(SAXMachine) }
  it { expect(@a.title).to eq("Test") }
  it { expect(@b).to be_a(A) }
  it { expect(@b).to be_a(B) }
  it { expect(@b).to be_a(SAXMachine) }
  it { expect(@b.title).to eq("Test") }
  it { expect(@b.b).to eq("Matched!") }
  it { expect(@c).to be_a(A) }
  it { expect(@c).to be_a(B) }
  it { expect(@c).to be_a(C) }
  it { expect(@c).to be_a(SAXMachine) }
  it { expect(@c.title).to eq("Test") }
  it { expect(@c.b).to eq("Matched!") }
  it { expect(@c.c).to eq("And Again") }
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sax-machine-1.3.2 spec/sax-machine/sax_include_spec.rb
sax-machine-1.3.1 spec/sax-machine/sax_include_spec.rb
sax-machine-1.3.0 spec/sax-machine/sax_include_spec.rb
sax-machine-1.2.0 spec/sax-machine/sax_include_spec.rb
sax-machine-1.1.1 spec/sax-machine/sax_include_spec.rb
sax-machine-1.1.0 spec/sax-machine/sax_include_spec.rb
sax-machine-1.0.3 spec/sax-machine/sax_include_spec.rb
sax-machine-1.0.2 spec/sax-machine/sax_include_spec.rb
sax-machine-1.0.1 spec/sax-machine/sax_include_spec.rb
sax-machine-1.0.0 spec/sax-machine/sax_include_spec.rb