Sha256: eeab3c823837a7f859ec827ac300fb658c26ef15b3b0e24b9b85a1a2f8b0f4d5

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

module JmeterPerf
  class ExtendedDSL < DSL
    def response_assertion(params, &)
      params[:test_type] = parse_test_type(params)
      params["0"] = params.values.first

      if params[:json]
        params[:EXPECTED_VALUE] = params[:value]
        params[:JSON_PATH] = params[:json]
        node = JmeterPerf::Plugins::JsonPathAssertion.new(params)
      end

      node ||= JmeterPerf::ResponseAssertion.new(params).tap do |node|
        if params[:variable]
          params["Scope.variable"] = params[:variable]
          node.doc.xpath("//stringProp[@name='Assertion.scope']").first.content = "variable"

          node.doc.children.first.add_child(
            Nokogiri::XML(<<-EOS.strip_heredoc).children
              <stringProp name="Scope.variable">#{params[:variable]}</stringProp>
            EOS
          )
        end

        if params[:scope] == "main"
          node.doc.xpath("//stringProp[@name='Assertion.scope']").remove
        end
      end

      attach_node(node, &)
    end

    alias_method :assert, :response_assertion
    alias_method :web_reg_find, :response_assertion
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jmeter_perf-0.0.7 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-0.0.6 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-0.0.2 lib/jmeter_perf/extend/assertions/response_assertion.rb