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,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