-
-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Sanctioned Support Helper Inclusion #1943
Comments
I don't understand what your proposed feature would provide for us over |
A few things come to mind immediately:
|
Does RSpec.shared_context "controller support", type: :controller do
def self.helper_for_a_describe_block
end
def helper_for_a_let_block
end
def helper_for_an_it_block
end
end (Note, however, that we're discussing changes to the semantics of shared group metadata in #1790). Anyhow you argue well :). Responses to some of your specific points below:
You're the first user I've ever heard say that. What do you find non-obvious about it? Can we improve our docs somehow? I've always thought (and from what I've heard from users, the community seems to agree) that it's very obvious given that it just delegates to
IMO, the DSL here would obscure, not clarify. It feels like "DSL for the sake of DSL". RSpec definitely supports a rich DSL but we generally don't want to add additional DSL when existing APIs provide the same functionality.
You can also just use a local variable instead of a global constant: module = Module.new do
# define stuff here...
end
RSpec.configure do |config|
config.include module
end
You can use a shared context and write methods as
Then do this: module MyHelpers
# method defs here
RSpec.configuration.include self
end Anyhow, given that we already have module inclusion, extension and shared contexts, adding yet another way to define and include helper methods seems like a confusing change for users. If you created this as an extension gem and it got some traction in the community, we'll be glad to reconsider including it in rspec-core. |
Just want to say I really appreciate you taking the time to write out your On Wed, Apr 22, 2015 at 1:34 AM, Myron Marston notifications@github.com
|
I got this brilliant error message today:
Then I began to wonder why there's no built in way to include support helpers easily. Here's a rough sketch of what I'm thinking would be incredibly useful:
I was earlier repeating this pattern all over the place:
Right now, I use this hackiness to do the dirty work, and it's been a pleasure so far:
I'd love to implement this myself with some guidance if you all are interested.
Cheers! 🍻
The text was updated successfully, but these errors were encountered: