Sha256: 9df134f54bb1523a00065d35565b5361b31705c82aed3914bff45a33fbddfd0d

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 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 => [: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 => [: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

4 entries across 4 versions & 1 rubygems

Version Path
rtml-2.0.3 spec/models/rtml/instruction_spec.rb
rtml-2.0.2 spec/models/rtml/instruction_spec.rb
rtml-2.0.1 spec/models/rtml/instruction_spec.rb
rtml-2.0.0.alpha.1 spec/models/rtml/instruction_spec.rb