Sha256: 79f79f959d267f25a7f6c473a3ffd210378107ecc96d19bf85cbf3de05dc89b7

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

class DSLTest < ActiveSupport::TestCase
  
  context "DSL" do
    
    context "define widgets" do
      setup do
        widgets = Widget do
          widget_a "This widget does X"
          widget_b "This does Y"
        end
      end
      
      should "have 2 widget classes" do
        assert WidgetA
        assert WidgetB
      end
      
      should "be able to instantiate the two widget classes" do
        @a = WidgetA.new
        @b = WidgetB.new
        
        assert @a
        assert @b
        
        assert_equal "This widget does X", @a.description
        assert_equal "This does Y", @b.description
      end
    end
    
  end
  
  context "Module" do
    setup do
      define_module("Lance::Pollard") do
        class << self
          def acts_as_lance_pollard
            "yep"
          end
        end
      end
    end
    
    should "have defined the modules" do
      assert Lance::Pollard
      assert_equal "yep", Lance::Pollard.acts_as_lance_pollard
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
defined-by-0.0.6 test/test_dsl.rb
defined-by-0.0.5 test/test_dsl.rb