RSpec.shared_examples 'stack template' do validated_model_name = described_class.name.demodulize.underscore it 'is valid with factory attrs' do expect(build(validated_model_name)).to be_valid end describe 'validation rules' do include_examples 'field type validation', :id, :not_nil, :non_empty_string, :only_word_symbols include_examples 'field type validation', :provider, :not_nil, :non_empty_string include_examples 'field type validation', :template_body, :not_nil, :non_empty_string include_examples 'field type validation', :owner, :not_nil, :non_empty_string end describe '#to_hash' do it 'returns hash with id, provider, template_body and owner' do expect(stack_template.to_hash).to include('id', 'provider', 'template_body', 'owner') end end describe '.create' do before do allow_any_instance_of(Devops::Model::StackTemplateAws).to receive(:update_template_url) end it "returns instance of #{described_class.name}" do params = { 'id' => 'foo', 'template_body' => '{}', 'owner' => 'root', 'provider' => 'ec2' } expect(described_class.create(params)).to be_an_instance_of(described_class) end end end