yukonisuru 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +14 -0
  4. data/.rspec +4 -0
  5. data/.travis.yml +13 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +1101 -0
  9. data/Rakefile +1 -0
  10. data/config/locales/en.yml +113 -0
  11. data/lib/yukonisuru.rb +93 -0
  12. data/lib/yukonisuru/matchers/ensure_valid_alpha_format_of.rb +26 -0
  13. data/lib/yukonisuru/matchers/ensure_valid_alpha_numeric_format_of.rb +26 -0
  14. data/lib/yukonisuru/matchers/ensure_valid_base64_format_of.rb +26 -0
  15. data/lib/yukonisuru/matchers/ensure_valid_boolean_format_of.rb +26 -0
  16. data/lib/yukonisuru/matchers/ensure_valid_credit_card_format_of.rb +26 -0
  17. data/lib/yukonisuru/matchers/ensure_valid_currency_format_of.rb +26 -0
  18. data/lib/yukonisuru/matchers/ensure_valid_cusip_format_of.rb +26 -0
  19. data/lib/yukonisuru/matchers/ensure_valid_email_format_of.rb +26 -0
  20. data/lib/yukonisuru/matchers/ensure_valid_equality_matcher_of.rb +40 -0
  21. data/lib/yukonisuru/matchers/ensure_valid_gtin_format_of.rb +26 -0
  22. data/lib/yukonisuru/matchers/ensure_valid_hex_format_of.rb +26 -0
  23. data/lib/yukonisuru/matchers/ensure_valid_imei_format_of.rb +26 -0
  24. data/lib/yukonisuru/matchers/ensure_valid_ip_format_of.rb +26 -0
  25. data/lib/yukonisuru/matchers/ensure_valid_isbn_format_of.rb +26 -0
  26. data/lib/yukonisuru/matchers/ensure_valid_isin_format_of.rb +26 -0
  27. data/lib/yukonisuru/matchers/ensure_valid_latitude_format_of.rb +26 -0
  28. data/lib/yukonisuru/matchers/ensure_valid_longitude_format_of.rb +26 -0
  29. data/lib/yukonisuru/matchers/ensure_valid_mac_address_format_of.rb +26 -0
  30. data/lib/yukonisuru/matchers/ensure_valid_name_format_of.rb +26 -0
  31. data/lib/yukonisuru/matchers/ensure_valid_password_format_of.rb +26 -0
  32. data/lib/yukonisuru/matchers/ensure_valid_phone_format_of.rb +26 -0
  33. data/lib/yukonisuru/matchers/ensure_valid_sedol_format_of.rb +26 -0
  34. data/lib/yukonisuru/matchers/ensure_valid_slug_format_of.rb +26 -0
  35. data/lib/yukonisuru/matchers/ensure_valid_ssn_format_of.rb +26 -0
  36. data/lib/yukonisuru/matchers/ensure_valid_url_format_of.rb +26 -0
  37. data/lib/yukonisuru/matchers/ensure_valid_username_format_of.rb +26 -0
  38. data/lib/yukonisuru/matchers/ensure_valid_uuid_format_of.rb +26 -0
  39. data/lib/yukonisuru/validators/alpha_numeric_validator.rb +31 -0
  40. data/lib/yukonisuru/validators/alpha_validator.rb +31 -0
  41. data/lib/yukonisuru/validators/base64_validator.rb +9 -0
  42. data/lib/yukonisuru/validators/boolean_validator.rb +9 -0
  43. data/lib/yukonisuru/validators/credit_card_validator.rb +133 -0
  44. data/lib/yukonisuru/validators/currency_validator.rb +23 -0
  45. data/lib/yukonisuru/validators/cusip_validator.rb +33 -0
  46. data/lib/yukonisuru/validators/email_validator.rb +25 -0
  47. data/lib/yukonisuru/validators/equality_validator.rb +27 -0
  48. data/lib/yukonisuru/validators/gtin_validator.rb +59 -0
  49. data/lib/yukonisuru/validators/hex_validator.rb +9 -0
  50. data/lib/yukonisuru/validators/imei_validator.rb +37 -0
  51. data/lib/yukonisuru/validators/ip_validator.rb +9 -0
  52. data/lib/yukonisuru/validators/isbn_validator.rb +24 -0
  53. data/lib/yukonisuru/validators/isin_validator.rb +38 -0
  54. data/lib/yukonisuru/validators/latitude_validator.rb +9 -0
  55. data/lib/yukonisuru/validators/longitude_validator.rb +9 -0
  56. data/lib/yukonisuru/validators/mac_address_validator.rb +24 -0
  57. data/lib/yukonisuru/validators/name_validator.rb +9 -0
  58. data/lib/yukonisuru/validators/password_validator.rb +23 -0
  59. data/lib/yukonisuru/validators/phone_validator.rb +9 -0
  60. data/lib/yukonisuru/validators/sedol_validator.rb +32 -0
  61. data/lib/yukonisuru/validators/slug_validator.rb +9 -0
  62. data/lib/yukonisuru/validators/ssn_validator.rb +9 -0
  63. data/lib/yukonisuru/validators/url_validator.rb +36 -0
  64. data/lib/yukonisuru/validators/username_validator.rb +9 -0
  65. data/lib/yukonisuru/validators/uuid_validator.rb +28 -0
  66. data/lib/yukonisuru/version.rb +3 -0
  67. data/spec/lib/alpha_numeric_validator_spec.rb +91 -0
  68. data/spec/lib/alpha_validator_spec.rb +182 -0
  69. data/spec/lib/base64_validator_spec.rb +33 -0
  70. data/spec/lib/boolean_validator_spec.rb +35 -0
  71. data/spec/lib/credit_card_validator_spec.rb +686 -0
  72. data/spec/lib/currency_validator_spec.rb +63 -0
  73. data/spec/lib/cusip_validator_spec.rb +27 -0
  74. data/spec/lib/email_validator_spec.rb +109 -0
  75. data/spec/lib/equality_validator_spec.rb +334 -0
  76. data/spec/lib/gtin_validator_spec.rb +101 -0
  77. data/spec/lib/hex_validator_spec.rb +73 -0
  78. data/spec/lib/imei_validator_spec.rb +41 -0
  79. data/spec/lib/ip_validator_spec.rb +33 -0
  80. data/spec/lib/isbn_validator_spec.rb +41 -0
  81. data/spec/lib/isin_validator_spec.rb +35 -0
  82. data/spec/lib/latitude_validator_spec.rb +31 -0
  83. data/spec/lib/longitude_validator_spec.rb +31 -0
  84. data/spec/lib/mac_address_validator_spec.rb +54 -0
  85. data/spec/lib/name_validator_spec.rb +39 -0
  86. data/spec/lib/password_validator_spec.rb +87 -0
  87. data/spec/lib/phone_validator_spec.rb +42 -0
  88. data/spec/lib/sedol_validator_spec.rb +31 -0
  89. data/spec/lib/slug_validator_spec.rb +41 -0
  90. data/spec/lib/ssn_validator_spec.rb +36 -0
  91. data/spec/lib/url_validator_spec.rb +109 -0
  92. data/spec/lib/username_validator_spec.rb +37 -0
  93. data/spec/lib/uuid_validator_spec.rb +157 -0
  94. data/spec/spec_helper.rb +12 -0
  95. data/yukonisuru.gemspec +29 -0
  96. metadata +264 -0
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+
3
+ describe GtinValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :code, :name
10
+ validates :code, gtin: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("73513537").for(:code) }
17
+ it { should allow_value("4006381333931").for(:code) }
18
+ it { should allow_value("9780471117094").for(:code) }
19
+ it { should allow_value("73 51353 7").for(:code) }
20
+ it { should allow_value("4 006381 33393 1").for(:code) }
21
+ it { should allow_value("97 804711 17094").for(:code) }
22
+
23
+ it { should_not allow_value('').for(:code) }
24
+ it { should_not allow_value(' ').for(:code) }
25
+ it { should_not allow_value(nil).for(:code) }
26
+ it { should_not allow_value("73513536").for(:code) }
27
+ it { should_not allow_value("97804711170941").for(:code) }
28
+ it { should_not allow_value("73 51353 6").for(:code) }
29
+ it { should_not allow_value("97 804711 17094 1").for(:code) }
30
+ it { should_not allow_value("! \#$%\`|").for(:code) }
31
+ it { should_not allow_value("<>@[]\`|").for(:code) }
32
+
33
+ it { should ensure_valid_gtin_format_of(:code) }
34
+ it { should_not ensure_valid_gtin_format_of(:name) }
35
+ end
36
+
37
+ context "with :strict option has a valid value" do
38
+ let(:klass) do
39
+ Class.new do
40
+ include ActiveModel::Validations
41
+ attr_accessor :code, :name
42
+ validates :code, gtin: { strict: true }
43
+ end
44
+ end
45
+
46
+ subject { klass.new }
47
+
48
+ it { should allow_value("73513537").for(:code) }
49
+ it { should allow_value("4006381333931").for(:code) }
50
+ it { should allow_value("9780471117094").for(:code) }
51
+
52
+ it { should_not allow_value('').for(:code) }
53
+ it { should_not allow_value(' ').for(:code) }
54
+ it { should_not allow_value(nil).for(:code) }
55
+ it { should_not allow_value("73513536").for(:code) }
56
+ it { should_not allow_value("97804711170941").for(:code) }
57
+ it { should_not allow_value("73 51353 6").for(:code) }
58
+ it { should_not allow_value("73 51353 7").for(:code) }
59
+ it { should_not allow_value("4 006381 33393 1").for(:code) }
60
+ it { should_not allow_value("97 804711 17094 1").for(:code) }
61
+ it { should_not allow_value("97 804711 17094").for(:code) }
62
+ it { should_not allow_value("! \#$%\`|").for(:code) }
63
+ it { should_not allow_value("<>@[]\`|").for(:code) }
64
+
65
+ it { should ensure_valid_gtin_format_of(:code) }
66
+ it { should_not ensure_valid_gtin_format_of(:name) }
67
+ end
68
+
69
+ context "with format: :ean_8 and :strict options has a valid value" do
70
+ let(:klass) do
71
+ Class.new do
72
+ include ActiveModel::Validations
73
+ attr_accessor :code, :name
74
+ validates :code, gtin: { format: :ean_8, strict: true }
75
+ end
76
+ end
77
+
78
+ subject { klass.new }
79
+
80
+ it { should allow_value("73513537").for(:code) }
81
+
82
+ it { should_not allow_value('').for(:code) }
83
+ it { should_not allow_value(' ').for(:code) }
84
+ it { should_not allow_value(nil).for(:code) }
85
+ it { should_not allow_value("73513536").for(:code) }
86
+ it { should_not allow_value("4006381333931").for(:code) }
87
+ it { should_not allow_value("9780471117094").for(:code) }
88
+ it { should_not allow_value("97804711170941").for(:code) }
89
+ it { should_not allow_value("73 51353 6").for(:code) }
90
+ it { should_not allow_value("73 51353 7").for(:code) }
91
+ it { should_not allow_value("4 006381 33393 1").for(:code) }
92
+ it { should_not allow_value("97 804711 17094 1").for(:code) }
93
+ it { should_not allow_value("97 804711 17094").for(:code) }
94
+ it { should_not allow_value("! \#$%\`|").for(:code) }
95
+ it { should_not allow_value("<>@[]\`|").for(:code) }
96
+
97
+ it { should ensure_valid_gtin_format_of(:code) }
98
+ it { should_not ensure_valid_gtin_format_of(:name) }
99
+ end
100
+
101
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe HexValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :color, :name
10
+ validates :color, hex: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("#aaa").for(:color) }
17
+ it { should allow_value("#AAA").for(:color) }
18
+ it { should allow_value("#aaaaaa").for(:color) }
19
+ it { should allow_value("#AAAAAA").for(:color) }
20
+ it { should allow_value("#999").for(:color) }
21
+ it { should allow_value("#999999").for(:color) }
22
+ it { should allow_value("#a9a").for(:color) }
23
+ it { should allow_value("#A9A").for(:color) }
24
+ it { should allow_value("#a9a9a9").for(:color) }
25
+ it { should allow_value("#A9A9A9").for(:color) }
26
+ it { should allow_value("aaa").for(:color) }
27
+ it { should allow_value("AAA").for(:color) }
28
+ it { should allow_value("aaaaaa").for(:color) }
29
+ it { should allow_value("AAAAAA").for(:color) }
30
+ it { should allow_value("999").for(:color) }
31
+ it { should allow_value("999999").for(:color) }
32
+ it { should allow_value("a9a").for(:color) }
33
+ it { should allow_value("A9A").for(:color) }
34
+ it { should allow_value("a9a9a9").for(:color) }
35
+ it { should allow_value("A9A9A9").for(:color) }
36
+
37
+ it { should_not allow_value('').for(:color) }
38
+ it { should_not allow_value(' ').for(:color) }
39
+ it { should_not allow_value(nil).for(:color) }
40
+ it { should_not allow_value("#").for(:color) }
41
+ it { should_not allow_value("#9").for(:color) }
42
+ it { should_not allow_value("#9a").for(:color) }
43
+ it { should_not allow_value("#9A").for(:color) }
44
+ it { should_not allow_value("#hhh").for(:color) }
45
+ it { should_not allow_value("#HHH").for(:color) }
46
+ it { should_not allow_value("#9h9").for(:color) }
47
+ it { should_not allow_value("#9H9").for(:color) }
48
+ it { should_not allow_value("#9a9a").for(:color) }
49
+ it { should_not allow_value("#9A9A").for(:color) }
50
+ it { should_not allow_value("#9a9a9").for(:color) }
51
+ it { should_not allow_value("#9A9A9").for(:color) }
52
+ it { should_not allow_value("#9a9a9a9").for(:color) }
53
+ it { should_not allow_value("#9A9A9A9").for(:color) }
54
+ it { should_not allow_value(" #9a9").for(:color) }
55
+ it { should_not allow_value(" #9A9").for(:color) }
56
+ it { should_not allow_value(" #9a9 ").for(:color) }
57
+ it { should_not allow_value(" #9A9 ").for(:color) }
58
+ it { should_not allow_value("#9a9 ").for(:color) }
59
+ it { should_not allow_value("#9A9 ").for(:color) }
60
+ it { should_not allow_value(" 9a9").for(:color) }
61
+ it { should_not allow_value(" 9A9").for(:color) }
62
+ it { should_not allow_value(" 9a9 ").for(:color) }
63
+ it { should_not allow_value(" 9A9 ").for(:color) }
64
+ it { should_not allow_value("9a9 ").for(:color) }
65
+ it { should_not allow_value("9A9 ").for(:color) }
66
+ it { should_not allow_value("! \#$%\`|").for(:color) }
67
+ it { should_not allow_value("<>@[]\`|").for(:color) }
68
+
69
+ it { should ensure_valid_hex_format_of(:color) }
70
+ it { should_not ensure_valid_hex_format_of(:name) }
71
+ end
72
+
73
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe ImeiValidator do
4
+
5
+ context "has valid format" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :imei, :name
10
+ validates :imei, imei: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value(356843052637512).for(:imei) }
17
+ it { should allow_value("356843052637512").for(:imei) }
18
+ it { should allow_value("35-684305-2637512").for(:imei) }
19
+ it { should allow_value("35-684305.263.7512").for(:imei) }
20
+
21
+ context "value too short" do
22
+ it { should_not allow_value("3568430537512").for(:imei) }
23
+ it { should_not allow_value("3").for(:imei) }
24
+ end
25
+
26
+ it "can't be too long" do
27
+ should_not allow_value("35684305263751233").for(:imei)
28
+ end
29
+
30
+ context "checksum doesn't match" do
31
+ it { should_not allow_value("356843052637513").for(:imei) }
32
+ it { should_not allow_value("156843052637512").for(:imei) }
33
+ end
34
+
35
+ it { should_not allow_value("invalid").for(:imei) }
36
+
37
+ it { should ensure_valid_imei_format_of(:imei) }
38
+ it { should_not ensure_valid_imei_format_of(:name) }
39
+ end
40
+
41
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe IpValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :ip, :name
10
+ validates :ip, ip: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("0.0.0.0").for(:ip) }
17
+ it { should allow_value("127.0.0.1").for(:ip) }
18
+ it { should allow_value("99.39.240.31").for(:ip) }
19
+
20
+ it { should_not allow_value('').for(:ip) }
21
+ it { should_not allow_value(' ').for(:ip) }
22
+ it { should_not allow_value(nil).for(:ip) }
23
+ it { should_not allow_value("0 0 0 0").for(:ip) }
24
+ it { should_not allow_value("0.0.0.0:3000").for(:ip) }
25
+ it { should_not allow_value("22.22.333.22").for(:ip) }
26
+ it { should_not allow_value("! \#$%\`|").for(:ip) }
27
+ it { should_not allow_value("<>@[]\`|").for(:ip) }
28
+
29
+ it { should ensure_valid_ip_format_of(:ip) }
30
+ it { should_not ensure_valid_ip_format_of(:name) }
31
+ end
32
+
33
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe IsbnValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :isbn, :name
10
+ validates :isbn, isbn: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("9519854894").for(:isbn) }
17
+ it { should allow_value("951 98548 9 4").for(:isbn) }
18
+ it { should allow_value("951-98548-9-4").for(:isbn) }
19
+ it { should allow_value("951-98548 9 4").for(:isbn) }
20
+ it { should allow_value("0-9722051-1-X").for(:isbn) }
21
+ it { should allow_value("0-9722051-1-x").for(:isbn) }
22
+ it { should allow_value("9781590599938").for(:isbn) }
23
+ it { should allow_value("978 159059 9938").for(:isbn) }
24
+ it { should allow_value("978-159059-9938").for(:isbn) }
25
+ it { should allow_value("978-159059 9938").for(:isbn) }
26
+
27
+ it { should_not allow_value('').for(:isbn) }
28
+ it { should_not allow_value(' ').for(:isbn) }
29
+ it { should_not allow_value(nil).for(:isbn) }
30
+ it { should_not allow_value("951-98548-9-p").for(:isbn) }
31
+ it { should_not allow_value("abc123ab3344").for(:isbn) }
32
+ it { should_not allow_value("12345678901234").for(:isbn) }
33
+ it { should_not allow_value("9991a9010599938").for(:isbn) }
34
+ it { should_not allow_value("! \#$%\`|").for(:isbn) }
35
+ it { should_not allow_value("<>@[]\`|").for(:isbn) }
36
+
37
+ it { should ensure_valid_isbn_format_of(:isbn) }
38
+ it { should_not ensure_valid_isbn_format_of(:name) }
39
+ end
40
+
41
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe IsinValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :isin, :name
10
+ validates :isin, isin: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("US0378331005").for(:isin) }
17
+ it { should allow_value("AU0000XVGZA3").for(:isin) }
18
+
19
+ it { should_not allow_value('').for(:isin) }
20
+ it { should_not allow_value(' ').for(:isin) }
21
+ it { should_not allow_value(nil).for(:isin) }
22
+ it { should_not allow_value("US03783310055").for(:isin) }
23
+ #it { should_not allow_value("US0378331004").for(:isin) }
24
+ it { should_not allow_value("US037833100").for(:isin) }
25
+ it { should_not allow_value("US03783315").for(:isin) }
26
+ it { should_not allow_value("AA0000XVGZA3").for(:isin) }
27
+ it { should_not allow_value("120378331004").for(:isin) }
28
+ it { should_not allow_value("! \#$%\`|").for(:isin) }
29
+ it { should_not allow_value("<>@[]\`|").for(:isin) }
30
+
31
+ it { should ensure_valid_isin_format_of(:isin) }
32
+ it { should_not ensure_valid_isin_format_of(:name) }
33
+ end
34
+
35
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe LatitudeValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :lat, :name
10
+ validates :lat, latitude: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value(-90).for(:lat) }
17
+ it { should allow_value(90).for(:lat) }
18
+ it { should allow_value(0).for(:lat) }
19
+ it { should allow_value(9.33).for(:lat) }
20
+
21
+ it { should_not allow_value('').for(:lat) }
22
+ it { should_not allow_value(' ').for(:lat) }
23
+ it { should_not allow_value(nil).for(:lat) }
24
+ it { should_not allow_value(-90.1).for(:lat) }
25
+ it { should_not allow_value(90.1).for(:lat) }
26
+
27
+ it { should ensure_valid_latitude_format_of(:lat) }
28
+ it { should_not ensure_valid_latitude_format_of(:name) }
29
+ end
30
+
31
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe LongitudeValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :lon, :name
10
+ validates :lon, longitude: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value(-180).for(:lon) }
17
+ it { should allow_value(180).for(:lon) }
18
+ it { should allow_value(0).for(:lon) }
19
+ it { should allow_value(9.33).for(:lon) }
20
+
21
+ it { should_not allow_value('').for(:lon) }
22
+ it { should_not allow_value(' ').for(:lon) }
23
+ it { should_not allow_value(nil).for(:lon) }
24
+ it { should_not allow_value(-181.1).for(:lon) }
25
+ it { should_not allow_value(181.1).for(:lon) }
26
+
27
+ it { should ensure_valid_longitude_format_of(:lon) }
28
+ it { should_not ensure_valid_longitude_format_of(:name) }
29
+ end
30
+
31
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe MacAddressValidator do
4
+
5
+ context "has valid format" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :mac, :name
10
+ validates :mac, mac_address: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ # Valid formats
17
+ it { should allow_value("08:00:2b:01:02:03").for(:mac) }
18
+ it { should allow_value("08-00-2b-01-02-03").for(:mac) }
19
+ it { should allow_value("08.00.2b.01.02.03").for(:mac) }
20
+ it { should allow_value("08 00 2b 01 02 03").for(:mac) }
21
+ it { should allow_value("08002b:010203").for(:mac) }
22
+ it { should allow_value("08002b.010203").for(:mac) }
23
+ it { should allow_value("08002b-010203").for(:mac) }
24
+ it { should allow_value("0800.2b01.0203").for(:mac) }
25
+ it { should allow_value("0800-2b01-0203").for(:mac) }
26
+ it { should allow_value("0800 2b01 0203").for(:mac) }
27
+ it { should allow_value("08002b010203").for(:mac) }
28
+
29
+ # Mixed Separators
30
+ it { should_not allow_value("08-00:2b:01:02:03").for(:mac) }
31
+ it { should_not allow_value("08.00:2b:01:02:03").for(:mac) }
32
+ it { should_not allow_value("08 00:2b:01:02:03").for(:mac) }
33
+ it { should_not allow_value("0800-2b01:0203").for(:mac) }
34
+ it { should_not allow_value("0800 2b01:0203").for(:mac) }
35
+
36
+ # Too Short
37
+ it { should_not allow_value("08:00:2b:01:02").for(:mac) }
38
+ it { should_not allow_value("08-00-2b-01-02").for(:mac) }
39
+
40
+ # Too Long
41
+ it { should_not allow_value("08:00:2b:01:02:03:04").for(:mac) }
42
+
43
+ # Non-Hex Characters
44
+ it { should_not allow_value("qq:00:00:00:00:00").for(:mac) }
45
+
46
+ it { should_not allow_value(' ').for(:mac) }
47
+ it { should_not allow_value(nil).for(:mac) }
48
+ it { should_not allow_value("invalid").for(:mac) }
49
+
50
+ it { should ensure_valid_mac_address_format_of(:mac) }
51
+ it { should_not ensure_valid_mac_address_format_of(:name) }
52
+ end
53
+
54
+ end