validates_cpf 1.0.0 → 1.1.0

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.
data/README.rdoc CHANGED
@@ -10,23 +10,19 @@ gem install validates_cpf
10
10
 
11
11
  Lets say you have a model with "cpf" string column that you want to be a valid CPF. Just add this to your model:
12
12
 
13
- ```ruby
14
- class User < ActiveRecord::Base
13
+ class User < ActiveRecord::Base
15
14
  validates :cpf, :cpf => true
16
- end
17
- ```
15
+ end
18
16
 
19
- == Test
20
17
 
21
- This gem has buitin matchers for shoulda-matchers and remarkable.
18
+ == Test
22
19
 
23
- === How?
20
+ This gem has builtin matchers for shoulda-matchers and remarkable.
24
21
 
25
- You should use require_a_valid_cpf(:attribute) or skip the attribute part if the attribute name is cpf.
22
+ == Notes
26
23
 
27
- == Goal
24
+ Since version 1.0.0, it isn't necessary to load any file inside your spec_helper anymore.
28
25
 
29
- This project is based on brcpfcnpj gem and his intention it to mantain a cleaner code to validate CPF and easy matchers to test it.
30
26
 
31
27
  == Contribute
32
28
 
data/lib/validates_cpf.rb CHANGED
@@ -6,6 +6,6 @@ require "validates_cpf/remarkable/require_a_valid_cpf_matcher" if defined?(::Rem
6
6
 
7
7
  class CpfValidator < ActiveModel::EachValidator
8
8
  def validate_each(record, attribute, value)
9
- record.errors[attribute] << I18n.t("errors.messages.invalid") unless CPF.new(value).valid?
9
+ record.errors[attribute] << I18n.t("activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid") unless CPF.new(value).valid?
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module ValidatesCpf
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -4,6 +4,7 @@ describe CpfValidator do
4
4
  context "when cpf is invalid" do
5
5
  before :each do
6
6
  @user = User.new(:cpf => "12345")
7
+ I18n.stub(:t).with("activerecord.errors.models.user.attributes.cpf.invalid").and_return("is invalid")
7
8
  end
8
9
 
9
10
  it "should set object as invalid" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_cpf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-24 00:00:00.000000000 Z
12
+ date: 2012-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord