Sha256: 488b43443d2dd40faf1cd96dcb0b085f13da40551de529fffc559017a8a12e9f

Contents?: true

Size: 1.42 KB

Versions: 8

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe Virtus::Attribute::EmbeddedValue, '.build' do
  subject { described_class.build(type) }

  context 'when type is a Virtus.model' do
    let(:type) { Class.new { include Virtus.model } }

    it { should be_frozen }

    it { should be_instance_of(Virtus::Attribute::EmbeddedValue) }

    its(:coercer) { should be_instance_of(described_class::FromOpenStruct) }
  end

  context 'when type includes Virtus' do
    let(:type) { Class.new { include Virtus } }

    it { should be_frozen }

    it { should be_instance_of(Virtus::Attribute::EmbeddedValue) }

    its(:coercer) { should be_instance_of(described_class::FromOpenStruct) }
  end

  context 'when type is an OpenStruct subclass' do
    let(:type) { Class.new(OpenStruct) }

    it { should be_frozen }

    it { should be_instance_of(Virtus::Attribute::EmbeddedValue) }

    its(:coercer) { should be_instance_of(described_class::FromOpenStruct) }
  end

  context 'when type is OpenStruct' do
    let(:type) { OpenStruct }

    it { should be_frozen }

    it { should be_instance_of(Virtus::Attribute::EmbeddedValue) }

    its(:coercer) { should be_instance_of(described_class::FromOpenStruct) }
  end

  context 'when type is Struct' do
    let(:type) { Struct.new(:test) }

    it { should be_frozen }

    it { should be_instance_of(Virtus::Attribute::EmbeddedValue) }

    its(:coercer) { should be_instance_of(described_class::FromStruct) }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
virtus-1.0.3 spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb
virtus-1.0.2 spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb
virtus-1.0.1 spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb
virtus-1.0.0 spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb
virtus-1.0.0.rc2 spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb
virtus-1.0.0.rc1 spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb
virtus-1.0.0.beta8 spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb
virtus-1.0.0.beta7 spec/unit/virtus/attribute/embedded_value/class_methods/build_spec.rb