Sha256: 77433f001e80fcdf047afd11d6e54d0092caec804e7a609068d952018535fc4a

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

require File.join(__FILE__.gsub(/(.*)?\/spec\/.*$/, '\1'), 'spec/spec_helper')

describe Rtml::Instruction do
  context "built statically" do
    it "should produce a document from a class method" do
      rtml_document = Rtml::Instruction.follow([
        'screen :init, :main',
        'screen :main',
        '  display "test"',
      ])

      rtml_document.should resemble_tml(:tml => [:screen, {:screen => :display}])
    end

    it "should produce a document from instances" do
      instructions = [ Rtml::Instruction.new(:name => :screen, :arguments => {:name => :init, :next => :main}),
                       Rtml::Instruction.new(:name => :screen, :arguments => {:name => :main}) ]
      instructions.last.instructions.build(:name => :display, :arguments => {:content => "test"})

      rtml_document = Rtml::Document.new
      rtml_document.setup_default_document

      instructions.each { |instruction| instruction.follow(rtml_document) }
      rtml_document.should resemble_tml(:tml => [:screen, {:screen => :display}])
    end
  end

  context "built dynamically" do
    context "with an entry point that exists" do
      it "should be able to find its Widget" do
        doc = Rtml::Document.create
        instr = Rtml::Instruction.create(:source => doc, :x => 0, :y => 0, :name => "screen")
        instr.widget.should == Rtml::Widgets::Screens
      end
    end

    context "with an entry point that does not exist" do
      it "should find a nil Widget" do
        doc = Rtml::Document.create
        instr = Rtml::Instruction.create(:source => doc, :x => 0, :y => 0, :name => "missing_entry_point_name")
        instr.widget.should == nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rtml-2.0.4 spec/models/rtml/instruction_spec.rb