activerecord-humanized_errors 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 784e2e2c6ac4d385140bd0b52a2e7af7392a64c8
4
- data.tar.gz: c714f09b4cf454f26e791c1c8478d189a650c3ee
3
+ metadata.gz: 3c588be2d000a46550e933b7823e5cc2d80991bc
4
+ data.tar.gz: ecb6f50324f49d4190e112ce312ecb83a8cd3876
5
5
  SHA512:
6
- metadata.gz: f60409ef10dfb4350012baf443536b8655bc7710d195f162027e15bc7411c38430a16bc85cc0eeae68d7dac3d7bb47368553eeb37bb61da52652a96abf8a055b
7
- data.tar.gz: de0d31f1d609b2920a023a2040e256255e5e8aa595fb3408976a6e1de5d5a100ea340fe5e715f840f0ef6acf5a66a7c075a2b8e025aca50959eb5406e659ac7e
6
+ metadata.gz: 2466dba2e1b33ab7a8a05db13142e0e9d88ed85d7f9020cabef3955dd013b762950b927905eb4c2e58c38f22d9492f3e249ba89133d4df8f3c3a9a3ef9ad66d0
7
+ data.tar.gz: e4a6fd20312b482ee21f74336597b92ae688db354d96a993b59ca18d34c0a878ef3c4f3f77e82ad560905a44809e61fdb00b8a63df83b83b8b3613c14d4b657b
@@ -2,6 +2,8 @@ module ActiveRecord
2
2
 
3
3
  module HumanizedErrors
4
4
  def humanized_errors
5
+ errors.clear
6
+ send :run_validations!
5
7
  errors.full_messages.join ', '
6
8
  end
7
9
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module HumanizedErrors
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
@@ -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) { should eq(subject.errors.full_messages.join(', ')) }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-humanized_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignacio Galindo