Sha256: b0be6a0fef6251a16407b608d60425063c8811b37b80458b1beb03c979a41934

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

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

  class DurationAssertion
    attr_accessor :doc
    include Helper

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