Top Level Namespace

Defined Under Namespace

Modules: Jackal

Instance Method Summary collapse

Methods included from Jackal::Utils::Config

#config, #config_path, #destination, #source_prefix

Methods included from Jackal::Utils::Payload

#new_payload, #unpack

Instance Method Details

#payload_for(style, args = {}) ⇒ Hash

Note:

‘style` is name of test payload without .json extension. Will

Fetch test payload and create new payload

search ‘test/specs/payload’ from CWD first, then fallback to ‘payloads’ directory within the directory of this file

Parameters:

  • style (String, Symbol)

    name of payload

  • args (Hash) (defaults to: {})

Options Hash (args):

  • :raw (TrueClass, FalseClass)

    return loaded payload only

  • :nest (String, Symbol)

    place loaded payload within key namespace in hash

Returns:

  • (Hash)

    new payload



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/jackal/utils/spec/helpers.rb', line 29

def payload_for(style, args={})
  file = "#{style}.json"
  path = [File.join(Dir.pwd, 'test/specs/payloads'), Jackal::Utils::Spec.payload_storage].flatten.compact.map do |dir|
    if(File.exists?(full_path = File.join(dir, file)))
      full_path
    end
  end.compact.first
  if(path)
    if(args[:raw])
      MultiJson.load(File.read(path))
    else
      if(args[:nest])
        Jackal::Utils.new_payload(:test, args[:nest] => MultiJson.load(File.read(path)))
      else
        Jackal::Utils.new_payload(:test, File.read(path))
      end
    end
  else
    raise "Requested payload path for test does not exist: #{path ? File.expand_path(path) : 'no path discovered'}"
  end
end

#run_setup(config) ⇒ Thread

Configure using custom configuration JSON within config directory of current test

Parameters:

  • config (String, Symbol)

    name of configuration file without json extension

Returns:

  • (Thread)

    thread with running source



56
57
58
59
60
61
62
63
64
65
# File 'lib/jackal/utils/spec/helpers.rb', line 56

def run_setup(config)
  path = File.join(Dir.pwd, 'test/specs/config', "#{config}.json")
  Carnivore::Config.configure(:config_path => path)
  Thread.abort_on_exception = true
  runner = Thread.new do
    require 'jackal/loader'
  end
  source_wait(:setup)
  runner
end