Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions json-schema_builder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'appraisal'
spec.add_dependency 'activesupport', '>= 4.0'
spec.add_dependency 'json-schema', '>= 2.1'
spec.add_dependency 'ostruct'
end
8 changes: 2 additions & 6 deletions lib/json/schema_builder/rspec_helper/deep_open_struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ module SchemaBuilder
module RSpecHelper
class DeepOpenStruct < OpenStruct
def initialize(hash = { })
@table = { }
hash.each_pair do |key, value|
key = key.to_sym
@table[key] = _transform value
new_ostruct_member key
end
transformed = hash.transform_keys(&:to_sym).transform_values { |v| _transform(v) }
super(transformed)
end

def ==(other)
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def initialize(*args); end
end

it 'should dispatch to entity' do
expect(instance).to receive(:entity).with(:something, 1, foo: :bar).and_call_original
expect(instance).to receive(:entity).with(:something, 1, { foo: :bar }).and_call_original
instance.something 1, foo: :bar
end

it 'should allow unnamed entities' do
expect(instance).to receive(:entity).with(:something, nil, foo: :bar).and_call_original
expect(instance).to receive(:entity).with(:something, nil, { foo: :bar }).and_call_original
instance.something foo: :bar
end
end
Expand Down Expand Up @@ -60,7 +60,7 @@ def initialize(*args); end

it 'should set the parent' do
expect(instance.class).to receive(:new)
.with('name', parent: kind_of(klass)).and_call_original
.with('name', { parent: kind_of(klass) }).and_call_original

entity = instance.entity :something, 'name'
expect(entity).to be_a klass
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/entity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def example

it "should #{ validator }" do
expect(JSON::Validator).to receive(validator)
.with subject.as_json, { }, working: true, opts: true
.with subject.as_json, { }, { working: true, opts: true }
subject.send validator, { }, opts: true
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/schema_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def example
describe "##{ validator }" do
it "should #{ validator }" do
expect(JSON::Validator).to receive(validator)
.with schema.as_json, { }, opts: true
.with schema.as_json, { }, { opts: true }
schema.send validator, { }, opts: true
end
end
Expand Down