tracing-matchers 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/tracing/matchers/have_span.rb +6 -0
- data/lib/tracing/matchers/span/follow_after.rb +72 -0
- data/lib/tracing/matchers/span_matchers.rb +14 -0
- data/lib/tracing/matchers/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 453bdb76b19f9217b2e1ef3149f1f787b6bee188
|
4
|
+
data.tar.gz: 951d8e59a64ae2ed9f01f18e427b051c901e5d36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76455d6e26271679fa9f5c5ece791be45063a329f44a969f9d7e7f7768ca6f1c57099640f178013d29304649fbb52ce0b02184861f8a526cb39350de74a672de
|
7
|
+
data.tar.gz: 8d2a86f4590c50b52b759f79da0920bd3ed1ea5064384d1422081b94f9c687d7acd4a9a0f9d2e3ee70d796a50d66d16de39116be00a03b5957e88342ce4c4f80
|
data/README.md
CHANGED
@@ -36,6 +36,7 @@ expect(tracer).to have_span(optional operation_name)
|
|
36
36
|
.with_log(optional fields)
|
37
37
|
.with_baggage(optional baggage to match)
|
38
38
|
.child_of(operation_name or span or context)
|
39
|
+
.following_after(operation_name or span)
|
39
40
|
|
40
41
|
expect(span).to have_tag
|
41
42
|
expect(span).to have_tags
|
@@ -45,6 +46,7 @@ expect(span).to have_baggage
|
|
45
46
|
expect(span).to have_baggage_item
|
46
47
|
expect(span).to have_parent
|
47
48
|
expect(span).to be_child_of
|
49
|
+
expect(span).to follow_after(String|Span)
|
48
50
|
```
|
49
51
|
|
50
52
|
Detailed documentation and usage examples can be found in [matchers.rb](https://github.com/iaintshine/ruby-tracing-matchers/blob/master/lib/tracing/matchers.rb) file.
|
@@ -41,6 +41,12 @@ module Tracing
|
|
41
41
|
end
|
42
42
|
alias :with_parent :child_of
|
43
43
|
|
44
|
+
def follow_after(previous)
|
45
|
+
@predicates << Tracing::Matchers::Span::FollowAfter.new(previous)
|
46
|
+
self
|
47
|
+
end
|
48
|
+
alias :following_after :follow_after
|
49
|
+
|
44
50
|
# @return [Boolean]
|
45
51
|
def matches?(tracer)
|
46
52
|
@subject = tracer
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Tracing
|
2
|
+
module Matchers
|
3
|
+
module Span
|
4
|
+
# @private
|
5
|
+
class FollowAfter
|
6
|
+
include Test::TypeCheck
|
7
|
+
|
8
|
+
def initialize(previous)
|
9
|
+
NotNull! previous
|
10
|
+
@expected = previous
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [Boolean]
|
14
|
+
def matches?(span)
|
15
|
+
@tracer = span.tracer
|
16
|
+
@subject = span
|
17
|
+
|
18
|
+
return false unless expected_index && subject_index
|
19
|
+
expected_index < subject_index
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [String]
|
23
|
+
def description
|
24
|
+
"follow after #{expected_message}"
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [String]
|
28
|
+
def failure_message
|
29
|
+
"expected #{subject_message} to follow after #{expected_message}"
|
30
|
+
end
|
31
|
+
alias :failure_message_for_should :failure_message
|
32
|
+
|
33
|
+
# @return [String]
|
34
|
+
def failure_message_when_negated
|
35
|
+
"did not expected #{subject_message} to follow after #{expected_message}"
|
36
|
+
end
|
37
|
+
alias :failure_message_for_should_not :failure_message_when_negated
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def expected_index
|
42
|
+
@tracer.spans.find_index(expected_span)
|
43
|
+
end
|
44
|
+
|
45
|
+
def subject_index
|
46
|
+
@tracer.spans.find_index(@subject)
|
47
|
+
end
|
48
|
+
|
49
|
+
def expected_span
|
50
|
+
case
|
51
|
+
when @expected.respond_to?(:context) then @expected
|
52
|
+
when @expected.is_a?(String)
|
53
|
+
@tracer.spans.find { |span| span.operation_name == @expected }
|
54
|
+
else @expected
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def expected_message
|
59
|
+
case
|
60
|
+
when @expected.respond_to?(:context) then "the span with operation name \"#{@expected.operation_name}\""
|
61
|
+
when @expected.is_a?(String) then "a span with operation name \"#{@expected}\""
|
62
|
+
else nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def subject_message
|
67
|
+
"a span with operation name \"#{@subject.operation_name}\""
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -2,6 +2,7 @@ require "tracing/matchers/span/have_tag"
|
|
2
2
|
require "tracing/matchers/span/have_log"
|
3
3
|
require "tracing/matchers/span/have_baggage"
|
4
4
|
require "tracing/matchers/span/be_child_of"
|
5
|
+
require "tracing/matchers/span/follow_after"
|
5
6
|
|
6
7
|
module Tracing
|
7
8
|
module Matchers
|
@@ -68,5 +69,18 @@ module Tracing
|
|
68
69
|
Tracing::Matchers::Span::BeChildOf.new(parent)
|
69
70
|
end
|
70
71
|
alias :have_parent :be_child_of
|
72
|
+
|
73
|
+
# The `follow_after` matcher tests that the span follows after some other span.
|
74
|
+
# @example
|
75
|
+
#
|
76
|
+
# # Passes if span follows after spcific span
|
77
|
+
# expect(span).to be_child_of("previous operation")
|
78
|
+
# expect(span).to be_child_of(previous_span)
|
79
|
+
#
|
80
|
+
# @param [String, Span] previous expected span to follow after
|
81
|
+
# @return [FollowAfter]
|
82
|
+
def follow_after(previous)
|
83
|
+
Tracing::Matchers::Span::FollowAfter.new(previous)
|
84
|
+
end
|
71
85
|
end
|
72
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tracing-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iaintshine
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-tracer
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/tracing/matchers/have_spans.rb
|
90
90
|
- lib/tracing/matchers/have_traces.rb
|
91
91
|
- lib/tracing/matchers/span/be_child_of.rb
|
92
|
+
- lib/tracing/matchers/span/follow_after.rb
|
92
93
|
- lib/tracing/matchers/span/have_baggage.rb
|
93
94
|
- lib/tracing/matchers/span/have_log.rb
|
94
95
|
- lib/tracing/matchers/span/have_tag.rb
|