-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add autoloadability via Bundler.require #137
Merged
eli-darkly
merged 3 commits into
launchdarkly:master
from
tonyta:bundler-require-autoload
Jul 23, 2019
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require_relative "ldclient-rb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require "spec_helper" | ||
require "bundler" | ||
|
||
describe LaunchDarkly do | ||
it "can be automatically loaded by Bundler.require" do | ||
ldclient_loaded = | ||
Bundler.with_clean_env do | ||
Kernel.system("ruby", "-e", <<~RUBY) | ||
require "bundler/setup" | ||
require "bundler/inline" | ||
|
||
gemfile do | ||
gem "launchdarkly-server-sdk", path: "." | ||
end | ||
|
||
Bundler.require(:development) | ||
abort unless $LOADED_FEATURES.any?(/ldclient-rb\.rb/) | ||
RUBY | ||
end | ||
|
||
expect(ldclient_loaded).to be true | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not sure this test mechanism is going to work in every version of Ruby that we support. It may need to be conditionally executed. Our CI build runs the tests in all supported versions, but it doesn't run on branches of forks.
What version(s) have you tested in?
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 doesn't quite work with Ruby < 2.5.0 because a pattern argument is passed to
Enumerable#any?
instead of a block. I'll change this example to ensure it can be run in earlier versions of Ruby.Edit: I've made changes to ensure this works with Ruby versions 2.3, 2.4, 2.5, 2.6, and 2.7.
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.
I copied your branch into a branch of our private mirror so I could run our own CI (I do think we will enable it for forks as you suggested, but in the meantime this is pretty easy for me to do). It's fine for 2.3-2.7, but we also support 2.2 and it doesn't work there because of the heredoc usage (
<<~RUBY
).You could build a multi-line string in other ways, but it might be simpler to just break out the test script into a separate file, like
launchdarkly-server-sdk_spec_autoloadtest.rb
, and then have the test just doKernel.system("ruby", "./spec/launchdarkly-server-sdk_spec_autoloadtest.rb")
. I verified that this works in all of our supported versions (including JRuby).