valuedate 0.0.4 → 0.0.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/lib/valuedate.rb CHANGED
@@ -51,7 +51,7 @@ class Valuedate
51
51
  valid? do |value|
52
52
  value ||= {}
53
53
  schema.all? do |(key, validator)|
54
- validator.call(value[key]) || collect_errors!(validator, :key => key)
54
+ validator.call(value[key]) || collect_errors!(validator, key)
55
55
  end
56
56
  end
57
57
  end
@@ -74,10 +74,10 @@ class Valuedate
74
74
  self
75
75
  end
76
76
 
77
- def collect_errors!(validator, options = {})
77
+ def collect_errors!(validator, key=nil)
78
78
  case validator
79
79
  when Valuedate
80
- @errors.concat(validator.errors.map { |error| error.options.update(options); error })
80
+ @errors.concat(validator.errors.map { |error| error.options[:key] ||= key; error })
81
81
  end
82
82
  false
83
83
  end
@@ -196,6 +196,7 @@ context "Valuedate" do
196
196
  asserts("invalid array size") { !v([1,2]) { value.not { |value| value.size == 2 } } }
197
197
  end
198
198
 
199
+ # TODO refactor!
199
200
  context "errors" do
200
201
  setup do
201
202
  Valuedate.schema {}
@@ -220,12 +221,7 @@ context "Valuedate" do
220
221
  end
221
222
 
222
223
  asserts("fails") { !topic.validate({}) }
223
- asserts_validation_error(:key => :key1, :matcher => :is_a) { topic.validate!({}) }
224
- asserts_validation_error(:key => :key1, :matcher => :is_a) { topic.validate!(:key1 => 23) }
225
- asserts_validation_error(:key => :key1, :matcher => :equals) { topic.validate!(:key1 => "value") }
226
- asserts_validation_error(:key => :key2, :matcher => :is_a) { topic.validate!(:key1 => "key") }
227
- asserts_validation_error(:key => :key2, :matcher => :is_a) { topic.validate!(:key1 => "key", :key2 => {}) }
228
- asserts_validation_error(:key => :key2, :matcher => :is_a) { topic.validate!(:key1 => "key", :key2 => {:key3 => 0.0}) }
224
+ asserts_validation_error(:key => :key3, :matcher => :is_a) { topic.validate!(:key1 => "key", :key2 => {:key3 => 0.0}) }
229
225
  asserts("passes") { topic.validate(:key1 => "key", :key2 => {:key3 => 23}) }
230
226
  end
231
227
  end
data/test.watchr CHANGED
@@ -17,4 +17,5 @@ watch('test/helper.rb') { run_tests }
17
17
  watch('VERSION') do
18
18
  puts "Building gem"
19
19
  system "rake build"
20
+ system %{git commit -m "Spec" *.gemspec}
20
21
  end
data/valuedate.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{valuedate}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Peter Suschlik"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valuedate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Suschlik