validates_cnpj 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
@@ -1,6 +1,6 @@
1
1
  = ValidatesCNPJ {<img src="https://secure.travis-ci.org/plribeiro3000/validates_cnpj.png" />}[http://travis-ci.org/plribeiro3000/validates_cnpj]
2
2
 
3
- Rails gem to validate CNPJ. Don't forget to check {ValidatesCpf}[https://github.com/plribeiro3000/validates_cpf] and {ValidatesTelephone}[https://github.com/plribeiro3000/validates_telephone].
3
+ Rails gem to validate CNPJ. Don't forget to check {ValidatesCpf}[https://github.com/plribeiro3000/validates_cpf], {ValidatesTelephone}[https://github.com/plribeiro3000/validates_telephone] and {ValidatesHost}[https://github.com/plribeiro3000/validates_host].
4
4
 
5
5
  == Install
6
6
 
@@ -10,26 +10,17 @@ gem install validates_cnpj
10
10
 
11
11
  Lets say you have a model with "cnpj" string column that you want to be a valid CNPJ. Just add this to your model:
12
12
 
13
- class User < ActiveRecord::Base
13
+ class User < ActiveRecord::Base
14
14
  validates :cnpj, :cnpj => true
15
- end
15
+ end
16
16
 
17
17
  == Test
18
18
 
19
- This gem has matchers for shoulda-matchers and remarkable.
19
+ This gem has builtin matchers for shoulda-matchers and remarkable.
20
20
 
21
- If you are using shoulda-matchers, add this line to your spec_helper.rb :
22
- require "validates_cnpj/shoulda-matchers/validate_as_cnpj_matcher"
23
- If you are using remarkable, add this line to your spec_helper.rb :
24
- require "validates_cnpj/remarkable/validate_as_cnpj_matcher"
21
+ == Notes
25
22
 
26
- === How?
27
-
28
- You should use validates_as_cnpj(:attribute) just like any other shoulda matcher.
29
-
30
- == Goal
31
-
32
- This project is based on brcpfcnpj gem and his intention it to mantain a cleaner code to validate CNPJ and easy matchers to test it.
23
+ Since version 1.0.0, it isn't necessary to load any file inside your spec_helper anymore.
33
24
 
34
25
  == Contribute
35
26
 
@@ -1,3 +1,3 @@
1
1
  module ValidatesCnpj
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -6,6 +6,6 @@ require "validates_cnpj/remarkable/require_a_valid_cnpj_matcher" if defined?(::R
6
6
 
7
7
  class CnpjValidator < ActiveModel::EachValidator
8
8
  def validate_each(record, attribute, value)
9
- record.errors[attribute] << I18n.t("errors.messages.invalid") unless CNPJ.new(value).valid?
9
+ record.errors[attribute] << I18n.t("activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid") unless CNPJ.new(value).valid?
10
10
  end
11
11
  end
@@ -4,6 +4,7 @@ describe CnpjValidator do
4
4
  context "when cnpj is invalid" do
5
5
  before :each do
6
6
  @company = Company.new(:cnpj => "12345")
7
+ I18n.stub(:t).with("activerecord.errors.models.company.attributes.cnpj.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_cnpj
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