Sha256: 9176846c79f75ab63f03bc4a902ddaf1c366a3f469bb899a4c8d84bc36d25391

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

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

class A
  include SAXMachine
  element :title
end

class B < A
  element :b
end

class C < B
  element :c
end

describe "SAXMachine inheritance" do
  before do
    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

  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

1 entries across 1 versions & 1 rubygems

Version Path
sax-machine-0.3.0 spec/sax-machine/sax_include_spec.rb