Sha256: 95aee172777a4b1ac73216df07f7ec4f1074a501ae868207be527e5f20ca9254

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'
require 'active_data/base'

describe ActiveData::Model::Associations::Reflections::EmbedsAny do
  describe '#build' do
    subject { described_class.build(User, User, :projects) {}.klass.new }

    before do
      stub_model(:project) do
        include ActiveData::Model::Lifecycle
        attribute :title, String
      end
      stub_model(:user) do
        include ActiveData::Model::Associations

        attribute :name, String
        embeds_many :projects
      end
    end

    it { is_expected.to be_a(ActiveData::Model) }
    it { is_expected.to be_a(ActiveData::Model::Primary) }
    it { is_expected.to be_a(ActiveData::Model::Lifecycle) }
    it { is_expected.to be_a(ActiveData::Model::Associations) }

    context 'when ActiveData.base_concern is defined' do
      before do
        stub_const('MyModule', Module.new)

        allow(ActiveData).to receive(:base_concern).and_return(MyModule)

        stub_model(:user) do
          include ActiveData::Model::Associations

          embeds_many :projects
        end
      end

      it { is_expected.to be_a(MyModule) }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
active_data-1.2.0 spec/lib/active_data/model/associations/reflections/embeds_any_spec.rb
active_data-1.1.7 spec/lib/active_data/model/associations/reflections/embeds_any_spec.rb
active_data-1.1.6 spec/lib/active_data/model/associations/reflections/embeds_any_spec.rb
active_data-1.1.5 spec/lib/active_data/model/associations/reflections/embeds_any_spec.rb
active_data-1.1.4 spec/lib/active_data/model/associations/reflections/embeds_any_spec.rb
active_data-1.1.3 spec/lib/active_data/model/associations/reflections/embeds_any_spec.rb
active_data-1.1.2 spec/lib/active_data/model/associations/reflections/embeds_any_spec.rb