Skip to content

Commit 24d0e4a

Browse files
committed
fixup! properly define class methods
1 parent 8b47470 commit 24d0e4a

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

lib/rspec/rails/fixture_support.rb

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,27 @@ module FixtureSupport
2626
end
2727

2828
module Fixtures
29-
def self.fixtures(*args)
30-
orig_methods = private_instance_methods
31-
super.tap do
32-
new_methods = private_instance_methods - orig_methods
33-
new_methods.each do |method_name|
34-
proxy_method_warning_if_called_in_before_context_scope(method_name)
29+
extend ActiveSupport::Concern
30+
31+
class_methods do
32+
def fixtures(*args)
33+
orig_methods = private_instance_methods
34+
super.tap do
35+
new_methods = private_instance_methods - orig_methods
36+
new_methods.each do |method_name|
37+
proxy_method_warning_if_called_in_before_context_scope(method_name)
38+
end
3539
end
3640
end
37-
end
3841

39-
def self.proxy_method_warning_if_called_in_before_context_scope(method_name)
40-
orig_implementation = instance_method(method_name)
41-
define_method(method_name) do |*args, &blk|
42-
if inspect.include?("before(:context)")
43-
RSpec.warn_with("Calling fixture method in before :context ")
44-
else
45-
orig_implementation.bind(self).call(*args, &blk)
42+
def proxy_method_warning_if_called_in_before_context_scope(method_name)
43+
orig_implementation = instance_method(method_name)
44+
define_method(method_name) do |*args, &blk|
45+
if inspect.include?("before(:context)")
46+
RSpec.warn_with("Calling fixture method in before :context ")
47+
else
48+
orig_implementation.bind(self).call(*args, &blk)
49+
end
4650
end
4751
end
4852
end

0 commit comments

Comments
 (0)