Sha256: 0a7b5198e704daff7cc7dc4e0eeb297576475da17b8f9e28e550df21728854c0

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

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

  class ResponseAssertion
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "ResponseAssertion" : (params[:name] || "ResponseAssertion")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="#{testname}" enabled="true">
          <collectionProp name="Asserion.test_strings">
            <stringProp name="0"/>
          </collectionProp>
          <stringProp name="Assertion.test_field">Assertion.response_data</stringProp>
          <boolProp name="Assertion.assume_success">false</boolProp>
          <intProp name="Assertion.test_type">16</intProp>
          <stringProp name="Assertion.scope">all</stringProp>
        </ResponseAssertion>
      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/response_assertion.rb