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,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Base64Validator 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, base64: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("YW55IGNhcm5hbCBwbGVhcw==").for(:code) }
17
+ it { should allow_value("YW55IGNhcm5hbCBwbGVhc3U=").for(:code) }
18
+ it { should allow_value("YW55IGNhcm5hbCBwbGVhc3Vy").for(:code) }
19
+ it { should allow_value("YW55IGNhcm5hbCBwbGVhc3VyZQ==").for(:code) }
20
+ it { should allow_value("YW55IGNhcm5hbCBwbGVhc3VyZS4=").for(:code) }
21
+
22
+ it { should_not allow_value('').for(:code) }
23
+ it { should_not allow_value(' ').for(:code) }
24
+ it { should_not allow_value(nil).for(:code) }
25
+ it { should_not allow_value("1a.b2").for(:code) }
26
+ it { should_not allow_value("1a b2").for(:code) }
27
+ it { should_not allow_value("1a.b2==").for(:code) }
28
+
29
+ it { should ensure_valid_base64_format_of(:code) }
30
+ it { should_not ensure_valid_base64_format_of(:name) }
31
+ end
32
+
33
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe BooleanValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :active, :name
10
+ validates :active, boolean: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value(true).for(:active) }
17
+ it { should allow_value(false).for(:active) }
18
+ it { should allow_value(1).for(:active) }
19
+ it { should allow_value(0).for(:active) }
20
+
21
+ it { should_not allow_value('').for(:active) }
22
+ it { should_not allow_value(' ').for(:active) }
23
+ it { should_not allow_value(nil).for(:active) }
24
+ it { should_not allow_value("true").for(:active) }
25
+ it { should_not allow_value("false").for(:active) }
26
+ it { should_not allow_value("1").for(:active) }
27
+ it { should_not allow_value("0").for(:active) }
28
+ it { should_not allow_value("! \#$%\`|").for(:active) }
29
+ it { should_not allow_value("<>@[]\`|").for(:active) }
30
+
31
+ it { should ensure_valid_boolean_format_of(:active) }
32
+ it { should_not ensure_valid_boolean_format_of(:name) }
33
+ end
34
+
35
+ end
@@ -0,0 +1,686 @@
1
+ require 'spec_helper'
2
+
3
+ describe CreditCardValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :cc_number, :name
10
+ validates :cc_number, credit_card: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("340000000000000").for(:cc_number) }
17
+ it { should allow_value("370000000000000").for(:cc_number) }
18
+ it { should allow_value("3700 0000.0000-000").for(:cc_number) }
19
+ it { should allow_value("30000000000000").for(:cc_number) }
20
+ it { should allow_value("30100000000000").for(:cc_number) }
21
+ it { should allow_value("30200000000000").for(:cc_number) }
22
+ it { should allow_value("30300000000000").for(:cc_number) }
23
+ it { should allow_value("30400000000000").for(:cc_number) }
24
+ it { should allow_value("30500000000000").for(:cc_number) }
25
+ it { should allow_value("36000000000000").for(:cc_number) }
26
+ it { should allow_value("54000000000000").for(:cc_number) }
27
+ it { should allow_value("55000000000000").for(:cc_number) }
28
+ it { should allow_value("5500000000000000").for(:cc_number) }
29
+ it { should allow_value("5500 0000.0000-00").for(:cc_number) }
30
+ it { should allow_value("5500 0000.0000-0000").for(:cc_number) }
31
+ it { should allow_value("6011000000000000").for(:cc_number) }
32
+ it { should allow_value("6221260000000000").for(:cc_number) }
33
+ it { should allow_value("6221270000000000").for(:cc_number) }
34
+ it { should allow_value("6221280000000000").for(:cc_number) }
35
+ it { should allow_value("6221290000000000").for(:cc_number) }
36
+ it { should allow_value("6221300000000000").for(:cc_number) }
37
+ it { should allow_value("6221400000000000").for(:cc_number) }
38
+ it { should allow_value("6221500000000000").for(:cc_number) }
39
+ it { should allow_value("6221600000000000").for(:cc_number) }
40
+ it { should allow_value("6221700000000000").for(:cc_number) }
41
+ it { should allow_value("6221800000000000").for(:cc_number) }
42
+ it { should allow_value("6221900000000000").for(:cc_number) }
43
+ it { should allow_value("6222000000000000").for(:cc_number) }
44
+ it { should allow_value("6223000000000000").for(:cc_number) }
45
+ it { should allow_value("6224000000000000").for(:cc_number) }
46
+ it { should allow_value("6225000000000000").for(:cc_number) }
47
+ it { should allow_value("6226000000000000").for(:cc_number) }
48
+ it { should allow_value("6227000000000000").for(:cc_number) }
49
+ it { should allow_value("6228000000000000").for(:cc_number) }
50
+ it { should allow_value("6229000000000000").for(:cc_number) }
51
+ it { should allow_value("6229100000000000").for(:cc_number) }
52
+ it { should allow_value("6229200000000000").for(:cc_number) }
53
+ it { should allow_value("6229210000000000").for(:cc_number) }
54
+ it { should allow_value("6229220000000000").for(:cc_number) }
55
+ it { should allow_value("6229230000000000").for(:cc_number) }
56
+ it { should allow_value("6229240000000000").for(:cc_number) }
57
+ it { should allow_value("6229250000000000").for(:cc_number) }
58
+ it { should allow_value("6440000000000000").for(:cc_number) }
59
+ it { should allow_value("6450000000000000").for(:cc_number) }
60
+ it { should allow_value("6460000000000000").for(:cc_number) }
61
+ it { should allow_value("6470000000000000").for(:cc_number) }
62
+ it { should allow_value("6480000000000000").for(:cc_number) }
63
+ it { should allow_value("6490000000000000").for(:cc_number) }
64
+ it { should allow_value("6500000000000000").for(:cc_number) }
65
+ it { should allow_value("6500 0000.0000-0000").for(:cc_number) }
66
+ it { should allow_value("3528000000000000").for(:cc_number) }
67
+ it { should allow_value("3529000000000000").for(:cc_number) }
68
+ it { should allow_value("3530000000000000").for(:cc_number) }
69
+ it { should allow_value("3540000000000000").for(:cc_number) }
70
+ it { should allow_value("3550000000000000").for(:cc_number) }
71
+ it { should allow_value("3560000000000000").for(:cc_number) }
72
+ it { should allow_value("3570000000000000").for(:cc_number) }
73
+ it { should allow_value("3580000000000000").for(:cc_number) }
74
+ it { should allow_value("3580 0000.0000-0000").for(:cc_number) }
75
+ it { should allow_value("6304000000000000").for(:cc_number) }
76
+ it { should allow_value("6706000000000000").for(:cc_number) }
77
+ it { should allow_value("6771000000000000").for(:cc_number) }
78
+ it { should allow_value("6709000000000000").for(:cc_number) }
79
+ it { should allow_value("67090000000000000").for(:cc_number) }
80
+ it { should allow_value("670900000000000000").for(:cc_number) }
81
+ it { should allow_value("6709000000000000000").for(:cc_number) }
82
+ it { should allow_value("6709 0000.0000-0000").for(:cc_number) }
83
+ it { should allow_value("6709 0000.0000-00000").for(:cc_number) }
84
+ it { should allow_value("6709 0000.0000-000000").for(:cc_number) }
85
+ it { should allow_value("6709 0000.0000-0000000").for(:cc_number) }
86
+ it { should allow_value("6221260000000000").for(:cc_number) }
87
+ it { should allow_value("6221270000000000").for(:cc_number) }
88
+ it { should allow_value("6221280000000000").for(:cc_number) }
89
+ it { should allow_value("6221300000000000").for(:cc_number) }
90
+ it { should allow_value("6221400000000000").for(:cc_number) }
91
+ it { should allow_value("6221500000000000").for(:cc_number) }
92
+ it { should allow_value("6221600000000000").for(:cc_number) }
93
+ it { should allow_value("6221700000000000").for(:cc_number) }
94
+ it { should allow_value("6221800000000000").for(:cc_number) }
95
+ it { should allow_value("6221900000000000").for(:cc_number) }
96
+ it { should allow_value("6222000000000000").for(:cc_number) }
97
+ it { should allow_value("6223000000000000").for(:cc_number) }
98
+ it { should allow_value("6224000000000000").for(:cc_number) }
99
+ it { should allow_value("6225000000000000").for(:cc_number) }
100
+ it { should allow_value("6226000000000000").for(:cc_number) }
101
+ it { should allow_value("6227000000000000").for(:cc_number) }
102
+ it { should allow_value("6228000000000000").for(:cc_number) }
103
+ it { should allow_value("6229000000000000").for(:cc_number) }
104
+ it { should allow_value("6229100000000000").for(:cc_number) }
105
+ it { should allow_value("6229200000000000").for(:cc_number) }
106
+ it { should allow_value("6229210000000000").for(:cc_number) }
107
+ it { should allow_value("6229220000000000").for(:cc_number) }
108
+ it { should allow_value("6229230000000000").for(:cc_number) }
109
+ it { should allow_value("6229240000000000").for(:cc_number) }
110
+ it { should allow_value("6229250000000000").for(:cc_number) }
111
+ it { should allow_value("62292500000000000").for(:cc_number) }
112
+ it { should allow_value("622925000000000000").for(:cc_number) }
113
+ it { should allow_value("6229250000000000000").for(:cc_number) }
114
+ it { should allow_value("6229 2500.0000-0000").for(:cc_number) }
115
+ it { should allow_value("6229 2500.0000-00000").for(:cc_number) }
116
+ it { should allow_value("6229 2500.0000-000000").for(:cc_number) }
117
+ it { should allow_value("6229 2500.0000-0000000").for(:cc_number) }
118
+ it { should allow_value("4000000000000000").for(:cc_number) }
119
+ it { should allow_value("4000 0000.0000-0000").for(:cc_number) }
120
+
121
+ it { should_not allow_value('').for(:cc_number) }
122
+ it { should_not allow_value(' ').for(:cc_number) }
123
+ it { should_not allow_value(nil).for(:cc_number) }
124
+ it { should_not allow_value("#").for(:cc_number) }
125
+ it { should_not allow_value("9").for(:cc_number) }
126
+ it { should_not allow_value("a").for(:cc_number) }
127
+ it { should_not allow_value("270000000000000").for(:cc_number) }
128
+ it { should_not allow_value("37000000000000").for(:cc_number) }
129
+ it { should_not allow_value("3700000000000000").for(:cc_number) }
130
+ it { should_not allow_value("2700 0000.0000-000").for(:cc_number) }
131
+ it { should_not allow_value("3700 0000.0000-00").for(:cc_number) }
132
+ it { should_not allow_value("3700 0000.0000-0000").for(:cc_number) }
133
+ it { should_not allow_value("5500000000000").for(:cc_number) }
134
+ it { should_not allow_value("5500 0000.0000-0").for(:cc_number) }
135
+ it { should_not allow_value("650000000000000").for(:cc_number) }
136
+ it { should_not allow_value("65000000000000000").for(:cc_number) }
137
+ it { should_not allow_value("6500 0000.0000-000").for(:cc_number) }
138
+ it { should_not allow_value("6500 0000.0000-00000").for(:cc_number) }
139
+ it { should_not allow_value("2580000000000000").for(:cc_number) }
140
+ it { should_not allow_value("358000000000000").for(:cc_number) }
141
+ it { should_not allow_value("35800000000000000").for(:cc_number) }
142
+ it { should_not allow_value("2580 0000.0000-0000").for(:cc_number) }
143
+ it { should_not allow_value("3580 0000.0000-000").for(:cc_number) }
144
+ it { should_not allow_value("3580 0000.0000-00000").for(:cc_number) }
145
+ it { should_not allow_value("5709000000000000").for(:cc_number) }
146
+ it { should_not allow_value("670900000000000").for(:cc_number) }
147
+ it { should_not allow_value("67090000000000000000").for(:cc_number) }
148
+ it { should_not allow_value("5709 0000.0000-0000").for(:cc_number) }
149
+ it { should_not allow_value("6709 0000.0000-000").for(:cc_number) }
150
+ it { should_not allow_value("6709 0000.0000-00000000").for(:cc_number) }
151
+ it { should_not allow_value("622925000000000").for(:cc_number) }
152
+ it { should_not allow_value("62292500000000000000").for(:cc_number) }
153
+ it { should_not allow_value("6229 2500.0000-000").for(:cc_number) }
154
+ it { should_not allow_value("6229 2500.0000-00000000").for(:cc_number) }
155
+ it { should_not allow_value("400000000000000").for(:cc_number) }
156
+ it { should_not allow_value("40000000000000000").for(:cc_number) }
157
+ it { should_not allow_value("4000 0000.0000-000").for(:cc_number) }
158
+ it { should_not allow_value("4000 0000.0000-00000").for(:cc_number) }
159
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
160
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
161
+
162
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
163
+ it { should_not ensure_valid_credit_card_format_of(:name) }
164
+ end
165
+
166
+ context "with card: :american_express option has a valid value" do
167
+ let(:klass) do
168
+ Class.new do
169
+ include ActiveModel::Validations
170
+ attr_accessor :cc_number, :name
171
+ validates :cc_number, credit_card: { card: :american_express }
172
+ end
173
+ end
174
+
175
+ subject { klass.new }
176
+
177
+ it { should allow_value("340000000000000").for(:cc_number) }
178
+ it { should allow_value("370000000000000").for(:cc_number) }
179
+ it { should allow_value("3700 0000.0000-000").for(:cc_number) }
180
+
181
+ it { should_not allow_value('').for(:cc_number) }
182
+ it { should_not allow_value(' ').for(:cc_number) }
183
+ it { should_not allow_value(nil).for(:cc_number) }
184
+ it { should_not allow_value("#").for(:cc_number) }
185
+ it { should_not allow_value("9").for(:cc_number) }
186
+ it { should_not allow_value("a").for(:cc_number) }
187
+ it { should_not allow_value("270000000000000").for(:cc_number) }
188
+ it { should_not allow_value("37000000000000").for(:cc_number) }
189
+ it { should_not allow_value("3700000000000000").for(:cc_number) }
190
+ it { should_not allow_value("2700 0000.0000-000").for(:cc_number) }
191
+ it { should_not allow_value("3700 0000.0000-00").for(:cc_number) }
192
+ it { should_not allow_value("3700 0000.0000-0000").for(:cc_number) }
193
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
194
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
195
+
196
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
197
+ it { should_not ensure_valid_credit_card_format_of(:name) }
198
+ end
199
+
200
+ context "with card: :diners_club option has a valid value" do
201
+ let(:klass) do
202
+ Class.new do
203
+ include ActiveModel::Validations
204
+ attr_accessor :cc_number, :name
205
+ validates :cc_number, credit_card: { card: :diners_club }
206
+ end
207
+ end
208
+
209
+ subject { klass.new }
210
+
211
+ it { should allow_value("30000000000000").for(:cc_number) }
212
+ it { should allow_value("30100000000000").for(:cc_number) }
213
+ it { should allow_value("30200000000000").for(:cc_number) }
214
+ it { should allow_value("30300000000000").for(:cc_number) }
215
+ it { should allow_value("30400000000000").for(:cc_number) }
216
+ it { should allow_value("30500000000000").for(:cc_number) }
217
+ it { should allow_value("36000000000000").for(:cc_number) }
218
+ it { should allow_value("54000000000000").for(:cc_number) }
219
+ it { should allow_value("55000000000000").for(:cc_number) }
220
+ it { should allow_value("5500000000000000").for(:cc_number) }
221
+ it { should allow_value("5500 0000.0000-00").for(:cc_number) }
222
+ it { should allow_value("5500 0000.0000-0000").for(:cc_number) }
223
+
224
+ it { should_not allow_value('').for(:cc_number) }
225
+ it { should_not allow_value(' ').for(:cc_number) }
226
+ it { should_not allow_value(nil).for(:cc_number) }
227
+ it { should_not allow_value("#").for(:cc_number) }
228
+ it { should_not allow_value("9").for(:cc_number) }
229
+ it { should_not allow_value("a").for(:cc_number) }
230
+ it { should_not allow_value("4500000000000000").for(:cc_number) }
231
+ it { should_not allow_value("5500000000000").for(:cc_number) }
232
+ it { should_not allow_value("55000000000000000").for(:cc_number) }
233
+ it { should_not allow_value("4500 0000.0000-0000").for(:cc_number) }
234
+ it { should_not allow_value("5500 0000.0000-0").for(:cc_number) }
235
+ it { should_not allow_value("5500 0000.0000-00000").for(:cc_number) }
236
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
237
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
238
+
239
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
240
+ it { should_not ensure_valid_credit_card_format_of(:name) }
241
+ end
242
+
243
+ context "with card: :discover option has a valid value" do
244
+ let(:klass) do
245
+ Class.new do
246
+ include ActiveModel::Validations
247
+ attr_accessor :cc_number, :name
248
+ validates :cc_number, credit_card: { card: :discover }
249
+ end
250
+ end
251
+
252
+ subject { klass.new }
253
+
254
+ it { should allow_value("6011000000000000").for(:cc_number) }
255
+ it { should allow_value("6221260000000000").for(:cc_number) }
256
+ it { should allow_value("6221270000000000").for(:cc_number) }
257
+ it { should allow_value("6221280000000000").for(:cc_number) }
258
+ it { should allow_value("6221290000000000").for(:cc_number) }
259
+ it { should allow_value("6221300000000000").for(:cc_number) }
260
+ it { should allow_value("6221400000000000").for(:cc_number) }
261
+ it { should allow_value("6221500000000000").for(:cc_number) }
262
+ it { should allow_value("6221600000000000").for(:cc_number) }
263
+ it { should allow_value("6221700000000000").for(:cc_number) }
264
+ it { should allow_value("6221800000000000").for(:cc_number) }
265
+ it { should allow_value("6221900000000000").for(:cc_number) }
266
+ it { should allow_value("6222000000000000").for(:cc_number) }
267
+ it { should allow_value("6223000000000000").for(:cc_number) }
268
+ it { should allow_value("6224000000000000").for(:cc_number) }
269
+ it { should allow_value("6225000000000000").for(:cc_number) }
270
+ it { should allow_value("6226000000000000").for(:cc_number) }
271
+ it { should allow_value("6227000000000000").for(:cc_number) }
272
+ it { should allow_value("6228000000000000").for(:cc_number) }
273
+ it { should allow_value("6229000000000000").for(:cc_number) }
274
+ it { should allow_value("6229100000000000").for(:cc_number) }
275
+ it { should allow_value("6229200000000000").for(:cc_number) }
276
+ it { should allow_value("6229210000000000").for(:cc_number) }
277
+ it { should allow_value("6229220000000000").for(:cc_number) }
278
+ it { should allow_value("6229230000000000").for(:cc_number) }
279
+ it { should allow_value("6229240000000000").for(:cc_number) }
280
+ it { should allow_value("6229250000000000").for(:cc_number) }
281
+ it { should allow_value("6440000000000000").for(:cc_number) }
282
+ it { should allow_value("6450000000000000").for(:cc_number) }
283
+ it { should allow_value("6460000000000000").for(:cc_number) }
284
+ it { should allow_value("6470000000000000").for(:cc_number) }
285
+ it { should allow_value("6480000000000000").for(:cc_number) }
286
+ it { should allow_value("6490000000000000").for(:cc_number) }
287
+ it { should allow_value("6500000000000000").for(:cc_number) }
288
+ it { should allow_value("6500 0000.0000-0000").for(:cc_number) }
289
+
290
+ it { should_not allow_value('').for(:cc_number) }
291
+ it { should_not allow_value(' ').for(:cc_number) }
292
+ it { should_not allow_value(nil).for(:cc_number) }
293
+ it { should_not allow_value("#").for(:cc_number) }
294
+ it { should_not allow_value("9").for(:cc_number) }
295
+ it { should_not allow_value("a").for(:cc_number) }
296
+ it { should_not allow_value("5500000000000000").for(:cc_number) }
297
+ it { should_not allow_value("650000000000000").for(:cc_number) }
298
+ it { should_not allow_value("65000000000000000").for(:cc_number) }
299
+ it { should_not allow_value("5500 0000.0000-0000").for(:cc_number) }
300
+ it { should_not allow_value("6500 0000.0000-000").for(:cc_number) }
301
+ it { should_not allow_value("6500 0000.0000-00000").for(:cc_number) }
302
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
303
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
304
+
305
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
306
+ it { should_not ensure_valid_credit_card_format_of(:name) }
307
+ end
308
+
309
+ context "with card: :jcb option has a valid value" do
310
+ let(:klass) do
311
+ Class.new do
312
+ include ActiveModel::Validations
313
+ attr_accessor :cc_number, :name
314
+ validates :cc_number, credit_card: { card: :jcb }
315
+ end
316
+ end
317
+
318
+ subject { klass.new }
319
+
320
+ it { should allow_value("3528000000000000").for(:cc_number) }
321
+ it { should allow_value("3529000000000000").for(:cc_number) }
322
+ it { should allow_value("3530000000000000").for(:cc_number) }
323
+ it { should allow_value("3540000000000000").for(:cc_number) }
324
+ it { should allow_value("3550000000000000").for(:cc_number) }
325
+ it { should allow_value("3560000000000000").for(:cc_number) }
326
+ it { should allow_value("3570000000000000").for(:cc_number) }
327
+ it { should allow_value("3580000000000000").for(:cc_number) }
328
+ it { should allow_value("3580 0000.0000-0000").for(:cc_number) }
329
+
330
+ it { should_not allow_value('').for(:cc_number) }
331
+ it { should_not allow_value(' ').for(:cc_number) }
332
+ it { should_not allow_value(nil).for(:cc_number) }
333
+ it { should_not allow_value("#").for(:cc_number) }
334
+ it { should_not allow_value("9").for(:cc_number) }
335
+ it { should_not allow_value("a").for(:cc_number) }
336
+ it { should_not allow_value("2580000000000000").for(:cc_number) }
337
+ it { should_not allow_value("358000000000000").for(:cc_number) }
338
+ it { should_not allow_value("35800000000000000").for(:cc_number) }
339
+ it { should_not allow_value("2580 0000.0000-0000").for(:cc_number) }
340
+ it { should_not allow_value("3580 0000.0000-000").for(:cc_number) }
341
+ it { should_not allow_value("3580 0000.0000-00000").for(:cc_number) }
342
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
343
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
344
+
345
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
346
+ it { should_not ensure_valid_credit_card_format_of(:name) }
347
+ end
348
+
349
+ context "with card: :laser option has a valid value" do
350
+ let(:klass) do
351
+ Class.new do
352
+ include ActiveModel::Validations
353
+ attr_accessor :cc_number, :name
354
+ validates :cc_number, credit_card: { card: :laser }
355
+ end
356
+ end
357
+
358
+ subject { klass.new }
359
+
360
+ it { should allow_value("6304000000000000").for(:cc_number) }
361
+ it { should allow_value("6706000000000000").for(:cc_number) }
362
+ it { should allow_value("6771000000000000").for(:cc_number) }
363
+ it { should allow_value("6709000000000000").for(:cc_number) }
364
+ it { should allow_value("67090000000000000").for(:cc_number) }
365
+ it { should allow_value("670900000000000000").for(:cc_number) }
366
+ it { should allow_value("6709000000000000000").for(:cc_number) }
367
+ it { should allow_value("6709 0000.0000-0000").for(:cc_number) }
368
+ it { should allow_value("6709 0000.0000-00000").for(:cc_number) }
369
+ it { should allow_value("6709 0000.0000-000000").for(:cc_number) }
370
+ it { should allow_value("6709 0000.0000-0000000").for(:cc_number) }
371
+
372
+ it { should_not allow_value('').for(:cc_number) }
373
+ it { should_not allow_value(' ').for(:cc_number) }
374
+ it { should_not allow_value(nil).for(:cc_number) }
375
+ it { should_not allow_value("#").for(:cc_number) }
376
+ it { should_not allow_value("9").for(:cc_number) }
377
+ it { should_not allow_value("a").for(:cc_number) }
378
+ it { should_not allow_value("5709000000000000").for(:cc_number) }
379
+ it { should_not allow_value("670900000000000").for(:cc_number) }
380
+ it { should_not allow_value("67090000000000000000").for(:cc_number) }
381
+ it { should_not allow_value("5709 0000.0000-0000").for(:cc_number) }
382
+ it { should_not allow_value("6709 0000.0000-000").for(:cc_number) }
383
+ it { should_not allow_value("6709 0000.0000-00000000").for(:cc_number) }
384
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
385
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
386
+
387
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
388
+ it { should_not ensure_valid_credit_card_format_of(:name) }
389
+ end
390
+
391
+ context "with card: :maestro option has a valid value" do
392
+ let(:klass) do
393
+ Class.new do
394
+ include ActiveModel::Validations
395
+ attr_accessor :cc_number, :name
396
+ validates :cc_number, credit_card: { card: :maestro }
397
+ end
398
+ end
399
+
400
+ subject { klass.new }
401
+
402
+ it { should allow_value("501800000000").for(:cc_number) }
403
+ it { should allow_value("502000000000").for(:cc_number) }
404
+ it { should allow_value("503800000000").for(:cc_number) }
405
+ it { should allow_value("630400000000").for(:cc_number) }
406
+ it { should allow_value("675900000000").for(:cc_number) }
407
+ it { should allow_value("676100000000").for(:cc_number) }
408
+ it { should allow_value("676200000000").for(:cc_number) }
409
+ it { should allow_value("676300000000").for(:cc_number) }
410
+ it { should allow_value("676400000000").for(:cc_number) }
411
+ it { should allow_value("676500000000").for(:cc_number) }
412
+ it { should allow_value("676600000000").for(:cc_number) }
413
+ it { should allow_value("6766000000000").for(:cc_number) }
414
+ it { should allow_value("67660000000000").for(:cc_number) }
415
+ it { should allow_value("676600000000000").for(:cc_number) }
416
+ it { should allow_value("6766000000000000").for(:cc_number) }
417
+ it { should allow_value("67660000000000000").for(:cc_number) }
418
+ it { should allow_value("676600000000000000").for(:cc_number) }
419
+ it { should allow_value("6766000000000000000").for(:cc_number) }
420
+ it { should allow_value("6766 0000.0000").for(:cc_number) }
421
+ it { should allow_value("6766 0000.0000-0").for(:cc_number) }
422
+ it { should allow_value("6766 0000.0000-00").for(:cc_number) }
423
+ it { should allow_value("6766 0000.0000-000").for(:cc_number) }
424
+ it { should allow_value("6766 0000.0000-0000").for(:cc_number) }
425
+ it { should allow_value("6766 0000.0000-00000").for(:cc_number) }
426
+ it { should allow_value("6766 0000.0000-000000").for(:cc_number) }
427
+ it { should allow_value("6766 0000.0000-0000000").for(:cc_number) }
428
+
429
+ it { should_not allow_value('').for(:cc_number) }
430
+ it { should_not allow_value(' ').for(:cc_number) }
431
+ it { should_not allow_value(nil).for(:cc_number) }
432
+ it { should_not allow_value("#").for(:cc_number) }
433
+ it { should_not allow_value("9").for(:cc_number) }
434
+ it { should_not allow_value("a").for(:cc_number) }
435
+ it { should_not allow_value("576600000000").for(:cc_number) }
436
+ it { should_not allow_value("67660000000").for(:cc_number) }
437
+ it { should_not allow_value("67660000000000000000").for(:cc_number) }
438
+ it { should_not allow_value("5766 0000.0000").for(:cc_number) }
439
+ it { should_not allow_value("6766 0000.000").for(:cc_number) }
440
+ it { should_not allow_value("6766 0000.0000-00000000").for(:cc_number) }
441
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
442
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
443
+
444
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
445
+ it { should_not ensure_valid_credit_card_format_of(:name) }
446
+ end
447
+
448
+ context "with card: :mastercard option has a valid value" do
449
+ let(:klass) do
450
+ Class.new do
451
+ include ActiveModel::Validations
452
+ attr_accessor :cc_number, :name
453
+ validates :cc_number, credit_card: { card: :mastercard }
454
+ end
455
+ end
456
+
457
+ subject { klass.new }
458
+
459
+ it { should allow_value("5100000000000000").for(:cc_number) }
460
+ it { should allow_value("5200000000000000").for(:cc_number) }
461
+ it { should allow_value("5300000000000000").for(:cc_number) }
462
+ it { should allow_value("5400000000000000").for(:cc_number) }
463
+ it { should allow_value("5500000000000000").for(:cc_number) }
464
+ it { should allow_value("5500 0000.0000-0000").for(:cc_number) }
465
+
466
+ it { should_not allow_value('').for(:cc_number) }
467
+ it { should_not allow_value(' ').for(:cc_number) }
468
+ it { should_not allow_value(nil).for(:cc_number) }
469
+ it { should_not allow_value("#").for(:cc_number) }
470
+ it { should_not allow_value("9").for(:cc_number) }
471
+ it { should_not allow_value("a").for(:cc_number) }
472
+ it { should_not allow_value("4500000000000000").for(:cc_number) }
473
+ it { should_not allow_value("550000000000000").for(:cc_number) }
474
+ it { should_not allow_value("55000000000000000").for(:cc_number) }
475
+ it { should_not allow_value("4500 0000.0000-0000").for(:cc_number) }
476
+ it { should_not allow_value("5500 0000.0000-00000").for(:cc_number) }
477
+ it { should_not allow_value("5500 0000.0000-000").for(:cc_number) }
478
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
479
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
480
+
481
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
482
+ it { should_not ensure_valid_credit_card_format_of(:name) }
483
+ end
484
+
485
+ context "with card: :solo option has a valid value" do
486
+ let(:klass) do
487
+ Class.new do
488
+ include ActiveModel::Validations
489
+ attr_accessor :cc_number, :name
490
+ validates :cc_number, credit_card: { card: :solo }
491
+ end
492
+ end
493
+
494
+ subject { klass.new }
495
+
496
+ it { should allow_value("6334000000000000").for(:cc_number) }
497
+ it { should allow_value("6767000000000000").for(:cc_number) }
498
+ it { should allow_value("676700000000000000").for(:cc_number) }
499
+ it { should allow_value("6767000000000000000").for(:cc_number) }
500
+ it { should allow_value("6767 0000.0000-0000").for(:cc_number) }
501
+ it { should allow_value("6767 0000.0000-000000").for(:cc_number) }
502
+ it { should allow_value("6767 0000.0000-0000000").for(:cc_number) }
503
+
504
+ it { should_not allow_value('').for(:cc_number) }
505
+ it { should_not allow_value(' ').for(:cc_number) }
506
+ it { should_not allow_value(nil).for(:cc_number) }
507
+ it { should_not allow_value("#").for(:cc_number) }
508
+ it { should_not allow_value("9").for(:cc_number) }
509
+ it { should_not allow_value("a").for(:cc_number) }
510
+ it { should_not allow_value("5767000000000000").for(:cc_number) }
511
+ it { should_not allow_value("676700000000000").for(:cc_number) }
512
+ it { should_not allow_value("67670000000000000").for(:cc_number) }
513
+ it { should_not allow_value("67670000000000000000").for(:cc_number) }
514
+ it { should_not allow_value("5767 0000.0000-0000").for(:cc_number) }
515
+ it { should_not allow_value("6767 0000.0000-000").for(:cc_number) }
516
+ it { should_not allow_value("6767 0000.0000-00000").for(:cc_number) }
517
+ it { should_not allow_value("6767 0000.0000-00000000").for(:cc_number) }
518
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
519
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
520
+
521
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
522
+ it { should_not ensure_valid_credit_card_format_of(:name) }
523
+ end
524
+
525
+ context "with card: :unionpay option has a valid value" do
526
+ let(:klass) do
527
+ Class.new do
528
+ include ActiveModel::Validations
529
+ attr_accessor :cc_number, :name
530
+ validates :cc_number, credit_card: { card: :unionpay }
531
+ end
532
+ end
533
+
534
+ subject { klass.new }
535
+
536
+ it { should allow_value("6221260000000000").for(:cc_number) }
537
+ it { should allow_value("6221270000000000").for(:cc_number) }
538
+ it { should allow_value("6221280000000000").for(:cc_number) }
539
+ it { should allow_value("6221300000000000").for(:cc_number) }
540
+ it { should allow_value("6221400000000000").for(:cc_number) }
541
+ it { should allow_value("6221500000000000").for(:cc_number) }
542
+ it { should allow_value("6221600000000000").for(:cc_number) }
543
+ it { should allow_value("6221700000000000").for(:cc_number) }
544
+ it { should allow_value("6221800000000000").for(:cc_number) }
545
+ it { should allow_value("6221900000000000").for(:cc_number) }
546
+ it { should allow_value("6222000000000000").for(:cc_number) }
547
+ it { should allow_value("6223000000000000").for(:cc_number) }
548
+ it { should allow_value("6224000000000000").for(:cc_number) }
549
+ it { should allow_value("6225000000000000").for(:cc_number) }
550
+ it { should allow_value("6226000000000000").for(:cc_number) }
551
+ it { should allow_value("6227000000000000").for(:cc_number) }
552
+ it { should allow_value("6228000000000000").for(:cc_number) }
553
+ it { should allow_value("6229000000000000").for(:cc_number) }
554
+ it { should allow_value("6229100000000000").for(:cc_number) }
555
+ it { should allow_value("6229200000000000").for(:cc_number) }
556
+ it { should allow_value("6229210000000000").for(:cc_number) }
557
+ it { should allow_value("6229220000000000").for(:cc_number) }
558
+ it { should allow_value("6229230000000000").for(:cc_number) }
559
+ it { should allow_value("6229240000000000").for(:cc_number) }
560
+ it { should allow_value("6229250000000000").for(:cc_number) }
561
+ it { should allow_value("62292500000000000").for(:cc_number) }
562
+ it { should allow_value("622925000000000000").for(:cc_number) }
563
+ it { should allow_value("6229250000000000000").for(:cc_number) }
564
+ it { should allow_value("6229 2500.0000-0000").for(:cc_number) }
565
+ it { should allow_value("6229 2500.0000-00000").for(:cc_number) }
566
+ it { should allow_value("6229 2500.0000-000000").for(:cc_number) }
567
+ it { should allow_value("6229 2500.0000-0000000").for(:cc_number) }
568
+
569
+ it { should_not allow_value('').for(:cc_number) }
570
+ it { should_not allow_value(' ').for(:cc_number) }
571
+ it { should_not allow_value(nil).for(:cc_number) }
572
+ it { should_not allow_value("#").for(:cc_number) }
573
+ it { should_not allow_value("9").for(:cc_number) }
574
+ it { should_not allow_value("a").for(:cc_number) }
575
+ it { should_not allow_value("5229250000000000").for(:cc_number) }
576
+ it { should_not allow_value("622925000000000").for(:cc_number) }
577
+ it { should_not allow_value("62292500000000000000").for(:cc_number) }
578
+ it { should_not allow_value("5229 2500.0000-0000").for(:cc_number) }
579
+ it { should_not allow_value("6229 2500.0000-000").for(:cc_number) }
580
+ it { should_not allow_value("6229 2500.0000-00000000").for(:cc_number) }
581
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
582
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
583
+
584
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
585
+ it { should_not ensure_valid_credit_card_format_of(:name) }
586
+ end
587
+
588
+ context "with card: :visa option has a valid value" do
589
+ let(:klass) do
590
+ Class.new do
591
+ include ActiveModel::Validations
592
+ attr_accessor :cc_number, :name
593
+ validates :cc_number, credit_card: { card: :visa }
594
+ end
595
+ end
596
+
597
+ subject { klass.new }
598
+
599
+ it { should allow_value("4000000000000000").for(:cc_number) }
600
+ it { should allow_value("4000 0000.0000-0000").for(:cc_number) }
601
+
602
+ it { should_not allow_value('').for(:cc_number) }
603
+ it { should_not allow_value(' ').for(:cc_number) }
604
+ it { should_not allow_value(nil).for(:cc_number) }
605
+ it { should_not allow_value("#").for(:cc_number) }
606
+ it { should_not allow_value("9").for(:cc_number) }
607
+ it { should_not allow_value("a").for(:cc_number) }
608
+ it { should_not allow_value("3000000000000000").for(:cc_number) }
609
+ it { should_not allow_value("400000000000000").for(:cc_number) }
610
+ it { should_not allow_value("40000000000000000").for(:cc_number) }
611
+ it { should_not allow_value("3000 0000.0000-0000").for(:cc_number) }
612
+ it { should_not allow_value("4000 0000.0000-000").for(:cc_number) }
613
+ it { should_not allow_value("4000 0000.0000-00000").for(:cc_number) }
614
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
615
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
616
+
617
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
618
+ it { should_not ensure_valid_credit_card_format_of(:name) }
619
+ end
620
+
621
+ context "with :strict option has a valid value" do
622
+ let(:klass) do
623
+ Class.new do
624
+ include ActiveModel::Validations
625
+ attr_accessor :cc_number, :name
626
+ validates :cc_number, credit_card: { strict: true }
627
+ end
628
+ end
629
+
630
+ subject { klass.new }
631
+
632
+ it { should allow_value("4000000000000000").for(:cc_number) }
633
+
634
+ it { should_not allow_value('').for(:cc_number) }
635
+ it { should_not allow_value(' ').for(:cc_number) }
636
+ it { should_not allow_value(nil).for(:cc_number) }
637
+ it { should_not allow_value("#").for(:cc_number) }
638
+ it { should_not allow_value("9").for(:cc_number) }
639
+ it { should_not allow_value("a").for(:cc_number) }
640
+ it { should_not allow_value("400000000000000").for(:cc_number) }
641
+ it { should_not allow_value("40000000000000000").for(:cc_number) }
642
+ it { should_not allow_value("3000 0000.0000-00").for(:cc_number) }
643
+ it { should_not allow_value("4000 0000.0000-000").for(:cc_number) }
644
+ it { should_not allow_value("4000 0000.0000-0000").for(:cc_number) }
645
+ it { should_not allow_value("4000 0000.0000-00000").for(:cc_number) }
646
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
647
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
648
+
649
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
650
+ it { should_not ensure_valid_credit_card_format_of(:name) }
651
+ end
652
+
653
+ context "with card: :visa and :strict options has a valid value" do
654
+ let(:klass) do
655
+ Class.new do
656
+ include ActiveModel::Validations
657
+ attr_accessor :cc_number, :name
658
+ validates :cc_number, credit_card: { card: :visa, strict: true }
659
+ end
660
+ end
661
+
662
+ subject { klass.new }
663
+
664
+ it { should allow_value("4000000000000000").for(:cc_number) }
665
+
666
+ it { should_not allow_value('').for(:cc_number) }
667
+ it { should_not allow_value(' ').for(:cc_number) }
668
+ it { should_not allow_value(nil).for(:cc_number) }
669
+ it { should_not allow_value("#").for(:cc_number) }
670
+ it { should_not allow_value("9").for(:cc_number) }
671
+ it { should_not allow_value("a").for(:cc_number) }
672
+ it { should_not allow_value("3000000000000000").for(:cc_number) }
673
+ it { should_not allow_value("400000000000000").for(:cc_number) }
674
+ it { should_not allow_value("40000000000000000").for(:cc_number) }
675
+ it { should_not allow_value("3000 0000.0000-0000").for(:cc_number) }
676
+ it { should_not allow_value("4000 0000.0000-000").for(:cc_number) }
677
+ it { should_not allow_value("4000 0000.0000-0000").for(:cc_number) }
678
+ it { should_not allow_value("4000 0000.0000-00000").for(:cc_number) }
679
+ it { should_not allow_value("! \#$%\`|").for(:cc_number) }
680
+ it { should_not allow_value("<>@[]\`|").for(:cc_number) }
681
+
682
+ it { should ensure_valid_credit_card_format_of(:cc_number) }
683
+ it { should_not ensure_valid_credit_card_format_of(:name) }
684
+ end
685
+
686
+ end