-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Catch unhandled system exits See rspec/rspec-core#2246 for more info * Fix typo * Fix argument passing to rake task * Write specs for version manager tasks
- Loading branch information
1 parent
cd0eba1
commit 6fc3027
Showing
20 changed files
with
189 additions
and
62 deletions.
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
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
echo "-----> chruby to version: \\"123\\"" | ||
if \[\[ ! -s "/etc/profile\.d/chruby\.sh" \]\]; then | ||
echo "! chruby\.sh init file not found" | ||
exit 1 | ||
fi | ||
source /etc/profile\.d/chruby\.sh | ||
chruby "123" \|\| exit 1 |
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,2 @@ | ||
Task 'chruby' needs a Ruby version as an argument\. | ||
Example: invoke :chruby, 'ruby-2.4' |
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 |
---|---|---|
@@ -1 +1,9 @@ | ||
echo\ "\-\-\-\-\->\ Loading\ rbenv"\nexport\ RBENV_ROOT="\$HOME/\.rbenv"\nexport\ PATH="\$HOME/\.rbenv/bin:\$PATH"\s*if\ !\ which\ rbenv\ >/dev/null;\ then\s*echo\ "!\ rbenv\ not\ found"\s*echo\ "!\ If\ rbenv\ is\ installed,\ check\ your\ :rbenv_path\ setting\."\s*exit\ 1\s*fi\s*eval\ "\$\(rbenv\ init\ \-\)" | ||
echo "-----> Loading rbenv" | ||
export RBENV_ROOT="\$HOME/\.rbenv" | ||
export PATH="\$HOME/\.rbenv/bin:\$PATH" | ||
if ! which rbenv >/dev/null; then | ||
echo "! rbenv not found" | ||
echo "! If rbenv is installed, check your :rbenv_path setting\." | ||
exit 1 | ||
fi | ||
eval "\$\(rbenv init -\)" |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
echo "-----> Using RVM environment \\"3\.0\.0\\"" | ||
if \[\[ ! -s "\$HOME/\.rvm/scripts/rvm" \]\]; then | ||
echo "! Ruby Version Manager not found" | ||
echo "! If RVM is installed, check your :rvm_use_path setting\." | ||
exit 1 | ||
fi | ||
source \$HOME/\.rvm/scripts/rvm | ||
rvm use "3\.0\.0" --create |
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,2 @@ | ||
Task 'rvm:use' needs an RVM environment name as an argument\. | ||
Example: invoke :'rvm:use', 'ruby-1\.9\.2@default' |
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,8 @@ | ||
echo "-----> creating RVM wrapper "myapp_unicorn" using \\"3\.0\.0\\"" | ||
if \[\[ ! -s "\$HOME/\.rvm/scripts/rvm" \]\]; then | ||
echo "! Ruby Version Manager not found" | ||
echo "! If RVM is installed, check your :rvm_use_path setting\." | ||
exit 1 | ||
fi | ||
source \$HOME/\.rvm/scripts/rvm | ||
rvm wrapper 3\.0\.0 myapp unicorn \|\| exit 1 |
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,2 @@ | ||
Task 'rvm:wrapper' needs an RVM environment name, a wrapper name and the binary name as arguments | ||
Example: invoke :'rvm:wrapper', 'ruby-1\.9\.2@myapp,myapp,unicorn_rails' |
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
echo "-----> ry to version: \\\"3\.0\.0\\\"" | ||
echo "-----> Loading ry" | ||
if \[\[ ! -e "\$HOME/\.local/bin" \]\]; then | ||
echo "! ry not found" | ||
echo "! If ry is installed, check your :ry_path setting." | ||
exit 1 | ||
fi | ||
export PATH="\$HOME/\.local/bin:\$PATH" | ||
eval "\$\(ry setup\)" | ||
RY_RUBY="3\.0\.0" | ||
if \[ -n "\$RY_RUBY" \]; then | ||
ry use \$RY_RUBY \|\| exit 1 | ||
fi |
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,13 @@ | ||
echo "-----> ry to version: \\"\*\*not specified\*\*\\"" | ||
echo "-----> Loading ry" | ||
if \[\[ ! -e "\$HOME/\.local/bin" \]\]; then | ||
echo "! ry not found" | ||
echo "! If ry is installed, check your :ry_path setting." | ||
exit 1 | ||
fi | ||
export PATH="\$HOME/\.local/bin:\$PATH" | ||
eval "\$\(ry setup\)" | ||
RY_RUBY="" | ||
if \[ -n "\$RY_RUBY" \]; then | ||
ry use \$RY_RUBY \|\| exit 1 | ||
fi |
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
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' | ||
|
||
RSpec.describe 'chruby', type: :rake do | ||
describe 'chruby' do | ||
subject { rake['chruby'] } | ||
|
||
context 'without an argument' do | ||
it 'exits with an error message' do | ||
expect do | ||
invoke_all | ||
end.to raise_error(SystemExit).and output(output_file('chruby_without_env')).to_stdout | ||
end | ||
end | ||
|
||
context 'with an argument' do | ||
it 'sets ruby version' do | ||
expect do | ||
invoke_all('123') | ||
end.to output(output_file('chruby_with_env')).to_stdout | ||
end | ||
end | ||
end | ||
end |
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,9 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe 'rbenv', type: :rake do | ||
describe 'rbenv:load' do | ||
it 'loads rbenv' do | ||
expect { invoke_all }.to output(output_file('rbenv_load')).to_stdout | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe 'rvm', type: :rake do | ||
describe 'rvm:use' do | ||
subject { rake['rvm:use'] } | ||
|
||
context 'without an argument' do | ||
it 'exits with an error message' do | ||
expect do | ||
invoke_all | ||
end.to raise_error(SystemExit) | ||
.and output(output_file('rvm_use_without_env')).to_stdout | ||
end | ||
end | ||
|
||
context 'with an argument' do | ||
it 'sets ruby version' do | ||
expect do | ||
invoke_all('3.0.0') | ||
end.to output(output_file('rvm_use_with_env')).to_stdout | ||
end | ||
end | ||
end | ||
|
||
describe 'rvm:wrapper' do | ||
subject { rake['rvm:wrapper'] } | ||
|
||
context 'without all arguments' do | ||
it 'exits with an error message' do | ||
expect do | ||
invoke_all('ruby-3.0.0') | ||
end.to raise_error(SystemExit) | ||
.and output(output_file('rvm_wrapper_without_arguments')).to_stdout | ||
end | ||
end | ||
|
||
context 'with all arguments' do | ||
it 'calls rvm wrapper' do | ||
expect do | ||
invoke_all('3.0.0', 'myapp', 'unicorn') | ||
end.to output(output_file('rvm_wrapper_with_arguments')).to_stdout | ||
end | ||
end | ||
end | ||
end |
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,37 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe 'ry', type: :rake do | ||
describe 'ry' do | ||
subject { rake['ry'] } | ||
|
||
let(:default_version_warning) { /Task 'ry' without argument will use default Ruby version\./ } | ||
|
||
context 'without an argument' do | ||
it 'prints a warning' do | ||
expect do | ||
invoke_all | ||
end.to output(default_version_warning).to_stdout | ||
end | ||
|
||
it 'sets ruby version' do | ||
expect do | ||
invoke_all | ||
end.to output(output_file('ry_without_env')).to_stdout | ||
end | ||
end | ||
|
||
context 'with an argument' do | ||
it "doesn't print a warning" do | ||
expect do | ||
invoke_all('3.0.0') | ||
end.not_to output(default_version_warning).to_stdout | ||
end | ||
end | ||
|
||
it 'sets ruby version' do | ||
expect do | ||
invoke_all('3.0.0') | ||
end.to output(output_file('ry_with_env')).to_stdout | ||
end | ||
end | ||
end |
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