16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/rspec-plugins/core.rb', line 16
def included(example_group)
proxy = Proxy.new(example_group)
example_group.metadata[:plugins] = proxy
example_group.define_singleton_method(:plugins) { proxy }
example_group.define_singleton_method :plugin do |plugin_id, meth, *args, &block|
current_example_group = self
plugin = proxy[plugin_id]
if plugin.nil?
raise("No plugin with id :#{plugin_id} enabled. Enabled plugins: #{proxy.plugins.keys}")
else
current_example_group.before(:all) do
plugin.current_example_group = current_example_group
Core.log("Calling plugin method #{plugin}##{meth}")
plugin.send(meth, *args, &block)
end
end
end
log "Included RSpec::Plugins::Core in example group [#{example_group.description}]"
end
|