File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
17
17
spec . test_files = spec . files . grep ( %r{^(test|spec|features)/} )
18
18
spec . require_paths = [ "lib" ]
19
19
20
- spec . add_dependency "activesupport"
21
- spec . add_dependency "activemodel"
20
+ spec . add_dependency "activesupport" , ">= 3.2"
21
+ spec . add_dependency "activemodel" , ">= 3.2"
22
22
spec . add_dependency "json-schema"
23
23
spec . add_dependency "json"
24
24
Original file line number Diff line number Diff line change 3
3
require 'json_validator'
4
4
5
5
class FakeActiveModel
6
- include ActiveModel ::Model
6
+ include ActiveModel ::Validations
7
7
8
8
attr_accessor :json_data
9
9
10
+ def initialize ( json_data )
11
+ self . json_data = json_data . to_hash
12
+ end
13
+
10
14
validates :json_data , json : {
11
15
allow_blank : true ,
12
16
schema : {
@@ -18,14 +22,14 @@ class FakeActiveModel
18
22
19
23
describe FakeActiveModel do
20
24
it 'sets validation errors using JsonValidator' do
21
- expect ( FakeActiveModel . new ( json_data : { hello : :world } ) ) . to_not be_valid
25
+ expect ( FakeActiveModel . new ( hello : :world ) ) . to_not be_valid
22
26
end
23
27
24
28
it 'does not set validation errors using JsonValidator when the json is valid' do
25
- expect ( FakeActiveModel . new ( json_data : { foo : :bar } ) ) . to be_valid
29
+ expect ( FakeActiveModel . new ( foo : :bar ) ) . to be_valid
26
30
end
27
31
28
32
it 'does not run JsonValidator when allow_blank is true and the json is an empty hash' do
29
- expect ( FakeActiveModel . new ( json_data : { } ) ) . to be_valid
33
+ expect ( FakeActiveModel . new ( { } ) ) . to be_valid
30
34
end
31
35
end
You can’t perform that action at this time.
0 commit comments