Sha256: 6c7773f20aab5b63ed9b1d7e8ce98acfd585a284b344dc03da6c12b755f05e1b

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

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

  class TestFragment
    attr_accessor :doc
    include Helper

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