<commit_before>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<commit_msg>Rearrange Child and Parent definitions so Child is in scope when we delegate to it from Parent<commit_after>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
{'fraction_non_alphanumeric': 0.11255156157925751, 'fraction_numerical': 0.0, 'mean_word_length': 3.8238636363636362, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2971482', 'n_tokens_mistral': 561, 'n_tokens_neox': 550, 'n_words': 178}