spec/beaker/options/parser_spec.rb in beaker-4.38.1 vs spec/beaker/options/parser_spec.rb in beaker-4.39.0
- old
+ new
@@ -2,16 +2,16 @@
module Beaker
module Options
describe Parser do
- let(:parser) { Parser.new }
+ let(:parser) { described_class.new }
let(:opts_path) { File.join(File.expand_path(File.dirname(__FILE__)), "data", "opts.txt") }
let(:hosts_path) { File.join(File.expand_path(File.dirname(__FILE__)), "data", "hosts.cfg") }
it "supports usage function" do
- expect { parser.usage }.to_not raise_error
+ expect { parser.usage }.not_to raise_error
end
describe 'parse_git_repos' do
it "transforms arguments of <PROJECT_NAME>/<REF> to <GIT_BASE_URL>/<lowercased_project_name>#<REF>" do
@@ -76,11 +76,11 @@
context 'combining split_arg and file_list maintain test file ordering' do
let(:test_dir) { 'tmp/tests' }
let(:other_test_dir) { 'tmp/tests2' }
- before :each do
+ before do
files = [
'00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
'01_TestSetup.rb', '03_PuppetMasterSanity.rb',
'06_InstallModules.rb', '02_PuppetUserAndGroup.rb',
'04_ValidateSignCert.rb', '07_InstallCACerts.rb']
@@ -170,11 +170,11 @@
:keys => 'keys123',
:keepalive => 'keepalive123'
}
}}
- before :each do
+ before do
expect(parser).to receive(:normalize_args).and_return(true)
end
def mock_out_parsing
presets_obj = double()
@@ -338,12 +338,12 @@
end
describe '#parse_hosts_options' do
context 'Hosts file exists' do
- before :each do
- allow(File).to receive(:exists?).and_return(true)
+ before do
+ allow(File).to receive(:exist?).and_return(true)
end
it 'returns the parser\'s output' do
parser.instance_variable_set( :@options, {} )
test_value = 'blaqwetjijl,emikfuj1235'
@@ -355,12 +355,12 @@
end
end
context 'Hosts file does not exist' do
require 'beaker-hostgenerator'
- before :each do
- allow(File).to receive(:exists?).and_return(false)
+ before do
+ allow(File).to receive(:exist?).and_return(false)
end
it 'calls beaker-hostgenerator to get hosts information' do
parser.instance_variable_set( :@options, {
:hosts_file => 'notafile.yml'
@@ -544,22 +544,22 @@
YAML.dump(hosts, file)
end
filename
end
- shared_examples_for(:a_platform_supporting_only_agents) do |platform, _type|
+ shared_examples_for('a platform supporting only agents') do |platform, _type|
it "restricts #{platform} hosts to agent" do
args = []
args << '--hosts' << fake_hosts_file_for_platform(hosts, platform)
expect { parser.parse_args(args) }.to raise_error(ArgumentError, /#{platform}.*may not have roles: master, database, dashboard/)
end
end
context "restricts agents" do
- it_should_behave_like(:a_platform_supporting_only_agents, 'windows-version-arch')
- it_should_behave_like(:a_platform_supporting_only_agents, 'el-4-arch')
+ it_behaves_like('a platform supporting only agents', 'windows-version-arch')
+ it_behaves_like('a platform supporting only agents', 'el-4-arch')
end
context "ssh user" do
it 'uses the ssh[:user] if it is provided' do
@@ -584,14 +584,14 @@
end
end
describe '#normalize_tags!' do
- let (:test_tag_and ) { @test_tag_and || [] }
- let (:test_tag_or ) { @test_tag_or || [] }
- let (:test_tag_exclude ) { @test_tag_exclude || [] }
- let (:options ) {
+ let(:test_tag_and ) { @test_tag_and || [] }
+ let(:test_tag_or ) { @test_tag_or || [] }
+ let(:test_tag_exclude ) { @test_tag_exclude || [] }
+ let(:options ) {
opts = Beaker::Options::OptionsHash.new
opts[:test_tag_and] = test_tag_and
opts[:test_tag_or] = test_tag_or
opts[:test_tag_exclude] = test_tag_exclude
opts
@@ -642,11 +642,11 @@
expect(options[:test_tag_exclude]).to be === ['leet_speak', 'poland']
end
end
describe '#resolve_symlinks' do
- let (:options) { Beaker::Options::OptionsHash.new }
+ let(:options) { Beaker::Options::OptionsHash.new }
it 'calls File.realpath if hosts_file is set' do
options[:hosts_file] = opts_path
parser.instance_variable_set(:@options, options)
@@ -656,11 +656,11 @@
it 'does not throw an error if hosts_file is not set' do
options[:hosts_file] = nil
parser.instance_variable_set(:@options, options)
- expect { parser.resolve_symlinks! }.to_not raise_error
+ expect { parser.resolve_symlinks! }.not_to raise_error
end
end
describe '#get_hypervisors' do
it 'returns a unique list' do
@@ -689,23 +689,23 @@
expect(parser.get_roles(roles_single)).to eq([['hi']])
end
end
describe '#check_hypervisor_config' do
- let (:options) { Beaker::Options::OptionsHash.new }
- let (:invalid_file) { '/tmp/doesnotexist_visor.yml' }
+ let(:options) { Beaker::Options::OptionsHash.new }
+ let(:invalid_file) { '/tmp/doesnotexist_visor.yml' }
- before :each do
+ before do
FakeFS.deactivate!
end
it 'checks ec2_yaml when blimpy' do
options[:ec2_yaml] = hosts_path
options[:dot_fog] = invalid_file
parser.instance_variable_set(:@options, options)
- expect { parser.check_hypervisor_config('blimpy') }.to_not raise_error
+ expect { parser.check_hypervisor_config('blimpy') }.not_to raise_error
end
it 'throws an error if ec2_yaml for blimpy is invalid' do
options[:ec2_yaml] = invalid_file
options[:dot_fog] = hosts_path
@@ -718,11 +718,11 @@
it "checks dot_fog when #{visor}" do
options[:ec2_yaml] = invalid_file
options[:dot_fog] = hosts_path
parser.instance_variable_set(:@options, options)
- expect { parser.check_hypervisor_config(visor) }.to_not raise_error
+ expect { parser.check_hypervisor_config(visor) }.not_to raise_error
end
it "throws an error if dot_fog for #{visor} is invalid" do
options[:ec2_yaml] = hosts_path
options[:dot_fog] = invalid_file
@@ -731,10 +731,10 @@
expect { parser.check_hypervisor_config(visor) }.to raise_error(ArgumentError, /required by #{visor}/)
end
end
it 'does not throw error on unknown visor' do
- expect { parser.check_hypervisor_config('unknown_visor') }.to_not raise_error
+ expect { parser.check_hypervisor_config('unknown_visor') }.not_to raise_error
end
end
end
end
end