RSpec Requestable Examples

I would be interested to hear any thoughts from the community about
the ability to request specific examples from a shared example group
as expressed in the rspec-requestable-examples gem.

Here’s the post that introduces them:
http://mutuallyhuman.com/blog/2012/01/27/rspec-requestable-examples

Git repository: GitHub - mhs/rspec-requestable-examples: rspec-requestable-examples let's you include specific examples from shared example sets


Zach D.
http://www.continuousthinking.com

@zachdennis (twitter)

On Fri, Jan 27, 2012 at 8:56 PM, Zach D. [email protected]
wrote:

I would be interested to hear any thoughts from the community about
the ability to request specific examples from a shared example group
as expressed in the rspec-requestable-examples gem.

I love the service it provides, and the consuming API (i.e. :examples
=> […]). It clearly communicates to the spec reader what is going
on.

As for the setup API, how about “requestable_example” instead of
“requestable_it”. In fact, I think “selectable” would be a more
accurate descriptor than “requestable”, so “selectable_examples_for”
and “selectable_example” would read better for me.

I haven’t looked at the implementation yet, but I wonder if you could
implement the same feature using metadata. Something like this, using
“selectable” rather than “requestable” (seems better aligned with what
it’s doing IMO):

shared_examples_for “variable things”, :selectable do
it “does one thing sometimes”, :selectable do
# …
end

it “does another thing sometimes”, :selectable do
# …
end

it “does one other thing all the time” do
# …
end
end

That way we don’t need a new method name to worry about and my issue
with the name “requestable_it” goes away.

WDYT?

On Sat, Jan 28, 2012 at 5:56 PM, David C. [email protected]
wrote:

“requestable_it”. In fact, I think “selectable” would be a more
accurate descriptor than “requestable”, so “selectable_examples_for”
and “selectable_example” would read better for me.

I agree with you, “selectable” seems like a better fit, but this may
not apply in its entirety given your next suggestion…

with the name “requestable_it” goes away.

WDYT?

I like what you’re suggesting here as well. One reason I had went with
a new method name for this was to not conflict with RSpec itself, but
given your feedback I will investigate what you propose above.

Thanks for taking the time to review and to respond,

Zach

@zachdennis (twitter)


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


@zachdennis
http://www.continuousthinking.com

On Jan 27, 2012, at 9:56 PM, Zach D. wrote:

I would be interested to hear any thoughts from the community about
the ability to request specific examples from a shared example group
as expressed in the rspec-requestable-examples gem.

Here’s the post that introduces them:
http://mutuallyhuman.com/blog/2012/01/27/rspec-requestable-examples

Git repository: GitHub - mhs/rspec-requestable-examples: rspec-requestable-examples let's you include specific examples from shared example sets

I’ve successfully used macros to get similar results, like in the gist
below:

macros approach to requestable examples

Curious if you see any big advantages over the macros approach.

-lenny