jackal 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/jackal/utils/payload.rb +2 -1
- data/lib/jackal/utils/spec.rb +21 -0
- data/lib/jackal/utils/spec/callback_local.rb +10 -0
- data/lib/jackal/utils/spec/helpers.rb +18 -2
- data/lib/jackal/version.rb +2 -3
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/lib/jackal/utils/payload.rb
CHANGED
@@ -10,8 +10,9 @@ module Jackal
|
|
10
10
|
#
|
11
11
|
# @param name [String]
|
12
12
|
# @param payload [Hash]
|
13
|
+
# @param args [Object] extra arguments
|
13
14
|
# @return [Smash]
|
14
|
-
def new_payload(name, payload)
|
15
|
+
def new_payload(name, payload, *args)
|
15
16
|
Smash.new(
|
16
17
|
:name => name,
|
17
18
|
:id => Celluloid.uuid,
|
data/lib/jackal/utils/spec.rb
CHANGED
@@ -5,6 +5,27 @@ module Jackal
|
|
5
5
|
# Testing helpers
|
6
6
|
module Spec
|
7
7
|
autoload :CallbackLocal, 'jackal/utils/spec/callback_local'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
# Valid directories for test payloads
|
12
|
+
#
|
13
|
+
# @param args [String] list of directories to append
|
14
|
+
# @return [Array<String>]
|
15
|
+
def payload_storage(*args)
|
16
|
+
unless(@_payload_dirs)
|
17
|
+
@_payload_dirs = []
|
18
|
+
end
|
19
|
+
unless(args.empty?)
|
20
|
+
@_payload_dirs += args.find_all do |dir_path|
|
21
|
+
File.directory?(dir_path)
|
22
|
+
end
|
23
|
+
@_payload_dirs.uniq!
|
24
|
+
end
|
25
|
+
@_payload_dirs
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
8
29
|
end
|
9
30
|
end
|
10
31
|
end
|
@@ -18,6 +18,16 @@ module Jackal
|
|
18
18
|
@forwarded << payload
|
19
19
|
end
|
20
20
|
|
21
|
+
class << self
|
22
|
+
# Init data store for internal message capture
|
23
|
+
def extended(klass)
|
24
|
+
klass.instance_eval do
|
25
|
+
@forwarded = []
|
26
|
+
end
|
27
|
+
end
|
28
|
+
alias_method :included, :extended
|
29
|
+
end
|
30
|
+
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
@@ -16,9 +16,19 @@ ENV.each do |key, value|
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
# Fetch test payload and create new payload
|
20
|
+
#
|
21
|
+
# @param style [String, Symbol] name of payload
|
22
|
+
# @param args [Hash]
|
23
|
+
# @option args [TrueClass, FalseClass] :raw return loaded payload only
|
24
|
+
# @option args [String, Symbol] :nest place loaded payload within key namespace in hash
|
25
|
+
# @return [Hash] new payload
|
26
|
+
# @note `style` is name of test payload without .json extension. Will
|
27
|
+
# search 'test/specs/payload' from CWD first, then fallback to
|
28
|
+
# 'payloads' directory within the directory of this file
|
19
29
|
def payload_for(style, args={})
|
20
30
|
file = "#{style}.json"
|
21
|
-
path = [File.join(Dir.pwd, 'test/specs/payloads'),
|
31
|
+
path = [File.join(Dir.pwd, 'test/specs/payloads'), Jackal::Utils::Spec.payload_storage].flatten.compact.map do |dir|
|
22
32
|
if(File.exists?(full_path = File.join(dir, file)))
|
23
33
|
full_path
|
24
34
|
end
|
@@ -34,13 +44,19 @@ def payload_for(style, args={})
|
|
34
44
|
end
|
35
45
|
end
|
36
46
|
else
|
37
|
-
raise "Requested payload path for test does not exist: #{File.expand_path(path)}"
|
47
|
+
raise "Requested payload path for test does not exist: #{path ? File.expand_path(path) : 'no path discovered'}"
|
38
48
|
end
|
39
49
|
end
|
40
50
|
|
51
|
+
# Configure using custom configuration JSON within config
|
52
|
+
# directory of current test
|
53
|
+
#
|
54
|
+
# @param config [String, Symbol] name of configuration file without json extension
|
55
|
+
# @return [Thread] thread with running source
|
41
56
|
def run_setup(config)
|
42
57
|
path = File.join(Dir.pwd, 'test/specs/config', "#{config}.json")
|
43
58
|
Carnivore::Config.configure(:config_path => path)
|
59
|
+
Thread.abort_on_exception = true
|
44
60
|
runner = Thread.new do
|
45
61
|
require 'jackal/loader'
|
46
62
|
end
|
data/lib/jackal/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: carnivore
|