liedetector 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/liedetector/request.rb +23 -36
- data/lib/liedetector/suite.rb +2 -0
- data/lib/liedetector/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa03058163399affa0461be6673a9d3e5a12c890
|
4
|
+
data.tar.gz: 1c53a79fe362a04d08772d26bc805877c9b2e098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20a421fc36dbd658fc3d6dbed033d94e32c3a8e5fd8f1ae71bab8e42304636698037baec78522f5c8dcfc6bcb78bd548eb1b26443f5f9b8953361cc8466018af
|
7
|
+
data.tar.gz: 5d19b4011700ddd9b7482a5b1164929d64846d2c666e8cef031f92203039cd5eadd76da67b88f1de953d83f5d718e486a3b1ae95f9657bca6d3d757bc2e9f17a
|
data/Gemfile.lock
CHANGED
data/lib/liedetector/request.rb
CHANGED
@@ -4,40 +4,27 @@ module LieDetector
|
|
4
4
|
@suite = suite
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def path(path)
|
12
|
-
@path = path
|
13
|
-
end
|
14
|
-
|
15
|
-
def data(data)
|
16
|
-
@data = data
|
17
|
-
end
|
18
|
-
|
19
|
-
def query(query)
|
20
|
-
@query = query
|
21
|
-
end
|
7
|
+
%w{method path data query headers status description}.each do |name|
|
8
|
+
define_method name do |arg|
|
9
|
+
self.instance_variable_set("@#{name}", arg)
|
10
|
+
end
|
22
11
|
|
23
|
-
|
24
|
-
|
12
|
+
define_method "get_#{name}" do
|
13
|
+
data = self.instance_variable_get("@#{name}")
|
14
|
+
if data.is_a? Proc
|
15
|
+
@suite.instance_eval &data
|
16
|
+
else
|
17
|
+
data
|
18
|
+
end
|
19
|
+
end
|
25
20
|
end
|
26
21
|
|
27
22
|
def await(trafaret)
|
28
23
|
@trafaret = T.construct(trafaret)
|
29
24
|
end
|
30
25
|
|
31
|
-
def description(description)
|
32
|
-
@description = description
|
33
|
-
end
|
34
|
-
|
35
26
|
def describe
|
36
|
-
"#{@description}\nExecute #{@method.to_s.upcase} #{
|
37
|
-
end
|
38
|
-
|
39
|
-
def status(status)
|
40
|
-
@status = status
|
27
|
+
"#{@description}\nExecute #{@method.to_s.upcase} #{get_path}\n"
|
41
28
|
end
|
42
29
|
|
43
30
|
def store(name)
|
@@ -46,21 +33,21 @@ module LieDetector
|
|
46
33
|
|
47
34
|
def call
|
48
35
|
res = @suite.session.send(
|
49
|
-
|
50
|
-
@suite.build_uri(
|
36
|
+
get_method,
|
37
|
+
@suite.build_uri(get_path, query: get_query),
|
51
38
|
{
|
52
|
-
data:
|
53
|
-
header: @suite.headers_defaults.merge(
|
39
|
+
data: get_data,
|
40
|
+
header: @suite.headers_defaults.merge(get_headers || {})
|
54
41
|
}
|
55
42
|
)
|
56
|
-
unless res.status ==
|
57
|
-
raise "Bad status(#{
|
43
|
+
unless res.status == get_status
|
44
|
+
raise "Bad status(#{get_status} != #{res.status}): #{res.inspect}"
|
58
45
|
end
|
59
|
-
|
60
|
-
if
|
61
|
-
raise "Unmatched data #{
|
46
|
+
check = @trafaret.call(Oj.load(res.content))
|
47
|
+
if check.is_a? Trafaret::Error
|
48
|
+
raise "Unmatched data #{check.dump} #{res.content}"
|
62
49
|
end
|
63
|
-
@suite.store_key(@store_key,
|
50
|
+
@suite.store_key(@store_key, check) if @store_key
|
64
51
|
end
|
65
52
|
end
|
66
53
|
end
|
data/lib/liedetector/suite.rb
CHANGED
data/lib/liedetector/version.rb
CHANGED