Skip to content

Commit 51f0f09

Browse files
committed
Made it possible to run the tests on rails 3.2
1 parent 5e7c8d5 commit 51f0f09

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

json_validator.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
1717
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
1818
spec.require_paths = ["lib"]
1919

20-
spec.add_dependency "activesupport"
21-
spec.add_dependency "activemodel"
20+
spec.add_dependency "activesupport", ">= 3.2"
21+
spec.add_dependency "activemodel", ">= 3.2"
2222
spec.add_dependency "json-schema"
2323
spec.add_dependency "json"
2424

spec/integration/active_model_spec.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
require 'json_validator'
44

55
class FakeActiveModel
6-
include ActiveModel::Model
6+
include ActiveModel::Validations
77

88
attr_accessor :json_data
99

10+
def initialize(json_data)
11+
self.json_data = json_data.to_hash
12+
end
13+
1014
validates :json_data, json: {
1115
allow_blank: true,
1216
schema: {
@@ -18,14 +22,14 @@ class FakeActiveModel
1822

1923
describe FakeActiveModel do
2024
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
2226
end
2327

2428
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
2630
end
2731

2832
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
3034
end
3135
end

0 commit comments

Comments
 (0)