formeze 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'formeze'
3
- s.version = '1.1.0'
3
+ s.version = '1.1.1'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ['Tim Craft']
6
6
  s.email = ['mail@timcraft.com']
@@ -19,17 +19,17 @@ module Formeze
19
19
  end
20
20
 
21
21
  def validate(value, &error)
22
- error.call(self, 'is required') if required? && value !~ /\S/
22
+ error.call(:'is required') if required? && value !~ /\S/
23
23
 
24
- error.call(self, 'has too many lines') if !multiline? && value.lines.count > 1
24
+ error.call(:'has too many lines') if !multiline? && value.lines.count > 1
25
25
 
26
- error.call(self, 'has too many characters') if value.chars.count > char_limit
26
+ error.call(:'has too many characters') if value.chars.count > char_limit
27
27
 
28
- error.call(self, 'has too many words') if word_limit? && value.scan(/\w+/).length > word_limit
28
+ error.call(:'has too many words') if word_limit? && value.scan(/\w+/).length > word_limit
29
29
 
30
- error.call(self, 'is invalid') if pattern? && value !~ pattern
30
+ error.call(:'is invalid') if pattern? && value !~ pattern
31
31
 
32
- error.call(self, 'is invalid') if values? && !values.include?(value)
32
+ error.call(:'is invalid') if values? && !values.include?(value)
33
33
  end
34
34
 
35
35
  def key
@@ -202,7 +202,7 @@ module Formeze
202
202
  unless form_data.has_key?(field.key)
203
203
  next if field.multiple? || !field.key_required?
204
204
 
205
- raise KeyError
205
+ raise KeyError, "missing form key: #{field.key}"
206
206
  end
207
207
 
208
208
  values = form_data.delete(field.key)
@@ -77,6 +77,14 @@ describe 'FormWithField after parsing blank input' do
77
77
  @form.valid?.must_equal(false)
78
78
  end
79
79
  end
80
+
81
+ describe 'errors method' do
82
+ it 'should return an array containing an error message' do
83
+ @form.errors.must_be_instance_of(Array)
84
+ @form.errors.length.must_equal(1)
85
+ @form.errors.first.to_s.must_equal('Title is required')
86
+ end
87
+ end
80
88
  end
81
89
 
82
90
  describe 'FormWithField after parsing input containing newlines' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formeze
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: