liedetector 0.2.2 → 0.2.5
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/README.md +46 -0
- data/lib/liedetector/suite.rb +11 -9
- data/lib/liedetector/version.rb +1 -1
- data/spec/liedetector_spec.rb +2 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d84111e812b82ef363c85d668e92616882f427de
|
4
|
+
data.tar.gz: 85b6313e88873a8d3d6c612b3ee196129298337a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: befffc92abd9982fd475aadfdfafa9820d165edcb1685c802b437a01670a8e1be840a168e1b1cecb26e103186d5f7eeb03eba6fa5838026f2ef19889996a70e9
|
7
|
+
data.tar.gz: c0a41b51b26680ec9fad5a368e3b45728fa2a5dc6d4d065eff3950faf2cdd40d29fe6031b808bafb3a4a893185f8472928cdbc809634cf92f21ca89efad01987
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
LieDetector
|
2
|
+
===========
|
3
|
+
|
4
|
+
I created this gem to keep API description and actual API in sync. You write markdown document
|
5
|
+
with data structures and request descriptions, and then you can check it against real server
|
6
|
+
to check that description is really describe this server API.
|
7
|
+
|
8
|
+
All requests executed one by one, and if any of them fail we stop checking.
|
9
|
+
|
10
|
+
So, take a look at some example - current document describe a bit of GitHub API.
|
11
|
+
|
12
|
+
GitHub API Check
|
13
|
+
----------------
|
14
|
+
|
15
|
+
As you know github has public API. API you can call without authentification.
|
16
|
+
Set API host:
|
17
|
+
|
18
|
+
self.http_defaults = {host: 'api.github.com', scheme: 'https', port: 443}
|
19
|
+
|
20
|
+
With Trafaret library we can define data types to check API results:
|
21
|
+
|
22
|
+
Repo = T.construct({
|
23
|
+
id: :integer,
|
24
|
+
name: :string,
|
25
|
+
full_name: :string,
|
26
|
+
# ... hundred of other fields, tired to define them
|
27
|
+
owner: {url: :uri}
|
28
|
+
})
|
29
|
+
|
30
|
+
So now we can get info about liedetector repo, store it, and then use it for next queries:
|
31
|
+
|
32
|
+
request :repo_info, :get, '/repos/Deepwalker/liedetector' do
|
33
|
+
status 200
|
34
|
+
await Repo
|
35
|
+
store :repo # we store API call result for later
|
36
|
+
end
|
37
|
+
|
38
|
+
Now we have repo info, and URI for it owner. Lets check this URI:
|
39
|
+
|
40
|
+
request :repo_owner, :get, proc { URI.parse(store[:repo][:owner][:url]).path } do
|
41
|
+
status 200
|
42
|
+
await :any
|
43
|
+
end
|
44
|
+
|
45
|
+
You can put proc {} in place of method, path, status, data, query and headers request args. As you see
|
46
|
+
request get name, method and path, and then with block you fill other parameters.
|
data/lib/liedetector/suite.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
module LieDetector
|
2
2
|
class Suite
|
3
|
-
|
4
|
-
HTTP_DEFAULTS = {host: '127.0.0.1', port: 3000}
|
5
|
-
|
6
|
-
attr_accessor :http_defaults
|
7
|
-
|
8
|
-
def headers_defaults
|
9
|
-
HEADERS_DEFAULTS
|
10
|
-
end
|
3
|
+
attr_accessor :http_defaults, :headers_defaults
|
11
4
|
|
12
5
|
def initialize(filepath)
|
13
6
|
@filepath = filepath
|
7
|
+
self.headers_defaults = {'Accept' => 'application/json'}
|
8
|
+
self.http_defaults = {host: '127.0.0.1', port: 3000}
|
14
9
|
end
|
15
10
|
|
16
11
|
def build_uri(path, query: nil, fragment: nil)
|
17
12
|
query = URI.encode_www_form(query) if query.is_a? Hash
|
18
|
-
|
13
|
+
scheme = http_defaults[:scheme] || 'http'
|
14
|
+
if scheme == 'http'
|
15
|
+
URI::HTTP
|
16
|
+
elsif scheme == 'https'
|
17
|
+
URI::HTTPS
|
18
|
+
else
|
19
|
+
raise 'Bad configuration'
|
20
|
+
end.build(http_defaults.merge(path: path, query: query, fragment: fragment)).to_s
|
19
21
|
end
|
20
22
|
|
21
23
|
def session
|
data/lib/liedetector/version.rb
CHANGED
data/spec/liedetector_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liedetector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikhail Krivushin
|
@@ -134,6 +134,7 @@ extra_rdoc_files: []
|
|
134
134
|
files:
|
135
135
|
- Gemfile
|
136
136
|
- Gemfile.lock
|
137
|
+
- README.md
|
137
138
|
- Rakefile
|
138
139
|
- bin/liedetector
|
139
140
|
- lib/liedetector.rb
|