Module: Kensho::RSpec::GroupTracker
- Defined in:
- lib/kensho/rspec/helpers.rb
Overview
Hook RSpec’s example-group definition so Kensho::Feature/Epic/Story can find the group whose describe block is currently executing. We override ‘module_exec` on the freshly-built subclass to push the class onto a tracking stack while RSpec evaluates the user body.
Instance Method Summary collapse
Instance Method Details
#subclass(parent, description, args, registration_collection, &example_group_block) ⇒ Object
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/kensho/rspec/helpers.rb', line 279 def subclass(parent, description, args, registration_collection, &example_group_block) wrapped = nil if example_group_block tracker = Kensho::RSpec::State wrapped = lambda do |*lambda_args| tracker.push_group(self) begin instance_exec(*lambda_args, &example_group_block) ensure tracker.pop_group end end end super(parent, description, args, registration_collection, &(wrapped || example_group_block)) end |