module Inspec::DescribeDslLazyLoader
This module exists to intercept the method_missing
class method on RSpec::Core::ExampleGroup
and is part of support for DSL
plugintypes
Public Instance Methods
method_missing(method_name, *arguments, &block)
click to toggle source
Support for Describe
DSL
plugins
Calls superclass method
# File lib/inspec/rspec_extensions.rb, line 13 def method_missing(method_name, *arguments, &block) begin backend = metadata[:backend] # populated via Inspec::Runner#add_resource resource = Inspec::DSL.method_missing_resource(backend, method_name, *arguments) return resource if resource rescue LoadError # pass through end # Check to see if there is a describe_dsl plugin activator hook with the method name registry = Inspec::Plugin::V2::Registry.instance hook = registry.find_activators(plugin_type: :describe_dsl, activator_name: method_name).first if hook # OK, load the hook if it hasn't been already. We'll then know a module, # which we can then inject into the context hook.activate # Inject the module's methods into the example group contexts. # implementation_class is the field name, but this is actually a module. # RSpec works by having these helper methods defined as class methods # (see the definition of `let` as an example) # So, we use extend to inject the new DSL methods. RSpec::Core::ExampleGroup.extend(hook.implementation_class) # We still haven't called the method we were looking for, so do so now. send(method_name, *arguments, &block) else super end end