Skip to content

Commit be8001a

Browse files
committed
Add relies_on looking in RSpec config
1 parent f8c4fde commit be8001a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spec/spec_helper.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,22 @@
9797
# as the one that triggered the failure.
9898
Kernel.srand config.seed
9999
=end
100+
101+
config.add_setting :relies_on
102+
103+
config.before(:suite) do
104+
config.relies_on = reckon_relies_on
105+
end
106+
end
107+
108+
def reckon_relies_on
109+
relies_on = Hash.new { |hash, key| hash[key] = [] }
110+
ObjectSpace.each_object(Class).select { |klass| klass < RSpec::Core::ExampleGroup }.each do |klass|
111+
instance = klass.new
112+
next unless instance.respond_to?(:relies_on)
113+
114+
relies_on_key = instance.method(:relies_on).call
115+
relies_on[relies_on_key] << klass
116+
end
117+
relies_on
100118
end

0 commit comments

Comments
 (0)