Sha256: 1efc0e0c26880f1605b1baecca2afb00819ac8beb39d8e2077dcc922d31d0a84

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

module JmeterPerf
  class DSL
    # DSL method synonymous with the JMeter Element JSONPathPostprocessor
    # @see https://github.com/jlurena/jmeter_perf/wiki/1.-DSL-Documentation#jsonpathpostprocessor
    # @param [Hash] params Parameters for the JSONPathPostprocessor element (default: `{}`).
    # @yield block to attach to the JSONPathPostprocessor element
    # @return [JmeterPerf::JSONPathPostprocessor], a subclass of JmeterPerf::DSL that can be chained with other DSL methods.
    def json_path_postprocessor(params = {}, &)
      node = JmeterPerf::JSONPathPostprocessor.new(params)
      attach_node(node, &)
    end
  end

  class JSONPathPostprocessor
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "JSONPathPostprocessor" : (params[:name] || "JSONPathPostprocessor")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <JSONPostProcessor guiclass="JSONPostProcessorGui" testclass="JSONPostProcessor" testname="#{testname}" enabled="true">
          <stringProp name="JSONPostProcessor.referenceNames"/>
          <stringProp name="JSONPostProcessor.jsonPathExprs"/>
          <stringProp name="JSONPostProcessor.match_numbers"/>
        </JSONPostProcessor>
      EOS
      update params
      update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jmeter_perf-0.0.7 lib/jmeter_perf/dsl/json_path_postprocessor.rb