[rspec-devel] [ rspec-Feature Requests-8507 ] change #include to some other name

noreply at rubyforge.org noreply at rubyforge.org
Sun Nov 18 21:11:19 EST 2007

Feature Requests item #8507, was opened at 2007-02-08 13:20
You can respond by visiting: 

Category: runner module
Group: None
>Status: Closed
Priority: 3
Submitted By: David Chelimsky (dchelimsky)
Assigned to: Nobody (None)
Summary: change #include to some other name

Initial Comment:
RSpec supports inclusion of a module in a context:

context "some context" do
  include SomeModule

The initial intent of this was to enable state sharing across contexts and/or introduce helper methods that might be used across contexts.

Unfortunately, the use of the name "include" has led to some perception problems. It does NOT work exactly like Ruby's include does, but the name leads to the expectation that it should.

I'd like to propose that we deprecate the name "include" and replace it with some other name like "include_methods_from" or something like that (suggestions please!!!), which indicates that methods from the module will be made available, but it should not otherwise be expected to behave as Module#include behaves.


Comment By: Chad Humphries (spicycode)
Date: 2007-11-19 02:10

Moved to http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/33-8507-change-include-to-some-other-name#ticket-33-2


Comment By: David Chelimsky (dchelimsky)
Date: 2007-02-08 17:43

Ian - thanks for responding.

As for keeping #include, that's possible, and might be the right course. This is really a starting point for a discussion.

My concern is not a specific bug (constants), but rather that there is an expectation that it operate exactly like Module#include. Right now we see the problem with constants, but what else we see later?

Also, re: constants - I've been banging my head against a wall with it, and really don't see a way to make it work, even using const_get/set. But, my meta-fu is, well, let's say "still evolving". So if you (or anyone) has a patch to make it work, have at it!!!!



Comment By: Ian Dees (undees)
Date: 2007-02-08 17:00

Hmmmm.... a few ideas:

* Most of the RSpec examples use names like MyContextHelper.  So how about "helper" or some permutation?

* The context is using methods from the module -- maybe "use", "uses", "using", etc.?

* I like your "include_methods_from" because it's nice and specific, but could we use a shorter variation, like "methods_from"?

* Is there any way to salvage the old "include" method, but make it act more like the Ruby one?  Maybe with clever usage of const_get (which _does_ work inside instance_eval)?


You can respond by visiting: 

More information about the rspec-devel mailing list