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