Module: LogStash::PluginMixins::ECSCompatibilitySupport::SpecHelper
- Defined in:
- lib/logstash/plugin_mixins/ecs_compatibility_support/spec_helper.rb
Overview
The ‘SpecHelper` is meant to be extended into an rspec context to provide it with tools for vaidating the ecs_compatibility matrix.
It creates one sub-context per provided mode, and yields a Selector::State to the provided block primed with the list of supported supported_modes and the active mode.
It also memoizes an ‘ecs_compatibility` set to the active mode. It is up to the user to plumb this into the initialization of your plugin.
~~~ ruby require ‘logstash/plugin_mixins/ecs_compatibility_support/spec_helper’
describe YourClass, :ecs_compatibility_support
ecs_compatibility_matrix(:disabled, :v1) do |ecs_select|
context "#description" do
subject(:result) { instance.description }
it { is_expected.to eq ecs_select[disabled: "legacy", v1: "novel"] }
end
end
end ~~~
Instance Method Summary collapse
Instance Method Details
#ecs_compatibility_matrix(*supported_modes, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/logstash/plugin_mixins/ecs_compatibility_support/spec_helper.rb', line 30 def ecs_compatibility_matrix(*supported_modes,&block) if supported_modes.empty? || supported_modes.any? { |mode| !mode.kind_of?(Symbol) } fail(ArgumentError, "ecs_compatibility_matrix(*supported_modes) requires one or more symbol supported_modes") end supported_modes.each do |active_mode| context "`ecs_compatibility => #{active_mode}`" do let(:ecs_compatibility) { active_mode } ecs_select = Selector::State.new(supported_modes, active_mode) instance_exec(ecs_select, &block) end end end |