class ApiBomb::Path::Single

Constants

HTTP_METHODS

Public Class Methods

new(path:, action: :get, options: {}) click to toggle source
# File lib/api_bomb/path.rb, line 20
def initialize(path:, action: :get, options: {})
  @path = path
  @action = action
  @action = :get if not HTTP_METHODS.include?(action.downcase.to_sym)
  @options = ApiBomb::LambdaHash.new(options)
end

Public Instance Methods

action() click to toggle source
# File lib/api_bomb/path.rb, line 60
def action
  return @action.call if @action.respond_to? :call
  return @action
end
options() click to toggle source
# File lib/api_bomb/path.rb, line 65
def options
  @options
end
params_report() click to toggle source
# File lib/api_bomb/path.rb, line 45
def params_report
  return '' unless options[:params]

  if options.is_lambda?
    " with random params like: #{ApiBomb::LambdaHash.hasharize(options)[:params]}"
  else
    " with params: #{options[:params]}"
  end
end
path() click to toggle source
# File lib/api_bomb/path.rb, line 55
def path
  return @path.call if @path.respond_to? :call
  return @path
end
path_report(base_url = '') click to toggle source
# File lib/api_bomb/path.rb, line 35
def path_report(base_url = '')
  base_url = options[:base_url] if options[:base_url]

  if @path.respond_to? :call
    "testing random paths like #{action.to_s.upcase} #{URI::join(base_url, path)}"
  else
    "testing path #{action.to_s.upcase} #{URI::join(base_url, path)}"
  end
end
pick() click to toggle source
# File lib/api_bomb/path.rb, line 27
def pick
  return self
end
report(base_url) click to toggle source
# File lib/api_bomb/path.rb, line 31
def report(base_url)
  path_report(base_url) + params_report
end