Module: Sbmt::Pact::Matchers
- Included in:
- SbmtPactConsumerDsl
- Defined in:
- lib/sbmt/pact/matchers.rb,
lib/sbmt/pact/matchers/base.rb,
lib/sbmt/pact/matchers/v2/type.rb,
lib/sbmt/pact/matchers/v3/date.rb,
lib/sbmt/pact/matchers/v3/each.rb,
lib/sbmt/pact/matchers/v3/time.rb,
lib/sbmt/pact/matchers/v2/regex.rb,
lib/sbmt/pact/matchers/v3/number.rb,
lib/sbmt/pact/matchers/v3/boolean.rb,
lib/sbmt/pact/matchers/v3/decimal.rb,
lib/sbmt/pact/matchers/v3/include.rb,
lib/sbmt/pact/matchers/v3/integer.rb,
lib/sbmt/pact/matchers/v1/equality.rb,
lib/sbmt/pact/matchers/v4/each_key.rb,
lib/sbmt/pact/matchers/v3/date_time.rb,
lib/sbmt/pact/matchers/v4/not_empty.rb,
lib/sbmt/pact/matchers/v4/each_value.rb,
lib/sbmt/pact/matchers/v4/each_key_value.rb
Defined Under Namespace
Modules: V1, V2, V3, V4
Classes: Base
Constant Summary
collapse
- PACT_SPEC_V1 =
1
- PACT_SPEC_V2 =
2
- PACT_SPEC_V3 =
3
- PACT_SPEC_V4 =
4
- ANY_STRING_REGEX =
/.*/
- UUID_REGEX =
/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i
- ISO8601_REGEX =
/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)*(.\d{2}:\d{2})*/i
Instance Method Summary
collapse
Instance Method Details
#match_any_boolean(sample = true) ⇒ Object
45
46
47
|
# File 'lib/sbmt/pact/matchers.rb', line 45
def match_any_boolean(sample = true)
V3::Boolean.new(sample)
end
|
#match_any_decimal(sample = 10.0) ⇒ Object
37
38
39
|
# File 'lib/sbmt/pact/matchers.rb', line 37
def match_any_decimal(sample = 10.0)
V3::Decimal.new(sample)
end
|
#match_any_integer(sample = 10) ⇒ Object
33
34
35
|
# File 'lib/sbmt/pact/matchers.rb', line 33
def match_any_integer(sample = 10)
V3::Integer.new(sample)
end
|
#match_any_number(sample = 10.0) ⇒ Object
41
42
43
|
# File 'lib/sbmt/pact/matchers.rb', line 41
def match_any_number(sample = 10.0)
V3::Number.new(sample)
end
|
#match_any_string(sample = "any") ⇒ Object
29
30
31
|
# File 'lib/sbmt/pact/matchers.rb', line 29
def match_any_string(sample = "any")
V2::Regex.new(ANY_STRING_REGEX, sample)
end
|
#match_date(format, sample) ⇒ Object
65
66
67
|
# File 'lib/sbmt/pact/matchers.rb', line 65
def match_date(format, sample)
V3::Date.new(format, sample)
end
|
#match_datetime(format, sample) ⇒ Object
57
58
59
|
# File 'lib/sbmt/pact/matchers.rb', line 57
def match_datetime(format, sample)
V3::DateTime.new(format, sample)
end
|
#match_each(template, min = nil) ⇒ Object
73
74
75
|
# File 'lib/sbmt/pact/matchers.rb', line 73
def match_each(template, min = nil)
V3::Each.new(template, min)
end
|
#match_each_key(template, key_matchers) ⇒ Object
81
82
83
|
# File 'lib/sbmt/pact/matchers.rb', line 81
def match_each_key(template, key_matchers)
V4::EachKey.new(key_matchers.is_a?(Array) ? key_matchers : [key_matchers], template)
end
|
#match_each_kv(template, key_matchers) ⇒ Object
89
90
91
|
# File 'lib/sbmt/pact/matchers.rb', line 89
def match_each_kv(template, key_matchers)
V4::EachKeyValue.new(key_matchers.is_a?(Array) ? key_matchers : [key_matchers], template)
end
|
#match_each_regex(regex, sample) ⇒ Object
77
78
79
|
# File 'lib/sbmt/pact/matchers.rb', line 77
def match_each_regex(regex, sample)
match_each_value(sample, match_regex(regex, sample))
end
|
#match_each_value(template, value_matchers = V2::Type.new("")) ⇒ Object
85
86
87
|
# File 'lib/sbmt/pact/matchers.rb', line 85
def match_each_value(template, value_matchers = V2::Type.new(""))
V4::EachValue.new(value_matchers.is_a?(Array) ? value_matchers : [value_matchers], template)
end
|
#match_exactly(arg) ⇒ Object
17
18
19
|
# File 'lib/sbmt/pact/matchers.rb', line 17
def match_exactly(arg)
V1::Equality.new(arg)
end
|
#match_include(arg) ⇒ Object
25
26
27
|
# File 'lib/sbmt/pact/matchers.rb', line 25
def match_include(arg)
V3::Include.new(arg)
end
|
#match_iso8601(sample = "2024-08-12T12:25:00.243118+03:00") ⇒ Object
61
62
63
|
# File 'lib/sbmt/pact/matchers.rb', line 61
def match_iso8601(sample = "2024-08-12T12:25:00.243118+03:00")
V2::Regex.new(ISO8601_REGEX, sample)
end
|
#match_regex(regex, sample) ⇒ Object
53
54
55
|
# File 'lib/sbmt/pact/matchers.rb', line 53
def match_regex(regex, sample)
V2::Regex.new(regex, sample)
end
|
#match_time(format, sample) ⇒ Object
69
70
71
|
# File 'lib/sbmt/pact/matchers.rb', line 69
def match_time(format, sample)
V3::Time.new(format, sample)
end
|
#match_type_of(arg) ⇒ Object
21
22
23
|
# File 'lib/sbmt/pact/matchers.rb', line 21
def match_type_of(arg)
V2::Type.new(arg)
end
|
#match_uuid(sample = "e1d01e04-3a2b-4eed-a4fb-54f5cd257338") ⇒ Object
49
50
51
|
# File 'lib/sbmt/pact/matchers.rb', line 49
def match_uuid(sample = "e1d01e04-3a2b-4eed-a4fb-54f5cd257338")
V2::Regex.new(UUID_REGEX, sample)
end
|