diff --git a/Gemfile b/Gemfile index f997252..52f6d54 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,7 @@ source 'https://rubygems.org' gem 'debug' +gem 'ice_age' gem 'lp' gem 'rspec' gem 'rspec_approvals' diff --git a/spec/completely/commands/generate_spec.rb b/spec/completely/commands/generate_spec.rb index a7f44c8..48300ae 100644 --- a/spec/completely/commands/generate_spec.rb +++ b/spec/completely/commands/generate_spec.rb @@ -48,10 +48,7 @@ ENV['COMPLETELY_CONFIG_PATH'] = 'spec/tmp/hello.yml' end - after do - ENV['COMPLETELY_CONFIG_PATH'] = nil - system 'rm -f hello.bash' - end + after { system 'rm -f hello.bash' } it 'generates the bash script to hello.bash' do expect { subject.execute %w[generate] }.to output_approval('cli/generate/custom-path-env') @@ -67,10 +64,6 @@ ENV['COMPLETELY_OUTPUT_PATH'] = outfile end - after do - ENV['COMPLETELY_OUTPUT_PATH'] = nil - end - it 'generates the bash script to the requested path' do expect { subject.execute %w[generate] }.to output_approval('cli/generate/custom-path-env2') expect(File.read outfile).to match_approval('cli/generated-script') diff --git a/spec/completely/commands/init_spec.rb b/spec/completely/commands/init_spec.rb index 01d5a30..a14f7f0 100644 --- a/spec/completely/commands/init_spec.rb +++ b/spec/completely/commands/init_spec.rb @@ -64,8 +64,6 @@ ENV['COMPLETELY_CONFIG_PATH'] = 'spec/tmp/hello.yml' end - after { ENV['COMPLETELY_CONFIG_PATH'] = nil } - it 'creates a new sample file with the requested name' do expect { subject.execute %w[init] } .to output_approval('cli/init/custom-path-env') diff --git a/spec/completely/commands/preview_spec.rb b/spec/completely/commands/preview_spec.rb index 6b8685f..dd21d16 100644 --- a/spec/completely/commands/preview_spec.rb +++ b/spec/completely/commands/preview_spec.rb @@ -32,8 +32,6 @@ ENV['COMPLETELY_CONFIG_PATH'] = 'spec/tmp/hello.yml' end - after { ENV['COMPLETELY_CONFIG_PATH'] = nil } - it 'outputs the generated script to STDOUT' do expect { subject.execute %w[preview] } .to output_approval('cli/generated-script') diff --git a/spec/completely/commands/test_spec.rb b/spec/completely/commands/test_spec.rb index 3f554d2..da77f04 100644 --- a/spec/completely/commands/test_spec.rb +++ b/spec/completely/commands/test_spec.rb @@ -3,13 +3,9 @@ before do system 'cp lib/completely/templates/flat-config/sample.yaml completely.yaml' - ENV['COMPLETELY_CONFIG_PATH'] = nil end - after do - system 'rm -f completely.yaml' - ENV['COMPLETELY_CONFIG_PATH'] = nil - end + after { system 'rm -f completely.yaml' } context 'with --help' do it 'shows long usage' do diff --git a/spec/completely/completions_spec.rb b/spec/completely/completions_spec.rb index 04c39e2..163567b 100644 --- a/spec/completely/completions_spec.rb +++ b/spec/completely/completions_spec.rb @@ -89,7 +89,6 @@ context 'when COMPLETELY_DEBUG is set' do before { ENV['COMPLETELY_DEBUG'] = '1' } - after { ENV['COMPLETELY_DEBUG'] = nil } it 'adds an additional debug snippet to the script' do expect(subject.script).to match_approval('completions/script-with-debug') diff --git a/spec/completely/installer_spec.rb b/spec/completely/installer_spec.rb index bf0a67b..54374f2 100644 --- a/spec/completely/installer_spec.rb +++ b/spec/completely/installer_spec.rb @@ -34,13 +34,7 @@ end context 'when BASH_COMPLETION_USER_DIR is set' do - around do |example| - original = ENV['BASH_COMPLETION_USER_DIR'] - ENV['BASH_COMPLETION_USER_DIR'] = '/tmp/completely-user-dir' - example.run - ensure - ENV['BASH_COMPLETION_USER_DIR'] = original - end + before { ENV['BASH_COMPLETION_USER_DIR'] = '/tmp/completely-user-dir' } it 'uses BASH_COMPLETION_USER_DIR/completions' do expect(subject.target_path).to eq '/tmp/completely-user-dir/completions/completely-test' @@ -48,13 +42,7 @@ end context 'when XDG_DATA_HOME is set' do - around do |example| - original = ENV['XDG_DATA_HOME'] - ENV['XDG_DATA_HOME'] = '/tmp/completely-xdg' - example.run - ensure - ENV['XDG_DATA_HOME'] = original - end + before { ENV['XDG_DATA_HOME'] = '/tmp/completely-xdg' } it 'uses XDG_DATA_HOME/bash-completion/completions' do expect(subject.target_path).to eq '/tmp/completely-xdg/bash-completion/completions/completely-test' @@ -62,13 +50,7 @@ end context 'when BASH_COMPLETION_USER_DIR has multiple entries' do - around do |example| - original = ENV['BASH_COMPLETION_USER_DIR'] - ENV['BASH_COMPLETION_USER_DIR'] = ':/tmp/completely-first:/tmp/completely-second' - example.run - ensure - ENV['BASH_COMPLETION_USER_DIR'] = original - end + before { ENV['BASH_COMPLETION_USER_DIR'] = ':/tmp/completely-first:/tmp/completely-second' } it 'uses the first non-empty entry' do expect(subject.target_path).to eq '/tmp/completely-first/completions/completely-test'