Thank you for your suggestion. That's a good idea!
david.lowenf
...@gmail.com wrote:
> Hi Semin,
> I'm not sure if I understand exactly what you're asking, but I
> think you could just write a test to test your module methods (which I
> assume you are mixing into a class by the include keyword?)
> If you need to test it in the context of a class, just create a dummy
> class which mixes in your module:
> class Foo; include MyModule; end
> class MyModuleTest < Test::Unit::TestCase
> context "An instance of a class with MyModule methods mixed-in" do
> setup do
> @object = Foo.new
> end
> should "do some stuff" do
> assert @object
> end
> end
> end
> -David
> On Apr 8, 2008, at 3:56 AM, Semin Lee wrote:
>> Hi guys,
>> I was wondering if there is an easy to do some tests on shared
>> behaviors using Shoulda (or test:unit). I am extracting shared methods
>> (or behaviors) out of individual classes and make them as a separate
>> module to be shared, but I don't find an easy and DRY way to test this
>> shared behaviors.
>> Rspec seems to provide this kind of functionality by using external
>> shared_examples (http://rspec.info/examples.html), but I don't want to
>> switch back to Rspec because I am already addicted to Shoulda's
>> terseness. :)
>> What do you guys think about this? Any suggestions?
>> Cheers,
>> Semin