Sha256: d42e6d0b7435e7e7cebad9c469cd00f0ade16746d89ce1aca91c16517231fe2d

Contents?: true

Size: 1.15 KB

Versions: 12

Compression:

Stored size: 1.15 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::DSL::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(JmeterPerf::Helpers::String.strip_heredoc(
              <<-EOS
              <stringProp name="Scope.variable">#{params[:variable]}</stringProp>
              EOS
            )).children
          )
        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

12 entries across 12 versions & 1 rubygems

Version Path
jmeter_perf-1.1.1 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.1.0 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.10 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.9 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.8 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.7 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.6 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.5 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.4 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.2 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.1 lib/jmeter_perf/extend/assertions/response_assertion.rb
jmeter_perf-1.0.0 lib/jmeter_perf/extend/assertions/response_assertion.rb