[rspec-users] Proposed deprecation

David Chelimsky dchelimsky at gmail.com
Sun Feb 17 14:48:35 EST 2008

>From http://rspec.lighthouseapp.com/projects/5645/tickets/295 (please
comment there, not here).

 Proposed Deprecation: do not include modules implicitly

As those of you using RSpec for Rails likely know, Rails Helper Specs
implicitly include the helper module right in the HelperExampleGroup,
so you can do this:

describe DogHelper do
  it "should bark" do
    bark.should == "woof"

module DogHelper
  def bark

Personally, I find this to be a bit too magical and confusing. Not to
mention inconsistent with controller and view examples, each of which
provide a convenience object (controller, response) but require that
you interact with this object explicitly.

Because I find this confusing, I've been in the habit of wrapping self
in a #helper method, so the above example would look like this:

describe DogHelper do
  it "should bark" do
    helper.bark.should == "woof"

That is a lot easier for anyone familiar with rspec to look at and grok away.

This feature is implemented in rspec core such that any time you
describe a module, that module is included in the ExampleGroup.

It turns out that it causes trouble if you have an initialize method
that accepts one or more arguments. You can get around that by using a

describe "SomeModule" do

But I don't think that really honors the principal of least surprise.

I'd like to deprecate this feature, but I'd like feedback from the
community before I do. Please post your comments to the original
ticket, which can be found at

Thank you,


More information about the rspec-users mailing list