I would prefer two independent steps:

1) Specify (or test) the plugin so that you can trust that it works as intended.

2) Write a custom matcher (behave_in_a_cool_way) that lets you express that you want to have added some_cool_behavior to SomeModel:

describe SomeModel

it "should show some_cool_behavior"  do
  SomeModel.should behave_in_a_cool_way
end

end

This: http://stevetooke.karmatrading.co.uk/2007/8/10/simple-rails- association-matching-with-rspec
may be an example.

Matthias

Am 03.03.2008 um 18:08 schrieb Anthony Broad-Crawford:

I have a question regarding best practices around module and plugin testing for rails applications. In our application we have created several plugins that extend ActiveRecord::Base with class methods, that when invoked in a model add behavior to that model. For example ...

class SomeModel < ActiveRecord::Base

        adds_some_cool_behavior
        adds_another_wicked_sweet_behavior

end

My initial thoughts are that any model that add these behaviors "should" have this specified in their spec. With that in mind, I was leaning towards creating a module that when included inside a model spec adds the necessary specifications to ensure the behavior is there and is executing as intended. However, before proceeding too far I wanted to run it by the collective to hear your thoughts as I am sure this has been tackled by others in the community already (although google didn't yield anything noteworthy).

Thanks,
Anthony Broad-Crawford



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

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

Reply via email to