Google Groups Home
Help | Sign in
testing shared behaviors
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Semin Lee  
View profile
 More options Apr 8, 6:56 am
From: Semin Lee <semin...@gmail.com>
Date: Tue, 8 Apr 2008 03:56:41 -0700 (PDT)
Local: Tues, Apr 8 2008 6:56 am
Subject: testing shared behaviors
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
david.lowenf...@gmail.com  
View profile
 More options Apr 8, 1:48 pm
From: david.lowenf...@gmail.com
Date: Tue, 8 Apr 2008 10:48:28 -0700
Local: Tues, Apr 8 2008 1:48 pm
Subject: Re: testing shared behaviors
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Semin Lee  
View profile
 More options Apr 9, 4:22 pm
From: Semin Lee <semin...@gmail.com>
Date: Wed, 09 Apr 2008 21:22:45 +0100
Local: Wed, Apr 9 2008 4:22 pm
Subject: Re: testing shared behaviors
Hi David,

Thank you for your suggestion. That's a good idea!

Cheers,
Semin


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google