require File.expand_path('../../spec_helper', __FILE__)

class Parent < ActiveRecord::Base
  def self.column_names; %w(one two) end

  has_one :child
  delegate_all_for :child, except: [:three], also_include: [:extra]

  def initialize; end
  def two; 'parent' end
end

class Child < ActiveRecord::Base
  belongs_to :parent
  def self.column_names; %w(two three four) end
  def two; 'child' end
  def extra; true end
end

describe DelegateAllFor do
  describe 'delegate_all_for' do
    subject { Parent.new }

    it { should respond_to? :three }
    it { should respond_to? :three? }
    it { should respond_to? :three= }
    it { should respond_to? :extra }
    it { should_not respond_to? :three }
    its(:two) { should == 'parent' }
  end
end

require File.expand_path('../../spec_helper', __FILE__)
require File.expand_path('../../support/active_record', __FILE__)

class Child < ActiveRecord::Base
  belongs_to :parent
  #def self.column_names; %w(two three four) end
  def two; 'child' end
  def extra; true end
end

class Parent < ActiveRecord::Base
  #def self.column_names; %w(one two) end

  has_one :child
  delegate_all_for :child, except: [:three], also_include: [:extra]

  def initialize; end
  def two; 'parent' end
end

describe DelegateAllFor do
  describe 'delegate_all_for' do
    subject { Parent.new }

    it { should respond_to? :three }
    it { should respond_to? :three? }
    it { should respond_to? :three= }
    it { should respond_to? :extra }
    it { should_not respond_to? :three }
    its(:two) { should == 'parent' }
  end
end

Rearrange Child and Parent definitions so Child is in scope when we delegate to it from Parent
Rearrange Child and Parent definitions so Child is in scope when we delegate to it from Parent
