Top Level Namespace
- Includes:
- Jackal::Utils::Config, Jackal::Utils::Payload
Defined Under Namespace
Modules: Jackal
Instance Method Summary collapse
-
#payload_for(style, args = {}) ⇒ Hash
Fetch test payload and create new payload.
-
#run_setup(config) ⇒ Thread
Configure using custom configuration JSON within config directory of current test.
Methods included from Jackal::Utils::Config
#config, #config_path, #destination, #source_prefix
Methods included from Jackal::Utils::Payload
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
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.(path) : 'no path discovered'}" end end |
#run_setup(config) ⇒ Thread
Configure using custom configuration JSON within config directory of current test
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 |