Skip to content

Commit e49f830

Browse files
author
Sam Phippen
committed
Use a module instead of proxying fixture methods directly on self.
1 parent 33aa831 commit e49f830

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/rspec/rails/fixture_support.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,24 @@ def self.fixtures(*args)
3333
orig_methods = private_instance_methods
3434
super.tap do
3535
new_methods = private_instance_methods - orig_methods
36+
builder_module = Module.new do
37+
def self.inspect
38+
"<RSpec fixtures module defined at #{__FILE__}:#{__LINE__}>"
39+
end
40+
end
3641
new_methods.each do |method_name|
37-
proxy_method_warning_if_called_in_before_context_scope(method_name)
42+
proxy_method_warning_if_called_in_before_context_scope(builder_module, method_name)
3843
end
44+
45+
require 'pry'; binding.pry
46+
47+
include builder_module
3948
end
4049
end
4150

42-
def self.proxy_method_warning_if_called_in_before_context_scope(method_name)
51+
def self.proxy_method_warning_if_called_in_before_context_scope(builder_module, method_name)
4352
orig_implementation = instance_method(method_name)
44-
define_method(method_name) do |*args, &blk|
53+
builder_module.send(:define_method, method_name) do |*args, &blk|
4554
if inspect.include?("before(:context)")
4655
RSpec.warn_with("Calling fixture method in before :context ")
4756
else

0 commit comments

Comments
 (0)