Skip to content

Commit

Permalink
namespacify n8l::am_i_sourced()
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoblitt committed Sep 16, 2017
1 parent 7a76b64 commit 2a8a0fc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/newinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ n8l::print_greeting() {
#
# See: https://stackoverflow.com/a/12396228
#
am_I_sourced() {
n8l::am_i_sourced() {
if [ "${FUNCNAME[1]}" = source ]; then
return 0
else
Expand Down Expand Up @@ -1022,7 +1022,7 @@ main() {
#
# support being sourced as a lib or executed
#
if ! am_I_sourced; then
if ! n8l::am_i_sourced; then
main "$@"
fi

Expand Down
21 changes: 21 additions & 0 deletions spec/unit/n8l/am_i_sourced_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'rspec/bash'

describe 'n8l::am_i_sourced' do
include Rspec::Bash

let(:stubbed_env) { create_stubbed_env }
subject(:func) { 'n8l::am_i_sourced' }

context 'not being sourced' do
it 'dies' do
out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
func,
)

expect(status.exitstatus).to_not be 0
expect(out).to eq('')
expect(err).to eq('')
end
end
end

0 comments on commit 2a8a0fc

Please sign in to comment.