require File.join(__FILE__.gsub(/(.*)?\/spec\/.*$/, '\1'), 'spec/spec_helper') describe Rtml::Rules::DomValidation do before :each do @doc = Rtml::Document.new @doc.setup_default_document @doc.process do screen :init, :idle do #set . . . end screen :idle, :next => :idle, :timeout => 3 do #display end end end it "should allow expected TML structure by array" do validate_tml_dom "", [ :screen ] end it "should disallow unexpected TML structure by array" do assert_raises Rtml::Errors::RulesViolationError do validate_tml_dom "", [ :vardcl ] end end it "should allow expected TML structure by symbol" do validate_tml_dom "", :screen end it "should disallow unexpected TML structure by symbol" do assert_raises Rtml::Errors::RulesViolationError do validate_tml_dom "", :vardcl end end it "should allow expected TML structure by string" do validate_tml_dom "", 'screen' end it "should disallow unexpected TML structure by string" do assert_raises Rtml::Errors::RulesViolationError do validate_tml_dom "", 'vardcl' end end it "should allow expected TML structure by hash" do validate_tml_dom "

...

", :screen => [ :next, {:display => :p} ] end it "should disallow unexpected TML structure by hash" do assert_raises Rtml::Errors::RulesViolationError do validate_tml_dom "", :screen => [ :next, {:display => :p} ] end end it "should validate TML generated by a document object" do validate_tml(@doc) end it "should validate correct TML in a string" do tml = <<-end_tml

this is a test

end_tml validate_tml(tml.strip) end it "should fail on too many display elements in a string" do assert_raises Rtml::Errors::RulesViolationError do tml = <<-end_tml

this is a test

this is another test

end_tml validate_tml(tml.strip) end end end