class RubyJmeter::ExtendedDSL
Attributes
root[RW]
Public Class Methods
new(params = {})
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 6 def initialize(params = {}) @root = Nokogiri::XML(<<-EOF.strip_heredoc) <?xml version="1.0" encoding="UTF-8"?> <jmeterTestPlan version="1.2" properties="3.1" jmeter="3.1" ruby-jmeter="3.0"> <hashTree> </hashTree> </jmeterTestPlan> EOF node = RubyJmeter::TestPlan.new(params) @current_node = @root.at_xpath('//jmeterTestPlan/hashTree') @current_node = attach_to_last(node) end
Public Instance Methods
active_threads_over_time(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 89 def active_threads_over_time(params = {}, &block) node = RubyJmeter::Plugins::ActiveThreadsOverTime.new(params) attach_node(node, &block) end
Also aliased as: active_threads
composite_graph(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 82 def composite_graph(params = {}, &block) node = RubyJmeter::Plugins::CompositeGraph.new(params) attach_node(node, &block) end
Also aliased as: composite
console_status_logger(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 33 def console_status_logger(params = {}, &block) node = RubyJmeter::Plugins::ConsoleStatusLogger.new(params) attach_node(node, &block) end
Also aliased as: console
constant_throughput_timer(params, &block)
click to toggle source
# File lib/ruby-jmeter/extend/timers/constant_throughput_timer.rb, line 3 def constant_throughput_timer(params, &block) params[:value] ||= params[:throughput] || 0.0 node = RubyJmeter::ConstantThroughputTimer.new(params) node.doc.xpath('//stringProp[@name="throughput"]').first.content = params[:value] attach_node(node, &block) end
dummy_sampler(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 47 def dummy_sampler(params = {}, &block) node = RubyJmeter::Plugins::DummySampler.new(params) attach_node(node, &block) end
Also aliased as: dummy
exists(variable, &block)
click to toggle source
# File lib/ruby-jmeter/extend/misc/exists.rb, line 3 def exists(variable, &block) params ||= {} params[:condition] = "\"${#{variable}}\" != \"\\${#{variable}}\"" params[:useExpression] = false params[:name] = "if ${#{variable}}" node = RubyJmeter::IfController.new(params) attach_node(node, &block) end
extract(params, &block)
click to toggle source
# File lib/ruby-jmeter/extend/processors/extract.rb, line 3 def extract(params, &block) node = if params[:regex] params[:refname] = params[:name] params[:regex] = params[:regex] #CGI.escapeHTML params[:template] = params[:template] || "$1$" RubyJmeter::RegularExpressionExtractor.new(params) elsif params[:xpath] params[:refname] = params[:name] params[:xpathQuery] = params[:xpath] RubyJmeter::XpathExtractor.new(params) elsif params[:json] params[:VAR] = params[:name] params[:JSONPATH] = params[:json] RubyJmeter::Plugins::JsonPathExtractor.new(params) elsif params[:css] params[:refname] = params[:name] params[:expr] = params[:css] RubyJmeter::CssjqueryExtractor.new(params) end attach_node(node, &block) end
Also aliased as: web_reg_save_param
flood(token, params = {})
click to toggle source
# File lib/ruby-jmeter/extend/misc/flood.rb, line 3 def flood(token, params = {}) RestClient.proxy = params[:proxy] if params[:proxy] begin file = Tempfile.new(['ruby-jmeter', '.jmx']) file.write(doc.to_xml(indent: 2)) file.rewind flood_files = { file: File.new("#{file.path}", 'rb') } if params[:files] flood_files.merge!(Hash[params[:files].map.with_index { |value, index| [index, File.new(value, 'rb')] }]) params.delete(:files) end post_params = { flood: { tool: 'jmeter', name: params[:name], notes: params[:notes], tag_list: params[:tag_list], project: params[:project], threads: params[:threads], rampup: params[:rampup], duration: params[:duration], override_parameters: params[:override_parameters], started: params[:started], stopped: params[:stopped], privacy_flag: params[:privacy] || 'private', grids: params[:grids] }.select { |_, value| !value.nil? }, flood_files: flood_files, region: params[:region], multipart: true, content_type: 'application/octet-stream' }.merge(params).select { |_, value| !value.nil? } logger.debug(post_params) if params[:debug] response = RestClient.post "#{params[:endpoint] ? params[:endpoint] : 'https://api.flood.io'}/floods?auth_token=#{token}", post_params if response.code == 201 logger.info "Flood results at: #{JSON.parse(response)["permalink"]}" else logger.fatal "Sorry there was an error: #{JSON.parse(response)["error"]}" end rescue => e logger.fatal "Sorry there was an error: #{e}" end end
foreach_controller(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/controllers/foreach_controller.rb, line 3 def foreach_controller(params = {}, &block) node = RubyJmeter::ForeachController.new(params).tap do |node| if params[:start_index] params[:startIndex] = params[:start_index] node.doc.children.first.add_child ( Nokogiri::XML(<<-EOS.strip_heredoc).children <stringProp name="ForeachController.startIndex"/> EOS ) end if params[:end_index] params[:endIndex] = params[:end_index] node.doc.children.first.add_child ( Nokogiri::XML(<<-EOS.strip_heredoc).children <stringProp name="ForeachController.endIndex"/> EOS ) end end attach_node(node, &block) end
http_cache_manager(params = {}, &block)
click to toggle source
Calls superclass method
# File lib/ruby-jmeter/extend/config_elements/http_cache_manager.rb, line 3 def http_cache_manager(params = {}, &block) params[:clearEachIteration] = true if params.keys.include? :clear_each_iteration params[:useExpires] = true if params.keys.include? :use_expires super end
Also aliased as: cache
http_header_manager(params, &block)
click to toggle source
Calls superclass method
# File lib/ruby-jmeter/extend/config_elements/header_manager.rb, line 3 def http_header_manager(params, &block) if params.is_a?(Hash) params['Header.name'] = params[:name] end super end
Also aliased as: header
http_request(*args, &block)
click to toggle source
# File lib/ruby-jmeter/extend/samplers/http_request.rb, line 3 def http_request(*args, &block) params = args.shift || {} params = { url: params }.merge(args.shift || {}) if params.class == String params[:method] ||= case __callee__.to_s when 'visit' 'GET' when 'submit' 'POST' else __callee__.to_s.upcase end params[:name] ||= params[:url] parse_http_request(params) if params[:sample] transaction name: params[:name], parent: true do loops count: params[:sample].to_i do params.delete(:sample) attach_node(http_request_node(params), &block) end end else attach_node(http_request_node(params), &block) end end
http_request_defaults(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/config_elements/http_request_defaults.rb, line 3 def http_request_defaults(params = {}, &block) params[:image_parser] = true if params.keys.include? :download_resources params[:concurrentDwn] = true if params.keys.include? :use_concurrent_pool params[:concurrentPool] = params[:use_concurrent_pool] if params.keys.include? :use_concurrent_pool node = RubyJmeter::HttpRequestDefaults.new(params).tap do |node| node.doc.children.first.add_child ( Nokogiri::XML(<<-EOS.strip_heredoc).children <stringProp name="HTTPSampler.embedded_url_re">#{params[:urls_must_match]}</stringProp> EOS ) if params[:urls_must_match] node.doc.children.first.add_child ( Nokogiri::XML(<<-EOS.strip_heredoc).children <boolProp name="HTTPSampler.md5">true</stringProp> EOS ) if params[:md5] node.doc.children.first.add_child ( Nokogiri::XML(<<-EOS.strip_heredoc).children <stringProp name="HTTPSampler.proxyHost">#{params[:proxy_host]}</stringProp> EOS ) if params[:proxy_host] node.doc.children.first.add_child ( Nokogiri::XML(<<-EOS.strip_heredoc).children <stringProp name="HTTPSampler.proxyPort">#{params[:proxy_port]}</stringProp> EOS ) if params[:proxy_port] end attach_node(node, &block) end
Also aliased as: defaults
http_request_node(params)
click to toggle source
# File lib/ruby-jmeter/extend/samplers/http_request.rb, line 32 def http_request_node(params) RubyJmeter::HttpRequest.new(params).tap do |node| node.doc.children.first.add_child ( Nokogiri::XML(<<-EOS.strip_heredoc).children <stringProp name="HTTPSampler.implementation">#{params[:implementation]}</stringProp> EOS ) if params[:implementation] node.doc.children.first.add_child ( Nokogiri::XML(<<-EOS.strip_heredoc).children <stringProp name="TestPlan.comments">#{params[:comments]}</stringProp> EOS ) if params[:comments] end end
jms_pointtopoint(params, &block)
click to toggle source
# File lib/ruby-jmeter/extend/samplers/jms_pointtopoint.rb, line 3 def jms_pointtopoint(params, &block) node = RubyJmeter::JmsPointtopoint.new(params).tap do |node| if params[:jndi_properties] params[:jndi_properties].map do |property_name, property_value| node.doc.xpath('//collectionProp').first.add_child ( Nokogiri::XML(<<-EOS.strip_heredoc).children <elementProp name="#{property_name}" elementType="Argument"> <stringProp name="Argument.name">#{property_name}</stringProp> <stringProp name="Argument.value">#{property_value}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> EOS ) end end attach_node(node, &block) end end
jmx(params = {})
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 24 def jmx(params = {}) file(params) logger.info "Test plan saved to: #{params[:file]}" end
jmx_collector(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 115 def jmx_collector(params = {}, &block) node = RubyJmeter::Plugins::JMXCollector.new(params) attach_node(node, &block) end
latencies_over_time(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 28 def latencies_over_time(params = {}, &block) node = RubyJmeter::Plugins::LatenciesOverTime.new(params) attach_node(node, &block) end
loadosophia_uploader(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 103 def loadosophia_uploader(params = {}, &block) node = RubyJmeter::Plugins::LoadosophiaUploader.new(params) attach_node(node, &block) end
Also aliased as: loadosophia
loop_controller(params, &block)
click to toggle source
Calls superclass method
# File lib/ruby-jmeter/extend/controllers/loop_controller.rb, line 3 def loop_controller(params, &block) params[:loops] = params[:count] || 1 super end
Also aliased as: loops
module_controller(params, &block)
click to toggle source
# File lib/ruby-jmeter/extend/controllers/module_controller.rb, line 3 def module_controller(params, &block) node = RubyJmeter::ModuleController.new(params) if params[:test_fragment] params[:test_fragment].kind_of?(String) && params[:test_fragment].split('/') elsif params[:node_path] params[:node_path] else [] end.each_with_index do |node_name, index| node.doc.at_xpath('//collectionProp') << Nokogiri::XML(<<-EOS.strip_heredoc).children <stringProp name="node_#{index}">#{node_name}</stringProp> EOS end attach_node(node, &block) end
out(params = {})
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 20 def out(params = {}) puts doc.to_xml(indent: 2) end
perfmon_collector(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 96 def perfmon_collector(params = {}, &block) node = RubyJmeter::Plugins::PerfmonCollector.new(params) attach_node(node, &block) end
Also aliased as: perfmon
random_timer(delay=0, range=0, &block)
click to toggle source
# File lib/ruby-jmeter/extend/timers/random_timer.rb, line 3 def random_timer(delay=0, range=0, &block) params = {} params[:delay] = delay params[:range] = range node = RubyJmeter::GaussianRandomTimer.new(params) attach_node(node, &block) end
Also aliased as: think_time
redis_data_set(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 110 def redis_data_set(params = {}, &block) node = RubyJmeter::Plugins::RedisDataSet.new(params) attach_node(node, &block) end
regular_expression_extractor(params, &block)
click to toggle source
# File lib/ruby-jmeter/extend/processors/regular_expression_extractor.rb, line 3 def regular_expression_extractor(params, &block) params[:refname] = params[:name] params[:regex] = params[:pattern] params[:template] = params[:template] || "$1$" node = RubyJmeter::RegularExpressionExtractor.new(params).tap do |node| if params[:variable] node.doc.xpath("//stringProp[@name='Sample.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 end attach_node(node, &block) end
Also aliased as: regex
response_assertion(params, &block)
click to toggle source
# File lib/ruby-jmeter/extend/assertions/response_assertion.rb, line 3 def response_assertion(params, &block) 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 = RubyJmeter::Plugins::JsonPathAssertion.new(params) end node ||= RubyJmeter::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, &block) end
Also aliased as: assert, web_reg_find
response_codes_per_second(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 3 def response_codes_per_second(params = {}, &block) node = RubyJmeter::Plugins::ResponseCodesPerSecond.new(params) attach_node(node, &block) end
response_times_distribution(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 8 def response_times_distribution(params = {}, &block) node = RubyJmeter::Plugins::ResponseTimesDistribution.new(params) attach_node(node, &block) end
response_times_over_time(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 13 def response_times_over_time(params = {}, &block) node = RubyJmeter::Plugins::ResponseTimesOverTime.new(params) attach_node(node, &block) end
response_times_percentiles(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 18 def response_times_percentiles(params = {}, &block) node = RubyJmeter::Plugins::ResponseTimesPercentiles.new(params) attach_node(node, &block) end
rsync(params = {})
click to toggle source
# File lib/ruby-jmeter/extend/misc/rsync.rb, line 3 def rsync(params = {}) logger.warn "Test file upload via rsync ..." file(params) cmd = "#{params[:rsync_bin_path]} #{params[:rsync_params]} #{params[:file]} #{params[:remote_user]}@#{params[:remote_host]}:#{params[:remote_path]}" logger.debug cmd if params[:debug] Open3.popen2e("#{cmd}") do |stdin, stdout_err, wait_thr| while line = stdout_err.gets logger.debug line.chomp if params[:debug] end exit_status = wait_thr.value abort "Sorry there was an error: #{cmd}" unless exit_status.success? end logger.info "Upload complete at: #{params[:remote_host]}:#{params[:remote_path]}" end
run(params = {})
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 37 def run(params = {}) file(params) logger.warn 'Test executing locally ...' cmd = "#{params[:path] ? File.join(params[:path], 'jmeter') : 'jmeter'} #{"-n" unless params[:gui] } -t #{params[:file]} -j #{params[:log] ? params[:log] : 'jmeter.log' } -l #{params[:jtl] ? params[:jtl] : 'jmeter.jtl' } #{build_properties(params[:properties]) if params[:properties]}" logger.debug cmd if params[:debug] Open3.popen2e("#{cmd}") do |stdin, stdout_err, wait_thr| while line = stdout_err.gets logger.debug line.chomp if params[:debug] end exit_status = wait_thr.value abort "FAILED !!! #{cmd}" unless exit_status.success? end logger.info "Local Results at: #{params[:jtl] ? params[:jtl] : 'jmeter.jtl'}" end
setup_thread_group(*args, &block)
click to toggle source
# File lib/ruby-jmeter/extend/threads/setup_thread_group.rb, line 3 def setup_thread_group(*args, &block) params = args.shift || {} params = { count: params }.merge(args.shift || {}) if params.class == Fixnum params[:num_threads] = params[:count] || 1 params[:ramp_time] = params[:rampup] || (params[:num_threads]/2.0).ceil params[:start_time] = params[:start_time] || Time.now.to_i * 1000 params[:end_time] = params[:end_time] || Time.now.to_i * 1000 params[:duration] ||= 60 params[:continue_forever] ||= false params[:loops] = -1 if params[:continue_forever] node = RubyJmeter::SetupThreadGroup.new(params) attach_node(node, &block) end
soapxmlrpc_request(params, &block)
click to toggle source
Calls superclass method
# File lib/ruby-jmeter/extend/samplers/soapxmlrpc_request.rb, line 3 def soapxmlrpc_request(params, &block) params[:method] ||= 'POST' super end
Also aliased as: soap
stepping_thread_group(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 54 def stepping_thread_group(params = {}, &block) node = RubyJmeter::Plugins::SteppingThreadGroup.new(params) attach_node(node, &block) end
Also aliased as: step
thread_group(*args, &block)
click to toggle source
# File lib/ruby-jmeter/extend/threads/thread_group.rb, line 3 def thread_group(*args, &block) params = args.shift || {} params = { count: params }.merge(args.shift || {}) if params.class == Fixnum params[:num_threads] = params[:count] || 1 params[:ramp_time] = params[:rampup] || (params[:num_threads]/2.0).ceil params[:start_time] = params[:start_time] || Time.now.to_i * 1000 params[:end_time] = params[:end_time] || Time.now.to_i * 1000 params[:duration] ||= 60 params[:continue_forever] ||= false params[:loops] = -1 if params[:continue_forever] node = RubyJmeter::ThreadGroup.new(params) attach_node(node, &block) end
Also aliased as: threads
throughput_controller(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/controllers/throughput_controller.rb, line 3 def throughput_controller(params = {}, &block) params[:style] = 1 if params[:percent] params[:maxThroughput] = params[:total] || params[:percent] || 1 node = RubyJmeter::ThroughputController.new(params) node.doc.xpath(".//FloatProperty/value").first.content = params[:maxThroughput].to_f attach_node(node, &block) end
Also aliased as: throughput
throughput_shaper(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 40 def throughput_shaper(params = {}, &block) node = RubyJmeter::Plugins::ThroughputShapingTimer.new(params) attach_node(node, &block) end
Also aliased as: shaper
to_doc()
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 33 def to_doc doc.clone end
to_xml()
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 29 def to_xml doc.to_xml(indent: 2) end
transaction_controller(*args, &block)
click to toggle source
# File lib/ruby-jmeter/extend/controllers/transaction_controller.rb, line 3 def transaction_controller(*args, &block) params = args.shift || {} params = { name: params }.merge(args.shift || {}) if params.class == String params[:parent] = params[:parent] || false params[:includeTimers] = params[:include_timers] || false node = RubyJmeter::TransactionController.new(params) attach_node(node, &block) end
Also aliased as: transaction
transactions_per_second(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 23 def transactions_per_second(params = {}, &block) node = RubyJmeter::Plugins::TransactionsPerSecond.new(params) attach_node(node, &block) end
ultimate_thread_group(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb, line 61 def ultimate_thread_group(params = {}, &block) node = RubyJmeter::Plugins::UltimateThreadGroup.new(params) (params.kind_of?(Array) ? params : params[:threads]).each_with_index do |group, index| node.doc.at_xpath('//collectionProp') << Nokogiri::XML(<<-EOS.strip_heredoc).children <collectionProp name="index"> <stringProp name="#{group[:start_threads]}">#{group[:start_threads]}</stringProp> <stringProp name="#{group[:initial_delay]}">#{group[:initial_delay]}</stringProp> <stringProp name="#{group[:start_time]}">#{group[:start_time]}</stringProp> <stringProp name="#{group[:hold_time]}">#{group[:hold_time]}</stringProp> <stringProp name="#{group[:stop_time]}">#{group[:stop_time]}</stringProp> </collectionProp> EOS end attach_node(node, &block) end
Also aliased as: ultimate
user_defined_variables(params, &block)
click to toggle source
Calls superclass method
# File lib/ruby-jmeter/extend/config_elements/user_defined_variables.rb, line 3 def user_defined_variables(params, &block) if params.is_a?(Hash) params['Argument.name'] = params[:name] end super end
Also aliased as: variables
user_parameters(params, &block)
click to toggle source
Calls superclass method
# File lib/ruby-jmeter/extend/config_elements/user_parameters.rb, line 3 def user_parameters(params, &block) params['Argument.name'] = params[:name] if params.is_a?(Hash) params[:names] = Nokogiri::XML::Builder.new do |b| b.builder do params[:names].each do |name| b.stringProp name, name: name end end end params[:thread_values] = Nokogiri::XML::Builder.new do |b| b.builder do params[:thread_values].map do |user, values| b.collectionProp name: user do values.each_with_index.map do |value, index| b.stringProp value, name: index end end end end end super end
Also aliased as: parameters
uuid_per_iteration(params = {}, &block)
click to toggle source
# File lib/ruby-jmeter/extend/misc/uuid.rb, line 3 def uuid_per_iteration(params = {}, &block) params[:name] ||= '__UUID' params[:variable] ||= 'UUID' dummy_sampler name: params[:name], response_data: '${__UUID}' do regex pattern: '(.*)', name: params[:variable], match_number: 1 end end
with_browser(device)
click to toggle source
# File lib/ruby-jmeter/extend/misc/with_helpers.rb, line 7 def with_browser(device) http_header_manager name: 'User-Agent', value: RubyJmeter::UserAgent.new(device).string http_header_manager [ { name: 'Accept-Encoding', value: 'gzip,deflate,sdch' }, { name: 'Accept', value: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' } ] end
with_gzip()
click to toggle source
# File lib/ruby-jmeter/extend/misc/with_helpers.rb, line 19 def with_gzip http_header_manager name: 'Accept-Encoding', value: 'gzip, deflate' end
with_json()
click to toggle source
# File lib/ruby-jmeter/extend/misc/with_helpers.rb, line 23 def with_json http_header_manager name: 'Accept', value: 'text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8, application/json' end
with_user_agent(device)
click to toggle source
# File lib/ruby-jmeter/extend/misc/with_helpers.rb, line 3 def with_user_agent(device) http_header_manager name: 'User-Agent', value: RubyJmeter::UserAgent.new(device).string end
with_xhr()
click to toggle source
# File lib/ruby-jmeter/extend/misc/with_helpers.rb, line 15 def with_xhr http_header_manager name: 'X-Requested-With', value: 'XMLHttpRequest' end
Private Instance Methods
attach_node(node, &block)
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 67 def attach_node(node, &block) ht = attach_to_last(node) previous = @current_node @current_node = ht instance_exec(&block) if block @current_node = previous end
attach_to_last(node)
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 60 def attach_to_last(node) ht = hash_tree last_node = @current_node last_node << node.doc.children << ht ht end
build_properties(properties)
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 84 def build_properties(properties) if properties.kind_of?(String) "-q #{properties}" elsif properties.kind_of?(Hash) properties.map{ |k,v| "-J#{k}=#{v}" }.join(" ") end end
doc()
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 80 def doc Nokogiri::XML(@root.to_s, &:noblanks) end
file(params = {})
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 75 def file(params = {}) params[:file] ||= 'ruby-jmeter.jmx' File.open(params[:file], 'w') { |file| file.write(doc.to_xml(indent: 2)) } end
hash_tree()
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 56 def hash_tree Nokogiri::XML::Node.new("hashTree", @root) end
logger()
click to toggle source
# File lib/ruby-jmeter/dsl.rb, line 92 def logger @log ||= Logger.new(STDOUT) @log.level = Logger::DEBUG @log end