| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  | 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 | 
					
						
							| 
									
										
										
										
											2018-04-04 22:44:39 +03:00
										 |  |  |     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 | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 22:44:39 +03:00
										 |  |  |   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') | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe '.create' do | 
					
						
							| 
									
										
										
										
											2018-04-04 22:44:39 +03:00
										 |  |  |     before do | 
					
						
							|  |  |  |       allow_any_instance_of(Devops::Model::StackTemplateAws).to receive(:update_template_url) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  |     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 |