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
Respect RSpec default_path
for generators
#2508
Conversation
Something failed |
Hii, I've updated the branch. At the moment, rails installer does not support I'll work on it when get a chance. |
Looks great, thank you. You may (completely optionally) add a feature to Just noticed that our Generators documentation is split into two, and the second one's name is misleading, Generator specs. It's a topic for another PR to bring them together, though. |
@pirj Are we only going to test Forgive me if I misunderstood anything 😅 . |
Yes, just your fix. Those features are published as documentation, and are end-to-end tests. No worries if you get stuck with it. Altering the default spec path is a pretty rare case. Also, with your fix it now works intuitively, so maybe documentation for it is redundant. Leaving it up to you to decide. |
Okay I will update the PR. But while implementing the feature I am running into one issue.: I thought that It looks the blocker is the |
We have to do something like, https://github.com/rspec/rspec-core/blob/main/lib/rspec/core/runner.rb#L132 (i.e. Any thoughts or suggestion? |
It's all kind of weird. If I'm not mistaken, the doc https://relishapp.com/rspec/rspec-core/v/3-9/docs/configuration/setting-the-default-spec-path says that `default_path` is not supported on `RSpec.configuration`, but it seems that it is. The reasoning is not exactly clear. Let me check later when I get back to the computer.
|
# RSpec.configure do |c|
# c.default_path = 'behavior' and
and what's more important: # @note Other scripts invoking `rspec` indirectly will ignore this
# setting. which is exactly the case with generators. Though
Can you please confirm that defining the default path in If it works, I suggest you to write the feature test in such a way that the default path is set in the |
I think I have bad news. Options from files, |
Yes that's what I exactly found. See my #2508 (comment) I've mentioned the line no. where I will try to find more and will update the PR. |
I'd like to see a feature file demonstrating this behaviour so that its both documented and tested, the changes to the generator look fine but I'm not sure its sufficient to load |
@JonRowe @pirj I will implement feature file. Can we initialize |
I believe with those discoveries, adding a feature test becomes a necessity. |
Hey, # Install rspec at custom directory (this will append `--default-path` option to `.rspec` file)
$ rails generate rspec:install --default-path behaviour Also look at 5f7b640 which implements the feature you've asked for!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is copied over from rspec-core
. It might be exposed as a public interface, but this may be postponed to a later version, and we can do this in rspec-core
4.0.1, and set the minimum dependent version to it.
Thank you!
@pirj Can we initialize |
That's an option to consider, too. def self.configuration
@configuration ||= RSpec::Core::Configuration.new
end and there could be cases when it's necessary to run a suite with different options, e.g. filters. It would make I don't feel that this code duplication is a big issue, it just hints that something can be optimized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delayed feedback, looking good but some more tweaks needed.
Code review notes addressed, proposed changes accepted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes behaviour for all generators, yet is only tested against one generator. This needs the additional tests and scenarios.
Hello guys, Sorry for delayed response. I was super busy in some stuffs. As @JonRowe asked, I am writing feature tests for below items (List grabbed from
EDIT: Added the entry of generator feature in TODO list. |
Looks good to me 👍 |
Hey @pirj @JonRowe, Added more feature tests 🎉 . Below are not implemented as I couldn't figure how to tackle them 🤕 :
|
@pirj can you review this? |
Thank you! |
Fixes #2507.
TODO
spec
directory todefault_path