Merge branch 'spec-cleanup'
Fix and improve some Test::* specs.
This commit is contained in:
commit
5623d19c51
@ -4,38 +4,39 @@ module Producer::Core
|
||||
module Tests
|
||||
describe HasEnv do
|
||||
let(:env) { Env.new }
|
||||
let(:variable_name) { :some_variable_name }
|
||||
let(:variable_name) { 'SOME_VAR' }
|
||||
let(:remote_env) { { 'SOME_VAR' => 'SOME_VALUE' } }
|
||||
subject(:has_env) { HasEnv.new(env, variable_name) }
|
||||
|
||||
it_behaves_like 'test'
|
||||
|
||||
describe '#verify' do
|
||||
let(:environment) { double 'environment' }
|
||||
|
||||
before do
|
||||
allow(env.remote).to receive(:environment) { environment }
|
||||
allow(env.remote).to receive(:environment) { remote_env }
|
||||
end
|
||||
|
||||
it 'stringifies the queried variable name' do
|
||||
expect(environment).to receive(:key?).with(kind_of(String))
|
||||
has_env.verify
|
||||
end
|
||||
|
||||
it 'upcases the queried variable name' do
|
||||
expect(environment).to receive(:key?).with('SOME_VARIABLE_NAME')
|
||||
has_env.verify
|
||||
end
|
||||
|
||||
it 'returns true when remote environment var is defined' do
|
||||
allow(environment).to receive(:key?) { true }
|
||||
describe '#verify' do
|
||||
context 'remote environment var is defined' do
|
||||
it 'returns true' do
|
||||
expect(has_env.verify).to be true
|
||||
end
|
||||
|
||||
it 'returns false when remote environment var is not defined' do
|
||||
allow(environment).to receive(:key?) { false }
|
||||
context 'when var name is given as a lowercase symbol' do
|
||||
let(:variable_name) { :some_var }
|
||||
|
||||
it 'returns true' do
|
||||
expect(has_env.verify).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'remote environment var is not defined' do
|
||||
let(:variable_name) { 'SOME_NON_EXISTENT_VAR' }
|
||||
|
||||
it 'returns false' do
|
||||
expect(has_env.verify).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||
module Producer::Core
|
||||
module Tests
|
||||
describe HasExecutable, :env do
|
||||
subject(:has_env) { HasExecutable.new(env, executable) }
|
||||
subject(:test) { HasExecutable.new(env, executable) }
|
||||
|
||||
it_behaves_like 'test'
|
||||
|
||||
@ -12,7 +12,7 @@ module Producer::Core
|
||||
let(:executable) { 'true' }
|
||||
|
||||
it 'returns true' do
|
||||
expect(has_env.verify).to be true
|
||||
expect(test.verify).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@ -20,7 +20,7 @@ module Producer::Core
|
||||
let(:executable) { 'some_non_existent_executable' }
|
||||
|
||||
it 'returns false' do
|
||||
expect(has_env.verify).to be false
|
||||
expect(test.verify).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user