magick_numbers_rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +4 -0
- data/lib/magick_numbers_rails/pesel_validator.rb +10 -0
- data/lib/magick_numbers_rails/regon_validator.rb +10 -0
- data/lib/magick_numbers_rails/version.rb +1 -1
- data/spec/nip_validator_spec.rb +2 -2
- data/spec/pesel_validator_spec.rb +29 -0
- data/spec/regon_validator_spec.rb +29 -0
- metadata +7 -1
data/README.markdown
CHANGED
data/spec/nip_validator_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'rspec'
|
3
3
|
require 'active_model'
|
4
4
|
|
5
|
-
class
|
5
|
+
class BasicNipModel
|
6
6
|
include ActiveModel::Validations
|
7
7
|
|
8
8
|
attr_accessor :nip
|
@@ -13,7 +13,7 @@ end
|
|
13
13
|
|
14
14
|
describe "NipValidator" do
|
15
15
|
before(:each) do
|
16
|
-
@model =
|
16
|
+
@model = BasicNipModel.new
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should be valid" do
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec'
|
3
|
+
require 'active_model'
|
4
|
+
|
5
|
+
class BasicPeselModel
|
6
|
+
include ActiveModel::Validations
|
7
|
+
|
8
|
+
attr_accessor :pesel
|
9
|
+
|
10
|
+
validates :pesel, :presence => true, :pesel => true
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
describe "PeselValidator" do
|
15
|
+
before(:each) do
|
16
|
+
@model = BasicPeselModel.new
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be valid" do
|
20
|
+
@model.should_not be_valid
|
21
|
+
@model.pesel = "44051401359"
|
22
|
+
@model.should be_valid
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be invalid" do
|
26
|
+
@model.pesel = "44051401353"
|
27
|
+
@model.should_not be_valid
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec'
|
3
|
+
require 'active_model'
|
4
|
+
|
5
|
+
class BasicRegonModel
|
6
|
+
include ActiveModel::Validations
|
7
|
+
|
8
|
+
attr_accessor :regon
|
9
|
+
|
10
|
+
validates :regon, :presence => true, :regon => true
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
describe "RegonValidator" do
|
15
|
+
before(:each) do
|
16
|
+
@model = BasicRegonModel.new
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be valid" do
|
20
|
+
@model.should_not be_valid
|
21
|
+
@model.regon = "192598184"
|
22
|
+
@model.should be_valid
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be invalid" do
|
26
|
+
@model.regon = "192598183"
|
27
|
+
@model.should_not be_valid
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: magick_numbers_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mariusz Nosinski
|
@@ -52,9 +52,13 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- lib/magick_numbers_rails.rb
|
54
54
|
- lib/magick_numbers_rails/nip_validator.rb
|
55
|
+
- lib/magick_numbers_rails/pesel_validator.rb
|
56
|
+
- lib/magick_numbers_rails/regon_validator.rb
|
55
57
|
- lib/magick_numbers_rails/version.rb
|
56
58
|
- magick_numbers_rails.gemspec
|
57
59
|
- spec/nip_validator_spec.rb
|
60
|
+
- spec/pesel_validator_spec.rb
|
61
|
+
- spec/regon_validator_spec.rb
|
58
62
|
- spec/spec_helper.rb
|
59
63
|
has_rdoc: true
|
60
64
|
homepage: https://github.com/marioosh/magick_numbers_rails
|
@@ -86,4 +90,6 @@ specification_version: 3
|
|
86
90
|
summary: Rails 3 validators for magick numbers like PESEL, NIP, REGON
|
87
91
|
test_files:
|
88
92
|
- spec/nip_validator_spec.rb
|
93
|
+
- spec/pesel_validator_spec.rb
|
94
|
+
- spec/regon_validator_spec.rb
|
89
95
|
- spec/spec_helper.rb
|