yukonisuru 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +14 -0
- data/.rspec +4 -0
- data/.travis.yml +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +1101 -0
- data/Rakefile +1 -0
- data/config/locales/en.yml +113 -0
- data/lib/yukonisuru.rb +93 -0
- data/lib/yukonisuru/matchers/ensure_valid_alpha_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_alpha_numeric_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_base64_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_boolean_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_credit_card_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_currency_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_cusip_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_email_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_equality_matcher_of.rb +40 -0
- data/lib/yukonisuru/matchers/ensure_valid_gtin_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_hex_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_imei_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_ip_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_isbn_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_isin_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_latitude_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_longitude_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_mac_address_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_name_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_password_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_phone_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_sedol_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_slug_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_ssn_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_url_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_username_format_of.rb +26 -0
- data/lib/yukonisuru/matchers/ensure_valid_uuid_format_of.rb +26 -0
- data/lib/yukonisuru/validators/alpha_numeric_validator.rb +31 -0
- data/lib/yukonisuru/validators/alpha_validator.rb +31 -0
- data/lib/yukonisuru/validators/base64_validator.rb +9 -0
- data/lib/yukonisuru/validators/boolean_validator.rb +9 -0
- data/lib/yukonisuru/validators/credit_card_validator.rb +133 -0
- data/lib/yukonisuru/validators/currency_validator.rb +23 -0
- data/lib/yukonisuru/validators/cusip_validator.rb +33 -0
- data/lib/yukonisuru/validators/email_validator.rb +25 -0
- data/lib/yukonisuru/validators/equality_validator.rb +27 -0
- data/lib/yukonisuru/validators/gtin_validator.rb +59 -0
- data/lib/yukonisuru/validators/hex_validator.rb +9 -0
- data/lib/yukonisuru/validators/imei_validator.rb +37 -0
- data/lib/yukonisuru/validators/ip_validator.rb +9 -0
- data/lib/yukonisuru/validators/isbn_validator.rb +24 -0
- data/lib/yukonisuru/validators/isin_validator.rb +38 -0
- data/lib/yukonisuru/validators/latitude_validator.rb +9 -0
- data/lib/yukonisuru/validators/longitude_validator.rb +9 -0
- data/lib/yukonisuru/validators/mac_address_validator.rb +24 -0
- data/lib/yukonisuru/validators/name_validator.rb +9 -0
- data/lib/yukonisuru/validators/password_validator.rb +23 -0
- data/lib/yukonisuru/validators/phone_validator.rb +9 -0
- data/lib/yukonisuru/validators/sedol_validator.rb +32 -0
- data/lib/yukonisuru/validators/slug_validator.rb +9 -0
- data/lib/yukonisuru/validators/ssn_validator.rb +9 -0
- data/lib/yukonisuru/validators/url_validator.rb +36 -0
- data/lib/yukonisuru/validators/username_validator.rb +9 -0
- data/lib/yukonisuru/validators/uuid_validator.rb +28 -0
- data/lib/yukonisuru/version.rb +3 -0
- data/spec/lib/alpha_numeric_validator_spec.rb +91 -0
- data/spec/lib/alpha_validator_spec.rb +182 -0
- data/spec/lib/base64_validator_spec.rb +33 -0
- data/spec/lib/boolean_validator_spec.rb +35 -0
- data/spec/lib/credit_card_validator_spec.rb +686 -0
- data/spec/lib/currency_validator_spec.rb +63 -0
- data/spec/lib/cusip_validator_spec.rb +27 -0
- data/spec/lib/email_validator_spec.rb +109 -0
- data/spec/lib/equality_validator_spec.rb +334 -0
- data/spec/lib/gtin_validator_spec.rb +101 -0
- data/spec/lib/hex_validator_spec.rb +73 -0
- data/spec/lib/imei_validator_spec.rb +41 -0
- data/spec/lib/ip_validator_spec.rb +33 -0
- data/spec/lib/isbn_validator_spec.rb +41 -0
- data/spec/lib/isin_validator_spec.rb +35 -0
- data/spec/lib/latitude_validator_spec.rb +31 -0
- data/spec/lib/longitude_validator_spec.rb +31 -0
- data/spec/lib/mac_address_validator_spec.rb +54 -0
- data/spec/lib/name_validator_spec.rb +39 -0
- data/spec/lib/password_validator_spec.rb +87 -0
- data/spec/lib/phone_validator_spec.rb +42 -0
- data/spec/lib/sedol_validator_spec.rb +31 -0
- data/spec/lib/slug_validator_spec.rb +41 -0
- data/spec/lib/ssn_validator_spec.rb +36 -0
- data/spec/lib/url_validator_spec.rb +109 -0
- data/spec/lib/username_validator_spec.rb +37 -0
- data/spec/lib/uuid_validator_spec.rb +157 -0
- data/spec/spec_helper.rb +12 -0
- data/yukonisuru.gemspec +29 -0
- metadata +264 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_gtin_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "1234")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.gtin'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_gtin_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_gtin_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_hex_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "#9999999")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.hex'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_hex_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_hex_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_imei_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "invalid.imei")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.imei'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_imei_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_imei_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_ip_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", ".")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.ip'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_ip_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_ip_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_isbn_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "12345")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.isbn'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_isbn_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_isbn_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_isin_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "1234")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.isin'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_isin_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_isin_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_latitude_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", 91)
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.latitude'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_latitude_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_latitude_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_longitude_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", 181)
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.longitude'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_longitude_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_longitude_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_mac_address_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "invalid.mac.address")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.mac_address'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_mac_address_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_mac_address_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_name_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "Jame$ Ear1 Jones")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.name'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_name_format_of.failure_message_for_should',
|
14
|
+
attribute: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_name_format_of.failure_message_for_should_not',
|
22
|
+
attribute: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_password_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "pass word")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.password'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_password_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_password_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_phone_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "555-123n")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.phone'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_phone_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_phone_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_sedol_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "1234")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.sedol'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_sedol_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_sedol_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_slug_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "sl ug")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.slug'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_slug_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_slug_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_ssn_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "555-0s-1234")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.ssn'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_ssn_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_ssn_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_url_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", ".")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.url'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_url_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_url_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_username_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "user name")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('yukonisuru.errors.messages.username'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'yukonisuru.matchers.ensure_valid_username_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'yukonisuru.matchers.ensure_valid_username_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|