Sha256: 0b4b565077bad8f69785162b061aa7e6f8cf32fbb2da0b5a3b66a64720603de1

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

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

  class XMLAssertion
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "XMLAssertion" : (params[:name] || "XMLAssertion")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <XMLAssertion guiclass="XMLAssertionGui" testclass="XMLAssertion" 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/xml_assertion.rb