Sha256: 7eaa0ef5a4ec973cafc4058d60a1a64d7976222b3d2c5ff90195778b05eaeb72

Contents?: true

Size: 841 Bytes

Versions: 2

Compression:

Stored size: 841 Bytes

Contents

require "spec_helper"

describe Findable::Associations::ActiveRecordExt do
  let(:company) { Company.first }
  let(:store) { Store.first }
  let(:email) { Email.first }
  let(:user) { User.first }

  describe "#has_many" do
    it { expect(company.users).to be_kind_of(Array) }
    it { expect(company.users.first).to be_kind_of(User) }
    it { expect(company.stores).to be_kind_of(ActiveRecord::Relation) }
    it { expect(company.stores.first).to be_kind_of(Store) }
  end

  describe "#has_one" do
    it { expect(company.image).to be_kind_of(Image) }
    it { expect(store.email).to be_kind_of(Email) }
  end

  describe "#belongs_to" do
    it { expect(email.user).to be_kind_of(User) }
    it { expect(store.company).to be_kind_of(Company) }
    it {
      email.user = user
      expect(email.user_id).to eq(user.id)
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
findable-0.1.5 spec/findable/associations/active_record_ext_spec.rb
findable-0.1.4 spec/findable/associations/active_record_ext_spec.rb