oncall 0.2.0 → 0.2.1
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/lib/oncall/commands/shell_command.rb +9 -0
- data/lib/oncall/core/assertion.rb +15 -2
- data/lib/oncall/core/config.rb +8 -0
- data/lib/oncall/core/reporter.rb +8 -5
- data/lib/oncall/core/scenario.rb +7 -3
- data/lib/oncall/dsl.rb +1 -29
- data/lib/oncall/version.rb +1 -1
- metadata +1 -2
- data/lib/oncall/dsl/response.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '07378ff6344fb59c22ac6927c7aeac9cfecabf1504e0bfcbb02871668c04c189'
|
4
|
+
data.tar.gz: f2c98df8c24c08648db1dcff593b68c7bbd2517afae9e090a5728cbe5cca1b24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee21dc544043fed09ad3a1cb6f2e5f9a223aab9e8cddd685dbe95710cf5d04c06735654af782a9128bcff24c9f59010ef31834f26ae7b90134f1f7de0cb6368f
|
7
|
+
data.tar.gz: e6290f30cbac7835eabae316ff9b82bb5a075d5d6cf7691cfb7be00840e1b89232896538f8d2f99b86482b3dbedcb25252e3c9932f17d5b649353fc19f4e988b
|
@@ -1,7 +1,16 @@
|
|
1
|
+
require 'readline'
|
2
|
+
|
1
3
|
module Oncall
|
2
4
|
module Commands
|
3
5
|
class ShellCommand
|
4
6
|
def self.invoke(args)
|
7
|
+
while input = Readline.readline("> ", true)
|
8
|
+
break if input == "exit"
|
9
|
+
|
10
|
+
# Remove blank lines from history
|
11
|
+
Readline::HISTORY.pop if input == ""
|
12
|
+
system(input)
|
13
|
+
end
|
5
14
|
end
|
6
15
|
end
|
7
16
|
end
|
@@ -1,14 +1,27 @@
|
|
1
1
|
module Oncall
|
2
2
|
module Core
|
3
3
|
class Assertion
|
4
|
-
def initialize(response)
|
4
|
+
def initialize(response, method, path)
|
5
5
|
@reporter = Oncall::Core.reporter
|
6
6
|
@response = response
|
7
|
+
@method = method
|
8
|
+
@path = path
|
7
9
|
end
|
8
10
|
|
9
11
|
def status(expected)
|
10
12
|
result = @response.code == expected.to_s
|
11
|
-
|
13
|
+
|
14
|
+
message = "#{@method} #{@path}\nexpected: #{expected}\nactual: #{@response.code}"
|
15
|
+
|
16
|
+
@reporter.report_status(result, message)
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate(expected)
|
20
|
+
result = JSON::Validator.validate(expected, @response.body)
|
21
|
+
|
22
|
+
message = "#{@method} #{@path}\nexpected: #{expected}\nactual: #{@response.body}"
|
23
|
+
|
24
|
+
@reporter.report_status(result, message)
|
12
25
|
end
|
13
26
|
end
|
14
27
|
end
|
data/lib/oncall/core/config.rb
CHANGED
data/lib/oncall/core/reporter.rb
CHANGED
@@ -7,6 +7,8 @@ module Oncall
|
|
7
7
|
success: 0,
|
8
8
|
empty: 0
|
9
9
|
}
|
10
|
+
|
11
|
+
@messages = []
|
10
12
|
end
|
11
13
|
|
12
14
|
def report(tests)
|
@@ -18,12 +20,12 @@ module Oncall
|
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
def start
|
22
|
-
end
|
23
|
+
def start; end
|
23
24
|
|
24
25
|
def finish
|
25
|
-
puts "\n"
|
26
|
-
puts
|
26
|
+
puts "\n\n"
|
27
|
+
puts @messages
|
28
|
+
puts "\n#{@results[:success]} passed, #{@results[:failure]} failed."
|
27
29
|
end
|
28
30
|
|
29
31
|
def success?
|
@@ -35,13 +37,14 @@ module Oncall
|
|
35
37
|
@results[:empty] = @results[:empty] + 1
|
36
38
|
end
|
37
39
|
|
38
|
-
def report_status(result)
|
40
|
+
def report_status(result, message)
|
39
41
|
if result
|
40
42
|
print '.'
|
41
43
|
@results[:success] = @results[:success] + 1
|
42
44
|
else
|
43
45
|
print 'F'
|
44
46
|
@results[:failure] = @results[:failure] + 1
|
47
|
+
@messages << message
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
data/lib/oncall/core/scenario.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
module Oncall
|
2
2
|
module Core
|
3
3
|
class Scenario
|
4
|
+
def initialize
|
5
|
+
@config = Oncall::Core.config
|
6
|
+
@http = Net::HTTP.new(@config.domain, @config.port)
|
7
|
+
end
|
8
|
+
|
4
9
|
def get(path, &block)
|
5
|
-
http = Net::HTTP.new('localhost', 4567)
|
6
10
|
request = Net::HTTP::Get.new(path)
|
7
|
-
response = http.request(request)
|
11
|
+
response = @http.request(request)
|
8
12
|
|
9
|
-
assertion = Oncall::Core::Assertion.new(response)
|
13
|
+
assertion = Oncall::Core::Assertion.new(response, 'GET', path)
|
10
14
|
assertion.instance_exec(&block)
|
11
15
|
end
|
12
16
|
end
|
data/lib/oncall/dsl.rb
CHANGED
@@ -1,32 +1,4 @@
|
|
1
|
-
require_relative 'dsl/response'
|
2
|
-
|
3
1
|
module Oncall
|
4
|
-
|
5
|
-
private
|
6
|
-
|
7
|
-
def describe(group, &block)
|
8
|
-
if block_given?
|
9
|
-
begin
|
10
|
-
yield
|
11
|
-
end
|
12
|
-
else
|
13
|
-
# Return status empty
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def get(path, &block)
|
18
|
-
if block_given?
|
19
|
-
http = Net::HTTP.new('localhost', 4567)
|
20
|
-
request = Net::HTTP::Get.new(path)
|
21
|
-
response = Oncall::Response.new(http.request(request))
|
22
|
-
|
23
|
-
begin
|
24
|
-
resuls = response.instance_eval &block
|
25
|
-
resuls
|
26
|
-
end
|
27
|
-
else
|
28
|
-
# Return status empty
|
29
|
-
end
|
30
|
-
end
|
2
|
+
module DSL
|
31
3
|
end
|
32
4
|
end
|
data/lib/oncall/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oncall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koen Woortman
|
@@ -92,7 +92,6 @@ files:
|
|
92
92
|
- lib/oncall/core/world.rb
|
93
93
|
- lib/oncall/core/wrapper.rb
|
94
94
|
- lib/oncall/dsl.rb
|
95
|
-
- lib/oncall/dsl/response.rb
|
96
95
|
- lib/oncall/http.rb
|
97
96
|
- lib/oncall/templates/oncall.yml.template
|
98
97
|
- lib/oncall/version.rb
|