Sha256: c15e2ea226b97d041ab5c442e936888557ea1459b4faf1a1d72d64fefa24c02f

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

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

  class SwitchController
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "SwitchController" : (params[:name] || "SwitchController")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <SwitchController guiclass="SwitchControllerGui" testclass="SwitchController" testname="#{testname}" enabled="true">
          <stringProp name="SwitchController.value"/>
        </SwitchController>
      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/switch_controller.rb