bookland 3.2.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b5ae359f32e9fe781b86320bcf0b7a7b095caa4
4
- data.tar.gz: 80143d0efdb7a3b958ab4e5fddefb93579d3b9da
3
+ metadata.gz: 6fb91e00c5bb23802dd09d5e3e0b5413d3b22135
4
+ data.tar.gz: c17a294ae6804e1a7a91130753fa4e03128e3f6c
5
5
  SHA512:
6
- metadata.gz: 772184fabb0aef7f79fa41a7dfaa9abfac58c27bb85dd518f2282ef64b3cfeb7db0e132fb4291391ef47d4d08cf5f0bea78daa757e3cd9e6bb3d118b2e5916a9
7
- data.tar.gz: 2da6323dc8a21306674b50199d653be13bd71f89dc725ccc4b38a9af198b5e67b5cfcb962bc3121a9810984718037274a5d855080068754a9c85d9f4f7b1e903
6
+ metadata.gz: aa0aa72c2402d39ff0ff1c75f15ab3d5d955e1666f150c2f897fb933d13d3437a50dab2ac1f12f648e420135b98a58737954198fac9a373e42671ea4fa55aaef
7
+ data.tar.gz: 508d0a310a0948b54fda5025d195ca287db5661414ba7fccff29cc0fe93356258723894c151f58ccb12f2e047f392f52e02eeeba68398ff5cea59600dd07041f
@@ -5,10 +5,11 @@
5
5
  return if value.nil? && options[:allow_nil]
6
6
 
7
7
  unless Bookland::#{klass}.valid?(value)
8
+ message = "is not an #{klass}"
8
9
  if options[:strict]
9
- raise ActiveModel::StrictValidationFailed, "\#{value} \#{options[:message] || "is not an #{klass}"}"
10
+ raise ActiveModel::StrictValidationFailed, "\#{value} \#{message}"
10
11
  else
11
- record.errors[attribute] << (options[:message] || 'is not an #{klass}')
12
+ record.errors[attribute] << message
12
13
  end
13
14
  end
14
15
  end
@@ -1,3 +1,3 @@
1
1
  module Bookland
2
- VERSION = '3.2.0'
2
+ VERSION = '3.2.1'
3
3
  end
@@ -27,6 +27,13 @@ class TestValidators < MiniTest::Unit::TestCase
27
27
  assert instance.valid?
28
28
  end
29
29
 
30
+ def test_validates_asin_with_message
31
+ @klass.validates(:attribute, asin: true)#, { message: 'is bad' })
32
+ instance = @klass.new(attribute: '123')
33
+ instance.valid?
34
+ assert_includes instance.errors.first, 'is not an ASIN'
35
+ end
36
+
30
37
  def test_validates_asin_strictly
31
38
  @klass.validates!(:attribute, asin: true)
32
39
  instance = @klass.new(attribute: '0262011530')
@@ -52,6 +59,13 @@ class TestValidators < MiniTest::Unit::TestCase
52
59
  assert instance.valid?
53
60
  end
54
61
 
62
+ def test_validates_ean_with_message
63
+ @klass.validates(:attribute, ean: true)#, { message: 'is bad' })
64
+ instance = @klass.new(attribute: '123')
65
+ instance.valid?
66
+ assert_includes instance.errors.first, 'is not an EAN'
67
+ end
68
+
55
69
  def test_validates_ean_strictly
56
70
  @klass.validates!(:attribute, ean: true)
57
71
  instance = @klass.new(attribute: '0814916013890')
@@ -76,6 +90,13 @@ class TestValidators < MiniTest::Unit::TestCase
76
90
  assert instance.valid?
77
91
  end
78
92
 
93
+ def test_validates_isbn_with_message
94
+ @klass.validates(:attribute, isbn: true)#, { message: 'is bad' })
95
+ instance = @klass.new(attribute: '123')
96
+ instance.valid?
97
+ assert_includes instance.errors.first, 'is not an ISBN'
98
+ end
99
+
79
100
  def test_validates_isbn_strictly
80
101
  @klass.validates!(:attribute, isbn: true)
81
102
  instance = @klass.new(attribute: '9780262011532')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookland
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari