api_pi 0.2.3 → 0.9.3
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 +5 -5
- data/.github/workflows/tests.yml +38 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +26 -12
- data/README.md +7 -9
- data/api_pi.gemspec +7 -6
- data/example/example.json +12 -0
- data/example/example.rb +39 -0
- data/lib/api_pi/assertion.rb +15 -15
- data/lib/api_pi/dsl.rb +6 -6
- data/lib/api_pi/request.rb +4 -2
- data/lib/api_pi/version.rb +1 -1
- data/lib/api_pi.rb +1 -1
- data/logo/pi-logo.jpg +0 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/test_assertions.rb +5 -5
- data/test/unit/test_dsl.rb +1 -1
- metadata +43 -27
- data/example/apiary.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ffac63a3f0f7ce1538044fa5336546effe59dc64b0a16a528761c80a740123c0
|
4
|
+
data.tar.gz: 146038c0ac9dd68fef685101c02370ab251cb7d77e3b2ab30af0a8013ba4a14d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc1440f2f95e199ac892dcd5a1ccfac5075fccdbb0043dcdccb982bb183ace03dcde7c515d0a79cea21aad942405f0982cf07faecd50173c603172c01cf36c1b
|
7
|
+
data.tar.gz: 1b733e4953891974bcff398e7c7bb7b0d7346f64beb91f42861a5fa245a9893033f01c3db6386ecdbf54dc955a88883495a8f0a26d0c35d21864ea6be97e62d9
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Tests
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "main" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "main" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['3.0']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v4
|
29
|
+
- name: Set up Ruby
|
30
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
+
# uses: ruby/setup-ruby@v1
|
33
|
+
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.3.4
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
api_pi (0.
|
5
|
-
map (~> 6.
|
4
|
+
api_pi (0.9.3)
|
5
|
+
map (~> 6.6)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
addressable (2.8.7)
|
11
|
+
public_suffix (>= 2.0.2, < 7.0)
|
12
|
+
bigdecimal (3.1.8)
|
13
|
+
crack (1.0.0)
|
14
|
+
bigdecimal
|
15
|
+
rexml
|
16
|
+
hashdiff (1.1.0)
|
17
|
+
map (6.6.0)
|
18
|
+
minitest (5.24.1)
|
19
|
+
public_suffix (6.0.0)
|
20
|
+
rake (13.2.1)
|
21
|
+
rexml (3.3.1)
|
22
|
+
strscan
|
23
|
+
strscan (3.1.0)
|
24
|
+
webmock (3.23.1)
|
25
|
+
addressable (>= 2.8.0)
|
18
26
|
crack (>= 0.3.2)
|
27
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
19
28
|
|
20
29
|
PLATFORMS
|
21
30
|
ruby
|
31
|
+
x86_64-darwin-21
|
22
32
|
|
23
33
|
DEPENDENCIES
|
24
34
|
api_pi!
|
25
|
-
|
26
|
-
|
35
|
+
minitest (~> 5.24.1)
|
36
|
+
rake (~> 13.2.1)
|
37
|
+
webmock (~> 3.23.1)
|
38
|
+
|
39
|
+
BUNDLED WITH
|
40
|
+
2.5.15
|
data/README.md
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
# API P.I.
|
2
|
+

|
2
3
|
|
3
|
-
A ruby DSL to
|
4
|
-
|
5
|
-
|
4
|
+
A ruby DSL to investigate and test JSON contracts.
|
5
|
+
----------
|
6
|
+
[](https://github.com/benwoody/api_pi/actions/workflows/tests.yml)
|
6
7
|
|
7
8
|
## Install
|
8
9
|
|
9
|
-
Api P.I. requires ruby 2.0.0+
|
10
|
-
|
11
10
|
Install the gem:
|
12
11
|
|
13
12
|
$ gem install api_pi
|
14
|
-
|
13
|
+
|
15
14
|
## Usage
|
16
15
|
|
17
16
|
### GETting Data
|
@@ -59,7 +58,7 @@ Header fields can be queried using the following format:
|
|
59
58
|
`response.header` is required in order to use dot notation on header fields.
|
60
59
|
|
61
60
|
Example:
|
62
|
-
|
61
|
+
|
63
62
|
response.header.connection.is 'keep-alive'
|
64
63
|
response.header.contenttype.is 'application/json'
|
65
64
|
|
@@ -132,7 +131,7 @@ This goes through the array and tests every item in it!
|
|
132
131
|
"this".is "that" => false
|
133
132
|
|
134
133
|
### is_a, is_an
|
135
|
-
|
134
|
+
|
136
135
|
The `is_a` and `is_an` assertions are used to assert Type on a field:
|
137
136
|
|
138
137
|
"Hello, World!".is_a String => true
|
@@ -212,4 +211,3 @@ To-Do
|
|
212
211
|
-----
|
213
212
|
|
214
213
|
* Ability to basic_auth before GET request
|
215
|
-
|
data/api_pi.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |g|
|
|
7
7
|
g.version = ApiPi::VERSION
|
8
8
|
|
9
9
|
g.summary = "API validation DSL"
|
10
|
-
g.description = "A ruby DSL to validate API requests."
|
10
|
+
g.description = "A ruby DSL to investigate and validate API requests."
|
11
11
|
|
12
12
|
g.authors = "Ben Woodall"
|
13
13
|
g.email = "mail@benwoodall.com"
|
@@ -16,9 +16,10 @@ Gem::Specification.new do |g|
|
|
16
16
|
g.test_files = `git ls-files -- test/*`.split("\n")
|
17
17
|
|
18
18
|
g.extra_rdoc_files = ["README.md"]
|
19
|
-
g.required_ruby_version = '>=
|
20
|
-
|
21
|
-
g.add_dependency 'map', '~> 6.
|
22
|
-
g.add_development_dependency '
|
23
|
-
g.add_development_dependency '
|
19
|
+
g.required_ruby_version = '>= 3.0'
|
20
|
+
|
21
|
+
g.add_dependency 'map', '~> 6.6'
|
22
|
+
g.add_development_dependency 'minitest', '~>5.24.1'
|
23
|
+
g.add_development_dependency 'webmock', '~> 3.23.1'
|
24
|
+
g.add_development_dependency 'rake', '~> 13.2.1'
|
24
25
|
end
|
data/example/example.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'api_pi'
|
2
|
+
|
3
|
+
set_header "api-pi-demo-header", "api-pi-example"
|
4
|
+
|
5
|
+
get "https://raw.githubusercontent.com/benwoody/api_pi/master/example/example.json" do
|
6
|
+
|
7
|
+
test "headers" do
|
8
|
+
response.code.is 200
|
9
|
+
response.header.has_key "contenttype"
|
10
|
+
end
|
11
|
+
|
12
|
+
test "metadata" do
|
13
|
+
response.body.results.is_a Hash
|
14
|
+
response.body.metadata.has_keys "totalCount", "totalPageCount"
|
15
|
+
response.body.metadata.totalCount.is_a Integer
|
16
|
+
response.body.metadata.totalPageCount.is_a Integer
|
17
|
+
end
|
18
|
+
|
19
|
+
test "results" do
|
20
|
+
response.body.results.is_a Hash
|
21
|
+
response.body.results.has_key "string"
|
22
|
+
response.body.results.lacks_key "nope"
|
23
|
+
response.body.results.has_keys "string", "int", "here", "array"
|
24
|
+
end
|
25
|
+
|
26
|
+
test "results.string" do
|
27
|
+
response.body.results.string.is_a String
|
28
|
+
response.body.results.string.matches /\w*/
|
29
|
+
end
|
30
|
+
|
31
|
+
test "results.int" do
|
32
|
+
response.body.results.int.is_an Integer
|
33
|
+
end
|
34
|
+
|
35
|
+
test "results.array" do
|
36
|
+
response.body.results.array.is_an Array
|
37
|
+
response.body.results.array.includes 3
|
38
|
+
end
|
39
|
+
end
|
data/lib/api_pi/assertion.rb
CHANGED
@@ -15,13 +15,13 @@ class Object
|
|
15
15
|
end
|
16
16
|
true
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
# `is` assertions are used to compare exact values.
|
20
|
-
#
|
20
|
+
#
|
21
21
|
# "this".is "this" => true
|
22
22
|
# 200.is "200" => true
|
23
23
|
# "this".is "that" => false
|
24
|
-
|
24
|
+
|
25
25
|
def is this
|
26
26
|
msg = "#{self} is not #{this}"
|
27
27
|
if this.is_a? Integer
|
@@ -32,29 +32,29 @@ class Object
|
|
32
32
|
end
|
33
33
|
|
34
34
|
# The `is_a` and `is_an` assertions are used to assert Type on a field:
|
35
|
-
#
|
35
|
+
#
|
36
36
|
# "Hello, World!".is_a String => true
|
37
37
|
# 3.14159265359.is_a Float => true
|
38
38
|
# "Not an array!".is_an Array => false
|
39
|
-
|
39
|
+
|
40
40
|
def is_a klass
|
41
41
|
msg = "#{self} is not a #{klass}"
|
42
|
-
check_if self.is_a?(klass), msg
|
42
|
+
check_if self.is_a?(klass), msg
|
43
43
|
end
|
44
44
|
alias :is_an :is_a
|
45
45
|
|
46
46
|
# The `has_key` assertion can be used to query if a certain
|
47
47
|
# field is present in a JSON block:
|
48
|
-
#
|
48
|
+
#
|
49
49
|
# { "here": "present!" }.has_key "here" => true
|
50
50
|
# { "here": "present!" }.has_key "nope!" => false
|
51
|
-
|
51
|
+
|
52
52
|
def has_key kkey
|
53
53
|
msg = "#{kkey} was not found in #{self.keys.join(', ')}}"
|
54
54
|
check_if self.respond_to?(kkey), msg
|
55
55
|
end
|
56
56
|
|
57
|
-
# The `has_keys` assertion works the same as `has_key`, except it takes
|
57
|
+
# The `has_keys` assertion works the same as `has_key`, except it takes
|
58
58
|
# multiple keys and tests them all at once:
|
59
59
|
#
|
60
60
|
# { "here": "present!", "hello": "world!" }.has_keys "here","hello" => true
|
@@ -71,7 +71,7 @@ class Object
|
|
71
71
|
true
|
72
72
|
else
|
73
73
|
nf = not_found.join(", ")
|
74
|
-
msg = "#{nf} were not found in #{self.keys.join(', ')}"
|
74
|
+
msg = "#{nf} were not found in #{self.keys.join(', ')}"
|
75
75
|
raise ApiPi::AssertionError, msg
|
76
76
|
end
|
77
77
|
end
|
@@ -88,7 +88,7 @@ class Object
|
|
88
88
|
end
|
89
89
|
|
90
90
|
# `matches` expectes a Regex formed value.
|
91
|
-
#
|
91
|
+
#
|
92
92
|
# "hello".matches /ll/ => true
|
93
93
|
|
94
94
|
def matches regex
|
@@ -97,7 +97,7 @@ class Object
|
|
97
97
|
end
|
98
98
|
|
99
99
|
# `includes` can be used for array to query if specific values are present:
|
100
|
-
#
|
100
|
+
#
|
101
101
|
# [1,2,3,4].includes 2 => true
|
102
102
|
|
103
103
|
def includes item
|
@@ -106,7 +106,7 @@ class Object
|
|
106
106
|
end
|
107
107
|
|
108
108
|
# `not_nil?` checks to see if the value is nil:
|
109
|
-
#
|
109
|
+
#
|
110
110
|
# nil.not_nil? => false
|
111
111
|
# "something".not_nil? => true
|
112
112
|
|
@@ -116,10 +116,10 @@ class Object
|
|
116
116
|
end
|
117
117
|
|
118
118
|
# `stripped?` will test is there is whitespace before or after a string:
|
119
|
-
#
|
119
|
+
#
|
120
120
|
# "works".stripped? => true
|
121
121
|
# " spaces ".stripped? => false
|
122
|
-
|
122
|
+
|
123
123
|
def stripped?
|
124
124
|
msg = "#{self} contains whitespace"
|
125
125
|
check_if(self.strip == self, msg)
|
data/lib/api_pi/dsl.rb
CHANGED
@@ -16,19 +16,19 @@ module ApiPi
|
|
16
16
|
pi.investigate
|
17
17
|
end
|
18
18
|
|
19
|
-
# Test blocks are used to group similar assertions into readable units.
|
20
|
-
#
|
19
|
+
# Test blocks are used to group similar assertions into readable units.
|
20
|
+
#
|
21
21
|
# For example, you may want to put your header tests into one test block:
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# get 'example.com/user.json' do
|
24
24
|
# test 'Headers have correct data' do
|
25
25
|
# # You header assertions...
|
26
26
|
# end
|
27
27
|
# end
|
28
|
-
#
|
28
|
+
#
|
29
29
|
# Inside of the test block, you would then put your header assertions.
|
30
|
-
# onceyou run your tests, your test blocks are grouped together and
|
31
|
-
# pass/fail based on
|
30
|
+
# onceyou run your tests, your test blocks are grouped together and
|
31
|
+
# pass/fail based on assertions in the test block.
|
32
32
|
|
33
33
|
def test desc, &block
|
34
34
|
@tests[desc] = block
|
data/lib/api_pi/request.rb
CHANGED
@@ -9,7 +9,9 @@ module Kernel
|
|
9
9
|
uri = URI.parse url
|
10
10
|
get = Net::HTTP::Get.new(uri)
|
11
11
|
req = Net::HTTPHeader.build_headers get
|
12
|
-
|
12
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
13
|
+
http.use_ssl = (uri.scheme == 'https')
|
14
|
+
resp = http.request req
|
13
15
|
json = net_parse resp
|
14
16
|
ApiPi::Dsl.new(json).parse(url, block)
|
15
17
|
end
|
@@ -21,7 +23,7 @@ module Kernel
|
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
24
|
-
|
26
|
+
|
25
27
|
# Groups all of the response parsing
|
26
28
|
|
27
29
|
def net_parse response
|
data/lib/api_pi/version.rb
CHANGED
data/lib/api_pi.rb
CHANGED
data/logo/pi-logo.jpg
ADDED
Binary file
|
data/test/test_helper.rb
CHANGED
@@ -2,10 +2,10 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module ApiPi
|
4
4
|
class TestAssertions < TestCase
|
5
|
-
|
5
|
+
|
6
6
|
def test_patch_methods
|
7
7
|
assert Object.respond_to?(:check_if), Object.check_if(true, "Yep")
|
8
|
-
assert Object.respond_to?(:is), Object.is(Object)
|
8
|
+
assert Object.respond_to?(:is), Object.is(Object)
|
9
9
|
assert Object.respond_to?(:is_a), @map.k.is_a(String)
|
10
10
|
assert Object.respond_to?(:is_an), Object.is_an(Object)
|
11
11
|
assert Object.respond_to?(:has_key), @map.has_key(:k)
|
@@ -38,7 +38,7 @@ module ApiPi
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_is_a__with_true
|
41
|
-
assert "string".is_a(String)
|
41
|
+
assert "string".is_a(String)
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_is_a__with_false
|
@@ -58,7 +58,7 @@ module ApiPi
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_has_keys__with_false
|
61
|
-
assert_raises(ApiPi::AssertionError) { @map.has_keys(:n,:r) }
|
61
|
+
assert_raises(ApiPi::AssertionError) { @map.has_keys(:n,:r) }
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_lacks_key__with_true
|
@@ -95,7 +95,7 @@ module ApiPi
|
|
95
95
|
|
96
96
|
def test_stripped?
|
97
97
|
assert "stripped".stripped?
|
98
|
-
assert_raises(ApiPi::AssertionError) { " not_stripped ".
|
98
|
+
assert_raises(ApiPi::AssertionError) { " not_stripped ".stripped? }
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
data/test/unit/test_dsl.rb
CHANGED
metadata
CHANGED
@@ -1,103 +1,119 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_pi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Woodall
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: map
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
19
|
+
version: '6.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '6.
|
26
|
+
version: '6.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 5.24.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 5.24.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: webmock
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - ~>
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
47
|
+
version: 3.23.1
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - ~>
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: 3.23.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - ~>
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 13.2.1
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - ~>
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
description: A ruby DSL to validate API requests.
|
68
|
+
version: 13.2.1
|
69
|
+
description: A ruby DSL to investigate and validate API requests.
|
56
70
|
email: mail@benwoodall.com
|
57
71
|
executables: []
|
58
72
|
extensions: []
|
59
73
|
extra_rdoc_files:
|
60
74
|
- README.md
|
61
75
|
files:
|
62
|
-
- .
|
63
|
-
- .
|
76
|
+
- ".github/workflows/tests.yml"
|
77
|
+
- ".gitignore"
|
78
|
+
- ".ruby-version"
|
64
79
|
- Gemfile
|
65
80
|
- Gemfile.lock
|
66
81
|
- README.md
|
67
82
|
- Rakefile
|
68
83
|
- api_pi.gemspec
|
69
|
-
- example/
|
84
|
+
- example/example.json
|
85
|
+
- example/example.rb
|
70
86
|
- lib/api_pi.rb
|
71
87
|
- lib/api_pi/assertion.rb
|
72
88
|
- lib/api_pi/case.rb
|
73
89
|
- lib/api_pi/dsl.rb
|
74
90
|
- lib/api_pi/request.rb
|
75
91
|
- lib/api_pi/version.rb
|
92
|
+
- logo/pi-logo.jpg
|
76
93
|
- test/test_helper.rb
|
77
94
|
- test/unit/test_assertions.rb
|
78
95
|
- test/unit/test_dsl.rb
|
79
96
|
- test/unit/test_requests.rb
|
80
|
-
homepage:
|
97
|
+
homepage:
|
81
98
|
licenses: []
|
82
99
|
metadata: {}
|
83
|
-
post_install_message:
|
100
|
+
post_install_message:
|
84
101
|
rdoc_options: []
|
85
102
|
require_paths:
|
86
103
|
- lib
|
87
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
105
|
requirements:
|
89
|
-
- -
|
106
|
+
- - ">="
|
90
107
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
108
|
+
version: '3.0'
|
92
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
110
|
requirements:
|
94
|
-
- -
|
111
|
+
- - ">="
|
95
112
|
- !ruby/object:Gem::Version
|
96
113
|
version: '0'
|
97
114
|
requirements: []
|
98
|
-
|
99
|
-
|
100
|
-
signing_key:
|
115
|
+
rubygems_version: 3.5.11
|
116
|
+
signing_key:
|
101
117
|
specification_version: 4
|
102
118
|
summary: API validation DSL
|
103
119
|
test_files:
|
data/example/apiary.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'api_pi'
|
2
|
-
|
3
|
-
set_header "api-pi-demo-header", "api-pi-example"
|
4
|
-
|
5
|
-
get "http://apipi.apiary.io/tests" do
|
6
|
-
|
7
|
-
test "headers" do
|
8
|
-
response.header.contenttype.is "application/json"
|
9
|
-
response.code.is 200
|
10
|
-
end
|
11
|
-
|
12
|
-
test "body results.string" do
|
13
|
-
response.body.results.string.is_a String
|
14
|
-
response.body.results.string.matches /\w*/
|
15
|
-
end
|
16
|
-
|
17
|
-
test "results.int" do
|
18
|
-
response.body.results.int.is_an Integer
|
19
|
-
end
|
20
|
-
|
21
|
-
test "results" do
|
22
|
-
response.body.results.has_key "string"
|
23
|
-
response.body.results.lacks_key "nope"
|
24
|
-
response.body.results.has_keys "string","int","here","array"
|
25
|
-
end
|
26
|
-
|
27
|
-
test "results.array" do
|
28
|
-
response.body.results.array.includes 4
|
29
|
-
end
|
30
|
-
end
|