spec/restspec/schema/dsl_spec.rb in restspec-0.2.6 vs spec/restspec/schema/dsl_spec.rb in restspec-0.3.0

- old
+ new

@@ -5,16 +5,14 @@ describe DSL do let(:dsl) { DSL.new } describe '#schema' do let(:single_dsl) { double } - let(:schema) { double(name: 'name') } + let(:schema) { Schema.new(name: 'name') } before do - allow(SingleSchemaDSL).to receive(:new).and_return(single_dsl) - allow(single_dsl).to receive(:instance_eval).and_return(single_dsl) - allow(single_dsl).to receive(:schema).and_return(schema) + allow(SingleSchemaDSL).to receive(:new).and_call_original end it 'creates a SingleSchemaDSL with the given name' do dsl.schema('name') { } expect(SingleSchemaDSL).to have_received(:new) @@ -22,10 +20,22 @@ it 'store the schema into the SchemaStore' do dsl.schema('name') { } expect(Restspec::SchemaStore.get('name')).to be_present end + + it 'stores a schema with the root attribute set to false' do + dsl.schema('dog') { } + expect(Restspec::SchemaStore.get('name').root?).to eq(false) + end + + context 'with the root option set to true' do + it 'creates a schema with the root option set to true' do + dsl.schema('dog', root: true) { } + expect(Restspec::SchemaStore.get('dog').root?).to eq(true) + end + end end end describe SingleSchemaDSL do let(:dsl) { SingleSchemaDSL.new(name) } @@ -52,10 +62,10 @@ end end describe '#include_attributes' do let(:main_dsl) { DSL.new } - let(:schema_dsl) { SingleSchemaDSL.new(:name, main_dsl.send(:mixins)) } + let(:schema_dsl) { SingleSchemaDSL.new(:name, {}, main_dsl.send(:mixins)) } before do main_dsl.mixin :test_mixin do attribute :test_attribute, string end