Top Level Namespace

Includes:
Jackal::Utils::Config, Jackal::Utils::Payload

Defined Under Namespace

Modules: Jackal

Instance Method Summary (collapse)

Instance Method Details

- (Hash) config Originally defined in module Jackal::Utils::Config

Returns configuration

Returns:

  • (Hash)

    configuration

- (Array) config_path(class_name = self.class.name) Originally defined in module Jackal::Utils::Config

Returns key path in configuration

Returns:

  • (Array)

    key path in configuration

- (Symbol) destination(direction = :output) Originally defined in module Jackal::Utils::Config

Generation destination key based on direction

Parameters:

  • direction (Symbol, String) (defaults to: :output)

Returns:

  • (Symbol)

- (Smash) new_payload(name, payload, *args) Originally defined in module Jackal::Utils::Payload

Generate a new payload

Parameters:

  • name (String)
  • payload (Hash)
  • args (Object)

    extra arguments

Returns:

  • (Smash)

- (Hash) payload_for(style, args = {})

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

- (Thread) run_setup(config)

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

- (String) source_prefix Originally defined in module Jackal::Utils::Config

Returns prefix of source for this callback

Returns:

  • (String)

    prefix of source for this callback

- (Smash) unpack(message) Originally defined in module Jackal::Utils::Payload

Extract payload from message

Parameters:

  • message (Carnivore::Message)

Returns:

  • (Smash)