Hi Ken,

On 31 May 2011, at 19:09, Ken Egervari wrote:

> I have a module that extends ActiveSupport::Concern. Here is the `included` 
> block:
> 
>   included do
>     after_save :save_tags
> 
>     has_many :taggings, :as => :taggable
>     has_many :tags, :through => :taggings
>   end
> 
> How can I stub out these calls? I have tried a few ways, but Ruby complains 
> that these methods don't exist when I try and test the module in isolation.

I've never used concerns, but my guess is that they carry shared responsibility 
that's mixed into a few other classes. If you want to test them in isolation 
(as opposed to just testing the behaviour of the actual classes you've mixed 
them in to) then I would create a simple dummy object in your test, mix the 
concern into that, and then test the behaviour of that object.

Make sense?

> 
> Thanks!
> 
> Ken
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

cheers,
Matt

m...@mattwynne.net
07974 430184

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to