-
Notifications
You must be signed in to change notification settings - Fork 36
Insert rspec setup code into generated binstub #20
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
Conversation
@@ -12,6 +12,10 @@ def exec_name | |||
def gem_name | |||
"rspec-core" | |||
end | |||
|
|||
def binstub_code | |||
"RSpec.configuration.start_time = Time.now" |
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 caused an error for me unless preceded with require rspec/core
. Please see #18 (comment)
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 spring pull request was merged. This pull request can now be merged. The gemspec does not need to depend on the next version of spring, since this change doesn't break any functionality. |
Wouldn't that only work if using binstubs? I've been trying out the following, which seems to work in the non-binstub case too: Spring.after_fork { ::RSpec.configuration.start_time = Time.now } |
@willbryant Yes, this issue fix will only work if the |
@willbryant Also, does #18 (comment) fix the issue for you? I found it did for me without adding any extra code to my project's binstubs or spring configs. |
Would it work to define the following instead? class Spring::Commands::RSpec
def call
RSpec.configuration.start_time = Time.now
load Gem.bin_path("rspec-core", "rspec")
end
end Working around the issue in the binstub feels wrong to me. |
@jonleighton My testing shows that would work. I can close this pull request and open a new one if you want. |
My guess is that this issue affects anyone who ends up requiring rspec at application boot time, rather than in their spec helper. I'd be happy to merge a PR which takes the above approach. Thanks. |
I have added a new pull request here: #22. I am closing this one since the issue this was designed to fix will be fixed by that pull request instead. |
Allow arbitrary setup code to be inserted into binstub
This reverts commit 2480a8e, reversing changes made to 9cd21d2. Revert "Changelog: binstub_prelude support for commands. #329." This reverts commit 8a3546d. Conflicts: CHANGELOG.md Reasoning: * #329 (comment) * jonleighton/spring-commands-rspec#20 (comment) * 2480a8e Since the thing that this feature was aiming to allow is already possible via the commands API, I prefer not to add an extra feature to Spring.
This reverts commit 2480a8eb4e88ad720e3d5a30bc23b53201673d58, reversing changes made to 9cd21d2249fdc33477dfc99f0e99c5d307108447. Revert "Changelog: binstub_prelude support for commands. #329." This reverts commit 8a3546d15892f28f19787d88e4a834e68b91c438. Conflicts: CHANGELOG.md Reasoning: * rails/spring#329 (comment) * jonleighton/spring-commands-rspec#20 (comment) * rails/spring@2480a8e Since the thing that this feature was aiming to allow is already possible via the commands API, I prefer not to add an extra feature to Spring.
This code relies on code in this pull request and should NOT be merged until the other pull request is merged. At that time, the gemspec may also be updated to depend on the newer version of the spring gem.