Sha256: 12d9203f05db731100c9d584be08620e5af0cccaf8883f4c4a2cbee73d60c80f

Contents?: true

Size: 828 Bytes

Versions: 3

Compression:

Stored size: 828 Bytes

Contents

require "spec_helper"

describe Mongoid::Relations::Proxy do

  describe "#extend" do

    before(:all) do
      Person.reset_callbacks(:validate)
      module Testable
      end
    end

    after(:all) do
      Object.send(:remove_const, :Testable)
    end

    let(:person) do
      Person.create
    end

    let(:name) do
      person.build_name
    end

    before do
      name.namable.extend(Testable)
    end

    it "extends the proxied object" do
      person.should be_a(Testable)
    end

    context "when extending from the relation definition" do

      let!(:address) do
        person.addresses.create(street: "hobrecht")
      end

      let(:found) do
        person.addresses.find_by_street("hobrecht")
      end

      it "extends the proxy" do
        found.should eq(address)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-3.1.7 spec/mongoid/relations/proxy_spec.rb
mongoid-3.1.6 spec/mongoid/relations/proxy_spec.rb
mongoid-3.1.5 spec/mongoid/relations/proxy_spec.rb