domain_model 0.2.0 → 0.2.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,3 +1,3 @@
1
1
  module DomainModel
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/domain_model.rb CHANGED
@@ -215,6 +215,10 @@ module DomainModel
215
215
  def fields
216
216
  @hash.keys
217
217
  end
218
+
219
+ def as_json(*)
220
+ @hash.clone
221
+ end
218
222
  end
219
223
 
220
224
  class FieldErrors
@@ -38,6 +38,20 @@ describe DomainModel do
38
38
  end
39
39
  end
40
40
 
41
+ describe "#errors" do
42
+ before { define { field :name, :required => true } }
43
+
44
+ it "has a resonable implementation of #as_json" do
45
+ errors = Client.new.errors
46
+ expect(errors.as_json).to eq({:name => ["cannot be nil"]})
47
+ end
48
+
49
+ it "has #as_json that is tolerant of parameters" do
50
+ expect { Client.new.errors.as_json("arbitrary", "params") }.not_to raise_error
51
+ end
52
+
53
+ end
54
+
41
55
  describe ".validate" do
42
56
  it "runs added validations each time #errors is called" do
43
57
  run_count = 0
@@ -366,7 +380,7 @@ describe DomainModel do
366
380
  end
367
381
  end
368
382
 
369
- describe ".flat_errors" do
383
+ describe "#flat_errors" do
370
384
  describe "associated DomainModels" do
371
385
  subject do
372
386
  name_class = Class.new do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domain_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-11 00:00:00.000000000 Z
12
+ date: 2015-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake