module RSpec::Rails::FixtureSupport::Fixtures

def fixtures(*args)

def fixtures(*args)
  super.tap do
    fixture_sets.each_pair do |method_name, fixture_name|
      proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
    end
  end
end

def fixtures(*args)

def fixtures(*args)
  orig_methods = private_instance_methods
  super.tap do
    new_methods = private_instance_methods - orig_methods
    new_methods.each do |method_name|
      proxy_method_warning_if_called_in_before_context_scope(method_name)
    end
  end
end

def proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)

def proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
  define_method(method_name) do |*args, **kwargs, &blk|
    if RSpec.current_scope == :before_context_hook
      RSpec.warn_with("Calling fixture method in before :context ")
    else
      access_fixture(fixture_name, *args, **kwargs, &blk)
    end
  end
end

def proxy_method_warning_if_called_in_before_context_scope(method_name)

def proxy_method_warning_if_called_in_before_context_scope(method_name)
  orig_implementation = instance_method(method_name)
  define_method(method_name) do |*args, &blk|
    if RSpec.current_scope == :before_context_hook
      RSpec.warn_with("Calling fixture method in before :context ")
    else
      orig_implementation.bind(self).call(*args, &blk)
    end
  end
end