1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
# frozen_string_literal: true
require 'spec_helper'
describe 'es_plugin_name' do
describe 'exception handling' do
it {
expect(subject).to run.with_params.and_raise_error(
Puppet::ParseError, %r{wrong number of arguments}i
)
}
end
describe 'single arguments' do
it {
expect(subject).to run.
with_params('foo').
and_return('foo')
}
it {
expect(subject).to run.
with_params('vendor/foo').
and_return('foo')
}
it {
expect(subject).to run.
with_params('vendor/foo/1.0.0').
and_return('foo')
}
it {
expect(subject).to run.
with_params('vendor/es-foo/1.0.0').
and_return('foo')
}
it {
expect(subject).to run.
with_params('vendor/elasticsearch-foo/1.0.0').
and_return('foo')
}
it {
expect(subject).to run.
with_params('com.foo:plugin_name:5.2.0').
and_return('plugin_name')
}
it {
expect(subject).to run.
with_params('com:plugin_name:5.2.0-12').
and_return('plugin_name')
}
it {
expect(subject).to run.
with_params('com.foo.bar:plugin_name:5').
and_return('plugin_name')
}
end
describe 'multiple arguments' do
it {
expect(subject).to run.
with_params('foo', nil).
and_return('foo')
}
it {
expect(subject).to run.
with_params(nil, 'foo').
and_return('foo')
}
it {
expect(subject).to run.
with_params(nil, 0, 'foo', 'bar').
and_return('foo')
}
end
describe 'undef parameters' do
it {
expect(subject).to run.
with_params('', 'foo').
and_return('foo')
}
it {
expect(subject).to run.
with_params('').
and_raise_error(Puppet::Error, %r{could not})
}
end
it 'does not change the original values' do
argument1 = 'foo'
original1 = argument1.dup
subject.execute(argument1)
expect(argument1).to eq(original1)
end
end
|