update specs for new name validation rules

This commit is contained in:
Anton Chuchkalov 2015-12-01 19:35:45 +03:00
parent 82ad9cac0d
commit 1b66ca88ad

View File

@ -37,7 +37,8 @@ RSpec.shared_examples 'field type validation' do |field, *properties|
end if properties.include?(:maybe_empty_array) end if properties.include?(:maybe_empty_array)
it 'should contain only word symbols' do it 'should contain only word symbols' do
expect(build(validated_model_name, field => 'asd-asd')).not_to be_valid expect(build(validated_model_name, field => '!')).not_to be_valid
expect(build(validated_model_name, field => '/')).not_to be_valid
end if properties.include?(:only_word_symbols) end if properties.include?(:only_word_symbols)
it 'should contain elements like role[asd] or recipe[asd]' do it 'should contain elements like role[asd] or recipe[asd]' do
@ -99,9 +100,12 @@ RSpec.shared_examples 'field type validation' do |field, *properties|
}.not_to raise_error }.not_to raise_error
end if properties.include?(:maybe_empty_array) end if properties.include?(:maybe_empty_array)
it 'should contain only word symbols' do it 'should contain only symbols in [a-zA-Z0-9_-]' do
expect{ expect{
build(validated_model_name, field => 'asd-asd').send(field_validation_method) build(validated_model_name, field => '!').send(field_validation_method)
}.to raise_error InvalidRecord
expect{
build(validated_model_name, field => '/').send(field_validation_method)
}.to raise_error InvalidRecord }.to raise_error InvalidRecord
end if properties.include?(:only_word_symbols) end if properties.include?(:only_word_symbols)