Sha256: d89b4dd9ff2a13f73710e4653fc6d00bf059eb0d925e9edcc736ca2eb589027e
Contents?: true
Size: 1.18 KB
Versions: 17
Compression:
Stored size: 1.18 KB
Contents
module JSON module SchemaBuilder module RSpecHelper extend ::RSpec::SharedContext let(:schema_method){ raise 'undefined schema method' } let(:schema_context){ { } } let(:schema){ described_class.new(schema_context).send schema_method } let(:json){ schema.as_json } let(:id_schema) do { oneOf: [ { type: 'integer', minimum: 1 }, { type: 'string', pattern: '^[1-9]\d*$' } ] } end let(:nullable_id_schema) do { oneOf: [ { type: 'integer', minimum: 1 }, { type: 'string', pattern: '^[1-9]\d*$' }, { type: 'null' } ] } end subject{ DeepOpenStruct.new json } def self.included(klass) super klass klass.send :extend, ClassMethods end module ClassMethods def with(key, &block) describe ".#{ key }" do eval "def subject; super.#{ key }; end" it 'should return an entity' do expect(schema).to be_a JSON::SchemaBuilder::Entity end instance_exec &block end end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems