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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21e2e79f1d7b3f98525a89c1cb973f23f5f8f4f3962d5be9a7ed5f9585db5296
4
- data.tar.gz: 074252b3271d4a441257b5fa171208ce33ac3f827f898cef75a9e93b6d81dc37
3
+ metadata.gz: '07378ff6344fb59c22ac6927c7aeac9cfecabf1504e0bfcbb02871668c04c189'
4
+ data.tar.gz: f2c98df8c24c08648db1dcff593b68c7bbd2517afae9e090a5728cbe5cca1b24
5
5
  SHA512:
6
- metadata.gz: 37fbc99650d45997051797f65df88e3db15c32275f4db054bf46a689182a5b1580fde0e8a80eb67658f48fe84e7f848d26b145308bfa9afa0d2eeb42aa65a764
7
- data.tar.gz: e9df5052851e20e227d61b4a51f8e9d6fbae36438233662f5b1fe1679a57940f803bf9af11f04c2f7baf08521067b33570d2fc0511538a20a4a0d6db7ef6377b
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
- @reporter.report_status(result)
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
@@ -15,6 +15,14 @@ module Oncall
15
15
  1
16
16
  end
17
17
 
18
+ def domain
19
+ 'localhost'
20
+ end
21
+
22
+ def port
23
+ 4567
24
+ end
25
+
18
26
  def test_files
19
27
  Dir.glob(pattern)
20
28
  end
@@ -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 "#{@results[:success]} passed, #{@results[:failure]} failed."
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
@@ -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
- class DSL
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Oncall
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
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.0
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
@@ -1,17 +0,0 @@
1
- module Oncall
2
- class Response
3
- def initialize(request)
4
- @request = request
5
- end
6
-
7
- private
8
-
9
- def status(code)
10
- if @request.code == code
11
- true
12
- else
13
- 'failed'
14
- end
15
- end
16
- end
17
- end