Forum: RSpec RSpec Requestable Examples

Posted by Zach Dennis (zdennis)
on 2012-01-28 04:34
(Received via mailing list)
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-req...

Git repository: https://github.com/mhs/rspec-requestable-examples

--
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
@zachdennis (twitter)
Posted by David Chelimsky (Guest)
on 2012-01-29 00:00
(Received via mailing list)
On Fri, Jan 27, 2012 at 8:56 PM, Zach Dennis <zach.dennis@gmail.com> 
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?
Posted by Zach Dennis (zdennis)
on 2012-01-29 06:36
(Received via mailing list)
On Sat, Jan 28, 2012 at 5:56 PM, David Chelimsky <dchelimsky@gmail.com> 
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
>> rspec-users@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users



--

--
@zachdennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
Posted by Lenny Marks (Guest)
on 2012-01-29 21:46
(Received via mailing list)
On Jan 27, 2012, at 9:56 PM, Zach Dennis 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-req...
>
> Git repository: https://github.com/mhs/rspec-requestable-examples

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

# macros approach to requestable examples
https://gist.github.com/1700352

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

-lenny
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.