Sha256: 478eb556f30829cf71035a43f0a998df00c1e87732b1d82f4582840d58014c9d

Contents?: true

Size: 915 Bytes

Versions: 11

Compression:

Stored size: 915 Bytes

Contents

require 'spec_helper'

include Restspec::Schema::Types

describe EmbeddedSchemaType do
  let(:type) { EmbeddedSchemaType.new(:category) }

  before do
    Restspec::Schema::DSL.new.instance_eval do
      schema :category do
        attribute :name, string
        attribute :description, string
      end
    end
  end

  describe '#example_for' do
    it 'is a example of the embedded schema' do
      sample = type.example_for(double)
      expect(sample[:name]).to be_a_kind_of(String)
    end
  end

  describe '#valid?' do
    it 'is valid if this works with the embedded schema' do
      expect(type.totally_valid?(double, name: 'Name', description: 'Desc')).to eq(true)
      expect(type.totally_valid?(double, name: 'Name')).to eq(false)
      expect(type.totally_valid?(double, age: 10)).to eq(false)
      expect(type.totally_valid?(double, name: 'Name', description: nil)).to eq(false)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
restspec-0.3.2 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.3.1 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.3.0 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.2.6 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.2.5 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.2.4 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.2.3 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.2.2 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.2.1 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.2 spec/restspec/schema/types/embedded_schema_type_spec.rb
restspec-0.1 spec/restspec/schema/types/embedded_schema_type_spec.rb