activerecord-humanized_errors 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c588be2d000a46550e933b7823e5cc2d80991bc
|
4
|
+
data.tar.gz: ecb6f50324f49d4190e112ce312ecb83a8cd3876
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2466dba2e1b33ab7a8a05db13142e0e9d88ed85d7f9020cabef3955dd013b762950b927905eb4c2e58c38f22d9492f3e249ba89133d4df8f3c3a9a3ef9ad66d0
|
7
|
+
data.tar.gz: e4a6fd20312b482ee21f74336597b92ae688db354d96a993b59ca18d34c0a878ef3c4f3f77e82ad560905a44809e61fdb00b8a63df83b83b8b3613c14d4b657b
|
@@ -18,7 +18,39 @@ describe ActiveRecord::HumanizedErrors do
|
|
18
18
|
shared_examples_for :invalid_model do
|
19
19
|
it { should be_invalid }
|
20
20
|
its(:humanized_errors) { should be_a(String) }
|
21
|
-
its(:humanized_errors)
|
21
|
+
its(:humanized_errors) do
|
22
|
+
subject.errors.clear
|
23
|
+
subject.send :run_validations!
|
24
|
+
should eq(subject.errors.full_messages.join(', '))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when instantiating new record' do
|
29
|
+
context 'without any required attribute' do
|
30
|
+
let(:model) { Model.new }
|
31
|
+
|
32
|
+
it_behaves_like :invalid_model
|
33
|
+
|
34
|
+
['Name', 'Email'].each do |column|
|
35
|
+
its(:humanized_errors) { should include("#{column} can't be blank") }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with 1 of 2 required attributes' do
|
40
|
+
let(:model) { Model.new name: 'John' }
|
41
|
+
|
42
|
+
it_behaves_like :invalid_model
|
43
|
+
|
44
|
+
its(:humanized_errors) { should eq("Email can't be blank") }
|
45
|
+
its(:humanized_errors) { should_not include("Name can't be blank") }
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'with all required attributes' do
|
49
|
+
let(:model) { Model.new name: 'John', email: 'john@example.com' }
|
50
|
+
|
51
|
+
it { should be_valid }
|
52
|
+
its(:humanized_errors) { should be_blank }
|
53
|
+
end
|
22
54
|
end
|
23
55
|
|
24
56
|
context 'when creating new record' do
|