38 lines
1.8 KiB
Ruby
38 lines
1.8 KiB
Ruby
RSpec.shared_examples 'cloud deploy env' do
|
|
validated_model_name = described_class.name.demodulize.underscore
|
|
|
|
describe 'validation rules:' do
|
|
include_examples 'field type validation', :flavor, :maybe_nil, :non_empty_string, :field_validator
|
|
include_examples 'field type validation', :image, :maybe_nil, :non_empty_string, :field_validator
|
|
include_examples 'field type validation', :groups, :maybe_nil, :maybe_empty_array, :field_validator
|
|
include_examples 'field type validation', :subnets, :maybe_nil, :maybe_empty_array, :field_validator
|
|
include_examples 'field type validation', :stack_template, :maybe_nil, :non_empty_string, :field_validator
|
|
|
|
it 'flavor should be available' do
|
|
expect(build(validated_model_name, flavor: 'flavor')).to be_valid
|
|
expect(build(validated_model_name, flavor: 'wrong')).not_to be_valid
|
|
end
|
|
|
|
it 'image should be available' do
|
|
expect(build(validated_model_name, image: 'image')).to be_valid
|
|
expect(build(validated_model_name, image: 'wrong')).not_to be_valid
|
|
end
|
|
|
|
it 'all groups should be available' do
|
|
expect(build(validated_model_name, groups: ['default'])).to be_valid
|
|
expect(build(validated_model_name, groups: ['wrong'])).not_to be_valid
|
|
expect(build(validated_model_name, groups: ['wrong', 'default'])).not_to be_valid
|
|
end
|
|
|
|
it 'stack_template should be available' do
|
|
expect(build(validated_model_name, stack_template: 'template')).to be_valid
|
|
expect(build(validated_model_name, stack_template: 'wrong')).not_to be_valid
|
|
end
|
|
end
|
|
|
|
describe '#to_hash' do
|
|
it 'includes flavor, image, subnets, groups and stack_template in keys' do
|
|
expect(described_class.new.to_hash).to include('flavor', 'image', 'subnets', 'groups', 'stack_template')
|
|
end
|
|
end
|
|
end |