Sha256: ae51b97f358ae1ba0099e331b9b1828127623ab55f4a7b417d119ff355b620ba

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

include Restspec::Schema

describe SchemaExample do
  let(:schema) { Schema.new(:name) }
  let(:hidden_type) { double(example_for: 'hidden') }
  let(:string_type) { double(example_for: 'name') }
  let(:integer_type) { double(example_for: 18) }

  subject { schema_example.value }

  before do
    schema.attributes['name'] = Attribute.new(:name, string_type)
    schema.attributes['age'] = Attribute.new(:age, integer_type)
  end

  context 'without extensions' do
    let(:schema_example) { SchemaExample.new(schema) }

    it { should eq(name: 'name', age: 18)}

    context 'with an attribute not allowed to generate examples' do
      before do
        schema.attributes['hidden'] = Attribute.new(:hidden, hidden_type, :for => [:checks])
      end

      it 'does not include the hidden attribute' do
        expect(subject).to_not include(:hidden)
      end
    end
  end

  context 'with extensions' do
    let(:extensions) { Hash[age: 21] }
    let(:schema_example) { SchemaExample.new(schema, extensions) }

    it { should eq(name: 'name', age: 21) }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
restspec-0.1 spec/restspec/schema/schema_example_spec.rb
restspec-0.0.4 spec/restspec/schema/schema_example_spec.rb
restspec-0.0.3 spec/restspec/schema/schema_example_spec.rb
restspec-0.0.2 spec/restspec/schema/schema_example_spec.rb
restspec-0.0.1 spec/restspec/schema/schema_example_spec.rb