28 lines
		
	
	
		
			755 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			755 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require 'db/mongo/models/key'
 | |
| 
 | |
| RSpec.describe Devops::Model::Key, type: :model do
 | |
|   let(:key) { build(:key) }
 | |
| 
 | |
|   it 'is valid with correct attrs' do
 | |
|     expect(key).to be_valid
 | |
|   end
 | |
| 
 | |
|   describe 'validations', stubbed_logger: true do
 | |
|     it 'key file should exist in file system' do
 | |
|       expect(build(:key, path: './not_exist')).not_to be_valid
 | |
|     end
 | |
| 
 | |
|     it "scope could be 'user' or 'system'" do
 | |
|       expect(build(:key, scope: 'system')).to be_valid
 | |
|       expect(build(:key, scope: 'wrong')).not_to be_valid
 | |
|     end
 | |
|   end
 | |
| 
 | |
|   it '#filename returns base name of key file' do
 | |
|     expect(key.filename).to eq('blank_file')
 | |
|   end
 | |
| 
 | |
|   it '#to_hash_without_id returns path and scope' do
 | |
|     expect(key.to_hash_without_id.keys).to eq(%w(path scope))
 | |
|   end
 | |
| end | 
