spec/granite/form/model/validations/associated_spec.rb in granite-form-0.5.0 vs spec/granite/form/model/validations/associated_spec.rb in granite-form-0.6.0
- old
+ new
@@ -31,68 +31,82 @@
embeds_many :unvalidated_many, class_name: 'UnvalidatedAssoc'
end
end
context do
- subject(:instance) { Main.instantiate name: 'hello', validated_one: {name: 'name'} }
+ subject(:instance) { Main.instantiate name: 'hello', validated_one: { name: 'name' } }
+
it { is_expected.to be_valid }
end
context do
subject(:instance) { Main.instantiate name: 'hello', validated_one: {} }
+
it { is_expected.not_to be_valid }
+
specify do
expect { instance.validate }.to change { instance.errors.messages }
.to(validated_one: ['is invalid'])
end
end
context do
- subject(:instance) { Main.instantiate name: 'hello', unvalidated_one: {name: 'name'} }
+ subject(:instance) { Main.instantiate name: 'hello', unvalidated_one: { name: 'name' } }
+
it { is_expected.to be_valid }
end
context do
subject(:instance) { Main.instantiate name: 'hello', unvalidated_one: {} }
+
it { is_expected.to be_valid }
end
context do
- subject(:instance) { Main.instantiate name: 'hello', validated_many: [{name: 'name'}] }
+ subject(:instance) { Main.instantiate name: 'hello', validated_many: [{ name: 'name' }] }
+
it { is_expected.to be_valid }
end
context do
subject(:instance) { Main.instantiate name: 'hello', validated_many: [{}] }
+
it { is_expected.not_to be_valid }
+
specify do
expect { instance.validate }.to change { instance.errors.messages }
.to('validated_many.0.name': ["can't be blank"], validated_many: ['is invalid'])
end
end
context do
- subject(:instance) { Main.instantiate name: 'hello', unvalidated_many: [{name: 'name'}] }
+ subject(:instance) { Main.instantiate name: 'hello', unvalidated_many: [{ name: 'name' }] }
+
it { is_expected.to be_valid }
end
context do
subject(:instance) { Main.instantiate name: 'hello', unvalidated_many: [{}] }
+
it { is_expected.to be_valid }
end
context do
- subject(:instance) { Main.instantiate name: 'hello', validated_many: [{name: 'name'}], validated_one: {} }
+ subject(:instance) { Main.instantiate name: 'hello', validated_many: [{ name: 'name' }], validated_one: {} }
+
it { is_expected.not_to be_valid }
+
specify do
expect { instance.validate }.to change { instance.errors.messages }
.to(validated_one: ['is invalid'])
end
end
context do
- subject(:instance) { Main.instantiate name: 'hello', validated_many: [{}], validated_one: {name: 'name'} }
+ subject(:instance) { Main.instantiate name: 'hello', validated_many: [{}], validated_one: { name: 'name' } }
+
it { is_expected.not_to be_valid }
+
specify do
expect { instance.validate }.to change { instance.errors.messages }
.to('validated_many.0.name': ["can't be blank"], validated_many: ['is invalid'])
end
end