Sha256: 6a1abadff324b8313016a93bb48406461df7bd16c88986f42d0e0c8488ed5fb7

Contents?: true

Size: 1.1 KB

Versions: 94

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'rbbt/util/simpleDSL'
require 'test/unit'

class TestSimpleDSLClass 
  include SimpleDSL

  def action(name, *args, &block)
    @actions ||= {}
    @actions[name] = args.first
  end

  def actions
    @actions
  end
end


class TestDSL < Test::Unit::TestCase
  def setup 
    @parser = TestSimpleDSLClass.new
    @parser.load_config(:action) do
      action1 "Hello"
      action2 "Good bye"
    end
  end

  def test_actions
    assert_equal({:action1=>"Hello", :action2=>"Good bye"}, @parser.actions)
  end

  def test_method_missing
    assert_raise(NoMethodError){@parser.cues}
  end

  def test_config
    config = <<-EOC
  action1 "Hello"  
  action2 "Good bye" 
    EOC

    begin
      assert_equal config.split("\n").collect{|l| l.strip}, @parser.config(:action).split("\n").collect{|l| l.strip}
    rescue SimpleDSL::NoRuby2Ruby
    end
  end

  def test_parse
    @parser.parse :action do
      action3 "Back again"
    end

    assert_equal({:action1 =>"Hello", :action2 =>"Good bye", :action3 =>"Back again"}, @parser.actions)
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
rbbt-util-5.43.0 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.42.0 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.41.1 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.41.0 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.40.5 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.40.4 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.40.3 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.40.0 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.39.0 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.38.1 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.38.0 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.37.16 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.37.15 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.37.14 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.37.13 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.37.12 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.37.11 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.37.10 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.37.9 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.37.8 test/rbbt/util/test_simpleDSL.rb