require File.join(__FILE__.gsub(/(.*)?\/spec\/.*$/, '\1'), 'spec/spec_helper') describe Rtml::Widgets::Screens do before :each do @doc = Rtml::Document.new end it "should have a #gui_configuration" do Rtml::Widgets::Screens.gui_configuration.should_not be_nil end context "with a #gui_configuration" do before(:each) { @gui = Rtml::Widgets::Screens.gui_configuration } #it "should have a title" do # @gui.title.should_not be_blank #end it "should construct initialization arguments from a hash of fields" do fields = {:name => "screen_name", :next => "next_screen"} arguments = @gui.construct_arguments(fields) arguments.should == ["screen_name", {:next => "next_screen"}] end end it "should find or build a TML screen" do # build a few screens @doc.screen :init, :main, :timeout => 3 @doc.screen :main @doc.screens.should have(2).items # find and update but don't create a screen scr = @doc.screen(:init, :other) scr.should be_kind_of(Rtml::Dom::ScreenElement) @doc.screens.should have(2).items end it "should never build a screen tag without a body (TML has issues with it)" do xml = Hpricot::XML(@doc.screen(:main).to_tml).root (xml.children || []).reject { |i| !i.kind_of?(Hpricot::Elem) }.should_not be_empty #.should match(/\s*<\/screen>/) end it "should never build an screen tag without a element (TML issues)" do xml = Hpricot::XML(@doc.screen(:main).to_tml).root (xml.children || []).reject { |i| !i.kind_of?(Hpricot::Elem) }.should_not be_empty # @doc.screen(:main, :another).to_tml.should match(/\s* 3 @doc.screen :main @doc.screen?(:init).should_not be_nil @doc.screen?(:main).should_not be_nil @doc.screen?(:none).should be_nil end it "should allow subelements for screens" do # build a few screens @doc.screen :init, :main, :timeout => 3 do setvar :name => "oebr.transid", :lo => '1' end @doc.screen :main do display end @doc.screens.should have(2).items @doc.screens.first.elements.should have(1).item @doc.screens.second.elements.should have(1).item (@doc.screen(:init) / :setvar).should have(1).setvar (@doc.screen(:main) / :display).should have(1).element end end