2018-11-02 19:07:56 -04:00
# frozen_string_literal: true
RSpec . describe " .bundle/config " do
describe " config " do
2019-04-14 02:01:35 -04:00
before { bundle " config set foo bar " }
2018-11-02 19:07:56 -04:00
it " prints a detailed report of local and user configuration " do
2019-04-14 02:01:35 -04:00
bundle " config list "
2018-11-02 19:07:56 -04:00
expect ( out ) . to include ( " Settings are listed in order of priority. The top value will be used " )
expect ( out ) . to include ( " foo \n Set for the current user " )
expect ( out ) . to include ( " : \" bar \" " )
end
context " given --parseable flag " do
it " prints a minimal report of local and user configuration " do
2019-04-14 02:01:35 -04:00
bundle " config list --parseable "
2018-11-02 19:07:56 -04:00
expect ( out ) . to include ( " foo=bar " )
end
context " with global config " do
it " prints config assigned to local scope " do
2019-04-14 02:01:35 -04:00
bundle " config set --local foo bar2 "
bundle " config list --parseable "
2018-11-02 19:07:56 -04:00
expect ( out ) . to include ( " foo=bar2 " )
end
end
context " with env overwrite " do
it " prints config with env " do
2019-04-14 02:01:35 -04:00
bundle " config list --parseable " , :env = > { " BUNDLE_FOO " = > " bar3 " }
2018-11-02 19:07:56 -04:00
expect ( out ) . to include ( " foo=bar3 " )
end
end
end
end
2020-05-08 01:19:04 -04:00
describe " location with a gemfile " do
2019-04-14 02:01:35 -04:00
before :each do
gemfile <<-G
2019-05-06 12:06:21 -04:00
source " #{ file_uri_for ( gem_repo1 ) } "
2019-04-14 02:01:35 -04:00
gem " rack " , " 1.0.0 "
G
end
2022-02-27 20:32:28 -05:00
it " is local by default " do
bundle " config set foo bar "
expect ( bundled_app ( " .bundle/config " ) ) . to exist
expect ( home ( " .bundle/config " ) ) . not_to exist
end
2018-11-02 19:07:56 -04:00
it " can be moved with an environment variable " do
ENV [ " BUNDLE_APP_CONFIG " ] = tmp ( " foo/bar " ) . to_s
2021-01-03 20:11:34 -05:00
bundle " config set --local path vendor/bundle "
2020-05-29 06:46:16 -04:00
bundle " install "
2018-11-02 19:07:56 -04:00
expect ( bundled_app ( " .bundle " ) ) . not_to exist
expect ( tmp ( " foo/bar/config " ) ) . to exist
expect ( the_bundle ) . to include_gems " rack 1.0.0 "
end
it " can provide a relative path with the environment variable " do
FileUtils . mkdir_p bundled_app ( " omg " )
ENV [ " BUNDLE_APP_CONFIG " ] = " ../foo "
2021-01-03 20:11:34 -05:00
bundle " config set --local path vendor/bundle "
2020-05-29 06:46:16 -04:00
bundle " install " , :dir = > bundled_app ( " omg " )
2018-11-02 19:07:56 -04:00
expect ( bundled_app ( " .bundle " ) ) . not_to exist
expect ( bundled_app ( " ../foo/config " ) ) . to exist
2020-05-08 01:19:04 -04:00
expect ( the_bundle ) . to include_gems " rack 1.0.0 " , :dir = > bundled_app ( " omg " )
end
end
describe " location without a gemfile " do
2022-02-27 20:32:28 -05:00
it " is global by default " do
bundle " config set foo bar "
expect ( bundled_app ( " .bundle/config " ) ) . not_to exist
expect ( home ( " .bundle/config " ) ) . to exist
end
2020-05-08 01:19:04 -04:00
it " works with an absolute path " do
ENV [ " BUNDLE_APP_CONFIG " ] = tmp ( " foo/bar " ) . to_s
bundle " config set --local path vendor/bundle "
expect ( bundled_app ( " .bundle " ) ) . not_to exist
expect ( tmp ( " foo/bar/config " ) ) . to exist
2018-11-02 19:07:56 -04:00
end
end
2021-07-30 04:30:24 -04:00
describe " config location " do
let ( :bundle_user_config ) { File . join ( Dir . home , " .config/bundler " ) }
before do
Dir . mkdir File . dirname ( bundle_user_config )
end
it " can be configured through BUNDLE_USER_CONFIG " do
bundle " config set path vendor " , :env = > { " BUNDLE_USER_CONFIG " = > bundle_user_config }
bundle " config get path " , :env = > { " BUNDLE_USER_CONFIG " = > bundle_user_config }
expect ( out ) . to include ( " Set for the current user ( #{ bundle_user_config } ): \" vendor \" " )
end
2021-08-06 05:20:31 -04:00
context " when not explicitly configured, but BUNDLE_USER_HOME set " do
let ( :bundle_user_home ) { bundled_app ( " .bundle " ) . to_s }
it " uses the right location " do
bundle " config set path vendor " , :env = > { " BUNDLE_USER_HOME " = > bundle_user_home }
bundle " config get path " , :env = > { " BUNDLE_USER_HOME " = > bundle_user_home }
expect ( out ) . to include ( " Set for the current user ( #{ bundle_user_home } /config): \" vendor \" " )
end
end
2021-07-30 04:30:24 -04:00
end
2018-11-02 19:07:56 -04:00
describe " global " do
2019-04-14 02:01:35 -04:00
before ( :each ) do
install_gemfile <<-G
2019-05-06 12:06:21 -04:00
source " #{ file_uri_for ( gem_repo1 ) } "
2019-04-14 02:01:35 -04:00
gem " rack " , " 1.0.0 "
G
end
2018-11-02 19:07:56 -04:00
it " is the default " do
2019-04-14 02:01:35 -04:00
bundle " config set foo global "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " global " )
end
it " can also be set explicitly " do
2020-06-03 14:45:36 -04:00
bundle " config set --global foo global "
2020-06-03 14:48:46 -04:00
run " puts Bundler.settings[:foo] "
2018-11-02 19:07:56 -04:00
expect ( out ) . to eq ( " global " )
end
it " has lower precedence than local " do
2019-04-14 02:01:35 -04:00
bundle " config set --local foo local "
2018-11-02 19:07:56 -04:00
2019-04-14 02:01:35 -04:00
bundle " config set --global foo global "
2018-11-02 19:07:56 -04:00
expect ( out ) . to match ( / Your application has set foo to "local" / )
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " local " )
end
it " has lower precedence than env " do
begin
ENV [ " BUNDLE_FOO " ] = " env "
2019-04-14 02:01:35 -04:00
bundle " config set --global foo global "
2018-11-02 19:07:56 -04:00
expect ( out ) . to match ( / You have a bundler environment variable for foo set to "env" / )
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " env " )
ensure
ENV . delete ( " BUNDLE_FOO " )
end
end
it " can be deleted " do
2019-04-14 02:01:35 -04:00
bundle " config set --global foo global "
bundle " config unset foo "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] == nil "
expect ( out ) . to eq ( " true " )
end
it " warns when overriding " do
2019-04-14 02:01:35 -04:00
bundle " config set --global foo previous "
bundle " config set --global foo global "
2018-11-02 19:07:56 -04:00
expect ( out ) . to match ( / You are replacing the current global value of foo / )
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " global " )
end
it " does not warn when using the same value twice " do
2019-04-14 02:01:35 -04:00
bundle " config set --global foo value "
bundle " config set --global foo value "
2018-11-02 19:07:56 -04:00
expect ( out ) . not_to match ( / You are replacing the current global value of foo / )
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " value " )
end
it " expands the path at time of setting " do
2019-04-14 02:01:35 -04:00
bundle " config set --global local.foo .. "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings['local.foo'] "
2020-05-08 01:19:04 -04:00
expect ( out ) . to eq ( File . expand_path ( bundled_app . to_s + " /.. " ) )
2018-11-02 19:07:56 -04:00
end
it " saves with parseable option " do
2019-04-14 02:01:35 -04:00
bundle " config set --global --parseable foo value "
2018-11-02 19:07:56 -04:00
expect ( out ) . to eq ( " foo=value " )
run " puts Bundler.settings['foo'] "
expect ( out ) . to eq ( " value " )
end
context " when replacing a current value with the parseable flag " do
2019-04-14 02:01:35 -04:00
before { bundle " config set --global foo value " }
2018-11-02 19:07:56 -04:00
it " prints the current value in a parseable format " do
2019-04-14 02:01:35 -04:00
bundle " config set --global --parseable foo value2 "
2018-11-02 19:07:56 -04:00
expect ( out ) . to eq " foo=value2 "
run " puts Bundler.settings['foo'] "
expect ( out ) . to eq ( " value2 " )
end
end
end
describe " local " do
2019-04-14 02:01:35 -04:00
before ( :each ) do
install_gemfile <<-G
2019-05-06 12:06:21 -04:00
source " #{ file_uri_for ( gem_repo1 ) } "
2019-04-14 02:01:35 -04:00
gem " rack " , " 1.0.0 "
G
end
2018-11-02 19:07:56 -04:00
it " can also be set explicitly " do
2019-04-14 02:01:35 -04:00
bundle " config set --local foo local "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " local " )
end
it " has higher precedence than env " do
begin
ENV [ " BUNDLE_FOO " ] = " env "
2019-04-14 02:01:35 -04:00
bundle " config set --local foo local "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " local " )
ensure
ENV . delete ( " BUNDLE_FOO " )
end
end
it " can be deleted " do
2019-04-14 02:01:35 -04:00
bundle " config set --local foo local "
bundle " config unset foo "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] == nil "
expect ( out ) . to eq ( " true " )
end
it " warns when overriding " do
2019-04-14 02:01:35 -04:00
bundle " config set --local foo previous "
bundle " config set --local foo local "
2018-11-02 19:07:56 -04:00
expect ( out ) . to match ( / You are replacing the current local value of foo / )
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " local " )
end
it " expands the path at time of setting " do
2019-04-14 02:01:35 -04:00
bundle " config set --local local.foo .. "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings['local.foo'] "
2020-05-08 01:19:04 -04:00
expect ( out ) . to eq ( File . expand_path ( bundled_app . to_s + " /.. " ) )
2018-11-02 19:07:56 -04:00
end
it " can be deleted with parseable option " do
2019-04-14 02:01:35 -04:00
bundle " config set --local foo value "
bundle " config unset --parseable foo "
2018-11-02 19:07:56 -04:00
expect ( out ) . to eq " "
run " puts Bundler.settings['foo'] == nil "
expect ( out ) . to eq ( " true " )
end
end
describe " env " do
2019-04-14 02:01:35 -04:00
before ( :each ) do
install_gemfile <<-G
2019-05-06 12:06:21 -04:00
source " #{ file_uri_for ( gem_repo1 ) } "
2019-04-14 02:01:35 -04:00
gem " rack " , " 1.0.0 "
G
end
2018-11-02 19:07:56 -04:00
it " can set boolean properties via the environment " do
ENV [ " BUNDLE_FROZEN " ] = " true "
run " if Bundler.settings[:frozen]; puts 'true' else puts 'false' end "
expect ( out ) . to eq ( " true " )
end
it " can set negative boolean properties via the environment " do
run " if Bundler.settings[:frozen]; puts 'true' else puts 'false' end "
expect ( out ) . to eq ( " false " )
ENV [ " BUNDLE_FROZEN " ] = " false "
run " if Bundler.settings[:frozen]; puts 'true' else puts 'false' end "
expect ( out ) . to eq ( " false " )
ENV [ " BUNDLE_FROZEN " ] = " 0 "
run " if Bundler.settings[:frozen]; puts 'true' else puts 'false' end "
expect ( out ) . to eq ( " false " )
ENV [ " BUNDLE_FROZEN " ] = " "
run " if Bundler.settings[:frozen]; puts 'true' else puts 'false' end "
expect ( out ) . to eq ( " false " )
end
it " can set properties with periods via the environment " do
ENV [ " BUNDLE_FOO__BAR " ] = " baz "
run " puts Bundler.settings['foo.bar'] "
expect ( out ) . to eq ( " baz " )
end
end
describe " parseable option " do
it " prints an empty string " do
2019-04-14 02:01:35 -04:00
bundle " config get foo --parseable "
2018-11-02 19:07:56 -04:00
expect ( out ) . to eq " "
end
it " only prints the value of the config " do
2019-04-14 02:01:35 -04:00
bundle " config set foo local "
bundle " config get foo --parseable "
2018-11-02 19:07:56 -04:00
expect ( out ) . to eq " foo=local "
end
it " can print global config " do
2019-04-14 02:01:35 -04:00
bundle " config set --global bar value "
bundle " config get bar --parseable "
2018-11-02 19:07:56 -04:00
expect ( out ) . to eq " bar=value "
end
it " prefers local config over global " do
2019-04-14 02:01:35 -04:00
bundle " config set --local bar value2 "
bundle " config set --global bar value "
bundle " config get bar --parseable "
2018-11-02 19:07:56 -04:00
expect ( out ) . to eq " bar=value2 "
end
end
describe " gem mirrors " do
2019-04-14 02:01:35 -04:00
before ( :each ) do
install_gemfile <<-G
2019-05-06 12:06:21 -04:00
source " #{ file_uri_for ( gem_repo1 ) } "
2019-04-14 02:01:35 -04:00
gem " rack " , " 1.0.0 "
G
end
2018-11-02 19:07:56 -04:00
it " configures mirrors using keys with `mirror.` " do
2019-04-14 02:01:35 -04:00
bundle " config set --local mirror.http://gems.example.org http://gem-mirror.example.org "
2018-11-02 19:07:56 -04:00
run ( <<-E)
Bundler . settings . gem_mirrors . each do | k , v |
puts " \# {k} => \# {v} "
end
E
expect ( out ) . to eq ( " http://gems.example.org/ => http://gem-mirror.example.org/ " )
end
end
describe " quoting " do
2021-07-24 11:27:02 -04:00
before ( :each ) { gemfile " source \" #{ file_uri_for ( gem_repo1 ) } \" " }
2018-11-02 19:07:56 -04:00
let ( :long_string ) do
" --with-xml2-include=/usr/pkg/include/libxml2 --with-xml2-lib=/usr/pkg/lib " \
" --with-xslt-dir=/usr/pkg "
end
it " saves quotes " do
2019-04-14 02:01:35 -04:00
bundle " config set foo something \\ ' "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " something' " )
end
2019-04-14 02:01:35 -04:00
it " doesn't return quotes around values " do
bundle " config set foo '1' "
2022-02-27 20:32:28 -05:00
run " puts Bundler.settings.send(:local_config_file).read "
2018-11-02 19:07:56 -04:00
expect ( out ) . to include ( '"1"' )
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( " 1 " )
end
2019-04-14 02:01:35 -04:00
it " doesn't duplicate quotes around values " do
2018-11-02 19:07:56 -04:00
bundled_app ( " .bundle " ) . mkpath
File . open ( bundled_app ( " .bundle/config " ) , " w " ) do | f |
f . write 'BUNDLE_FOO: "$BUILD_DIR"'
end
2019-04-14 02:01:35 -04:00
bundle " config set bar baz "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings.send(:local_config_file).read "
# Starting in Ruby 2.1, YAML automatically adds double quotes
# around some values, including $ and newlines.
expect ( out ) . to include ( 'BUNDLE_FOO: "$BUILD_DIR"' )
end
it " doesn't duplicate quotes around long wrapped values " do
2019-04-14 02:01:35 -04:00
bundle " config set foo #{ long_string } "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( long_string )
2019-04-14 02:01:35 -04:00
bundle " config set bar baz "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] "
expect ( out ) . to eq ( long_string )
end
end
describe " very long lines " do
2019-04-14 02:01:35 -04:00
before ( :each ) do
install_gemfile <<-G
2019-05-06 12:06:21 -04:00
source " #{ file_uri_for ( gem_repo1 ) } "
2019-04-14 02:01:35 -04:00
gem " rack " , " 1.0.0 "
G
end
2018-11-02 19:07:56 -04:00
let ( :long_string ) do
" --with-xml2-include=/usr/pkg/include/libxml2 --with-xml2-lib=/usr/pkg/lib " \
" --with-xslt-dir=/usr/pkg "
end
let ( :long_string_without_special_characters ) do
" here is quite a long string that will wrap to a second line but will not be " \
" surrounded by quotes "
end
it " doesn't wrap values " do
2019-04-14 02:01:35 -04:00
bundle " config set foo #{ long_string } "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] "
expect ( out ) . to match ( long_string )
end
it " can read wrapped unquoted values " do
2019-04-14 02:01:35 -04:00
bundle " config set foo #{ long_string_without_special_characters } "
2018-11-02 19:07:56 -04:00
run " puts Bundler.settings[:foo] "
expect ( out ) . to match ( long_string_without_special_characters )
end
end
2019-04-14 02:01:35 -04:00
2022-05-28 12:37:41 -04:00
describe " commented out settings with urls " do
before do
bundle " config set # mirror.https://rails-assets.org http://localhost:9292 "
end
it " does not make bundler crash and ignores the configuration " do
bundle " config list --parseable "
expect ( out ) . to eq ( " # mirror.https://rails-assets.org/=http://localhost:9292 " )
expect ( err ) . to be_empty
ruby ( << ~ RUBY )
require " #{ entrypoint } "
print Bundler . settings . mirror_for ( " https://rails-assets.org " )
RUBY
expect ( out ) . to eq ( " https://rails-assets.org/ " )
expect ( err ) . to be_empty
bundle " config set mirror.all http://localhost:9293 "
ruby ( << ~ RUBY )
require " #{ entrypoint } "
print Bundler . settings . mirror_for ( " https://rails-assets.org " )
RUBY
expect ( out ) . to eq ( " http://localhost:9293/ " )
expect ( err ) . to be_empty
end
end
2019-04-14 02:01:35 -04:00
describe " subcommands " do
Fix some bundler specs (#2380)
* These seem to consistenly pass already
* Show actual command when running `make test-bundler`
Current the setup command that installs the necessary gems for testing
bundler was printed, but not the actual command that runs the tests.
That was a bit confusing.
* Borrow trick from setproctitle specs
* A title that long doesn't get set sometimes
No idea why, but the test doesn't need that the title is that long.
* Fix most gem helper spec ruby-core failures
* Fix the rest of the gem helper failures
* Fix version spec by improving the assertion
* Remove unnecessary `BUNDLE_RUBY` environment var
We can use `RUBY` when necessary, and `BUNDLE_RUBY` is not a good name
because bundler considers `BUNDLE_*` variables as settings.
* Rename `BUNDLE_GEM` to `GEM_COMMAND`
This is more descriptive I think, and also friendlier for bundler
because `BUNDLE_` env variables are interpreted by bundler as settings,
and this is not a bundler setting.
This fixes one bundler spec failure in config specs against ruby-core.
* Fix quality spec when run in core
Use the proper path helper.
* Fix dummy lib builder to never load default gems
If a dummy library is named as a default gem, when requiring the library
from its executable, the default gem would be loaded when running from
core, because in core all default gems share path with bundler, and thus
they are always in the $LOAD_PATH. We fix the issue by loading lib
relatively inside dummy lib executables.
* More exact assertions
Sometimes I have the problem that I do some "print debugging" inside
specs, and suddently the spec passes. This happens when the assertion is
too relaxed, and the things I print make it match, specially when they
are simple strings like "1.0" than can be easily be part of gem paths
that I print for debugging.
I fix this by making a more exact assertion.
* Detect the correct shebang when ENV["RUBY"] is set
* Relax assertion
So that the spec passes even if another paths containing "ext" are in
the load path. This works to fix a ruby-core issue, but it's a better
assertion in general. We just want to know that the extension path was
added.
* Use folder structure independent path helper
It should fix this spec for ruby-core.
* Fix the last failing spec on ruby-core
* Skip `bundle open <default_gem>` spec when no default gems
2019-08-19 20:46:31 -04:00
it " list " do
2021-12-19 16:36:15 -05:00
bundle " config list " , :env = > { " BUNDLE_FOO " = > " bar " }
expect ( out ) . to eq " Settings are listed in order of priority. The top value will be used. \n foo \n Set via BUNDLE_FOO: \" bar \" "
2019-04-14 02:01:35 -04:00
2021-12-19 16:36:15 -05:00
bundle " config list " , :env = > { " BUNDLE_FOO " = > " bar " } , :parseable = > true
expect ( out ) . to eq " foo=bar "
2019-04-14 02:01:35 -04:00
end
2021-04-21 07:54:29 -04:00
it " list with credentials " do
bundle " config list " , :env = > { " BUNDLE_GEMS__MYSERVER__COM " = > " user:password " }
2021-12-19 16:36:15 -05:00
expect ( out ) . to eq " Settings are listed in order of priority. The top value will be used. \n gems.myserver.com \n Set via BUNDLE_GEMS__MYSERVER__COM: \" user:[REDACTED] \" "
2021-04-21 07:54:29 -04:00
bundle " config list " , :parseable = > true , :env = > { " BUNDLE_GEMS__MYSERVER__COM " = > " user:password " }
2021-12-19 16:36:15 -05:00
expect ( out ) . to eq " gems.myserver.com=user:password "
2021-04-21 07:54:29 -04:00
end
2021-08-19 16:12:04 -04:00
it " list with API token credentials " do
bundle " config list " , :env = > { " BUNDLE_GEMS__MYSERVER__COM " = > " api_token:x-oauth-basic " }
2021-12-19 16:36:15 -05:00
expect ( out ) . to eq " Settings are listed in order of priority. The top value will be used. \n gems.myserver.com \n Set via BUNDLE_GEMS__MYSERVER__COM: \" [REDACTED]:x-oauth-basic \" "
2021-08-19 16:12:04 -04:00
bundle " config list " , :parseable = > true , :env = > { " BUNDLE_GEMS__MYSERVER__COM " = > " api_token:x-oauth-basic " }
2021-12-19 16:36:15 -05:00
expect ( out ) . to eq " gems.myserver.com=api_token:x-oauth-basic "
2021-08-19 16:12:04 -04:00
end
2019-04-14 02:01:35 -04:00
it " get " do
ENV [ " BUNDLE_BAR " ] = " bar_val "
2020-06-03 14:45:36 -04:00
bundle " config get foo "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " Settings for `foo` in order of priority. The top value will be used \n You have not configured a value for `foo` "
2019-04-14 02:01:35 -04:00
ENV [ " BUNDLE_FOO " ] = " foo_val "
2020-06-03 14:45:36 -04:00
bundle " config get foo --parseable "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " foo=foo_val "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config get foo "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " Settings for `foo` in order of priority. The top value will be used \n Set via BUNDLE_FOO: \" foo_val \" "
2019-04-14 02:01:35 -04:00
end
it " set " do
2020-06-03 14:45:36 -04:00
bundle " config set foo 1 "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config set --local foo 2 "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config set --global foo 3 "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " Your application has set foo to \" 2 \" . This will override the global value you are currently setting "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config set --parseable --local foo 4 "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " foo=4 "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config set --local foo 4.1 "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " You are replacing the current local value of foo, which is currently \" 4 \" "
2019-04-14 02:01:35 -04:00
2020-06-03 12:43:17 -04:00
bundle " config set --global --local foo 5 " , :raise_on_error = > false
2019-04-14 02:01:35 -04:00
expect ( last_command ) . to be_failure
2019-06-01 05:49:40 -04:00
expect ( err ) . to eq " The options global and local were specified. Please only use one of the switches at a time. "
2019-04-14 02:01:35 -04:00
end
it " unset " do
2020-06-03 14:45:36 -04:00
bundle " config unset foo "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config set foo 1 "
bundle " config unset foo --parseable "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config set --local foo 1 "
bundle " config set --global foo 2 "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config unset foo "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " "
2020-06-03 14:45:36 -04:00
expect ( bundle ( " config get foo " ) ) . to eq " Settings for `foo` in order of priority. The top value will be used \n You have not configured a value for `foo` "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config set --local foo 1 "
bundle " config set --global foo 2 "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config unset foo --local "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " "
2020-06-03 14:45:36 -04:00
expect ( bundle ( " config get foo " ) ) . to eq " Settings for `foo` in order of priority. The top value will be used \n Set for the current user ( #{ home ( " .bundle/config " ) } ): \" 2 \" "
bundle " config unset foo --global "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " "
2020-06-03 14:45:36 -04:00
expect ( bundle ( " config get foo " ) ) . to eq " Settings for `foo` in order of priority. The top value will be used \n You have not configured a value for `foo` "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config set --local foo 1 "
bundle " config set --global foo 2 "
2019-04-14 02:01:35 -04:00
2020-06-03 14:45:36 -04:00
bundle " config unset foo --global "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " "
2020-06-03 14:45:36 -04:00
expect ( bundle ( " config get foo " ) ) . to eq " Settings for `foo` in order of priority. The top value will be used \n Set for your local app ( #{ bundled_app ( " .bundle/config " ) } ): \" 1 \" "
bundle " config unset foo --local "
2019-06-01 05:49:40 -04:00
expect ( out ) . to eq " "
2020-06-03 14:45:36 -04:00
expect ( bundle ( " config get foo " ) ) . to eq " Settings for `foo` in order of priority. The top value will be used \n You have not configured a value for `foo` "
2019-04-14 02:01:35 -04:00
2020-06-03 12:43:17 -04:00
bundle " config unset foo --local --global " , :raise_on_error = > false
2019-04-14 02:01:35 -04:00
expect ( last_command ) . to be_failure
2019-06-01 05:49:40 -04:00
expect ( err ) . to eq " The options global and local were specified. Please only use one of the switches at a time. "
2019-04-14 02:01:35 -04:00
end
end
2018-11-02 19:07:56 -04:00
end
RSpec . describe " setting gemfile via config " do
context " when only the non-default Gemfile exists " do
it " persists the gemfile location to .bundle/config " do
2018-09-25 14:36:56 -04:00
gemfile bundled_app ( " NotGemfile " ) , <<-G
source " #{ file_uri_for ( gem_repo1 ) } "
gem 'rack'
G
2018-11-02 19:07:56 -04:00
2019-04-14 02:01:35 -04:00
bundle " config set --local gemfile #{ bundled_app ( " NotGemfile " ) } "
2020-05-08 01:19:04 -04:00
expect ( File . exist? ( bundled_app ( " .bundle/config " ) ) ) . to eq ( true )
2018-11-02 19:07:56 -04:00
2019-04-14 02:01:35 -04:00
bundle " config list "
2018-11-02 19:07:56 -04:00
expect ( out ) . to include ( " NotGemfile " )
end
end
end