Sha256: 725a729089b56220872060368c660f3daefcd548c7ea49fc054ee5396ef08af5

Contents?: true

Size: 1.02 KB

Versions: 128

Compression:

Stored size: 1.02 KB

Contents

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

class TestClass 
  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 = TestClass.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(@parser.config(:action) == config)
    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

128 entries across 128 versions & 1 rubygems

Version Path
rbbt-util-5.5.17 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.16 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.15 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.14 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.13 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.12 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.11 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.10 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.9 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.8 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.7 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.6 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.5 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.4 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.3 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.2 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.1 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.5.0 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.4.1 test/rbbt/util/test_simpleDSL.rb
rbbt-util-5.3.4 test/rbbt/util/test_simpleDSL.rb