lacerda 2.0.1 → 2.1.0
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/CHANGELOG.markdown +4 -0
- data/lib/lacerda/publish_specification.rb +6 -5
- data/lib/lacerda/reporter.rb +4 -2
- data/lib/lacerda/reporters/rspec.rb +26 -9
- data/lib/lacerda/service.rb +5 -0
- data/lib/lacerda/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaf17955acd73740444ef9eadfb624649845878c
|
4
|
+
data.tar.gz: 95faea39afed8806d21c1a38c03f690ed702154c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4706bfcb9a42d7c2b1eb0920d8b96ff83544fb2f6870f78b318b8ada1fc096d0f9b1fb947ceebb7fbcc459b2161db2988d8717544127b093f8c7d3f533384fd8
|
7
|
+
data.tar.gz: a1b8da1d419825b8718e68b001d7f52b19325937ddfaa98a5ceab8cbb3c7ed5ea96b4a44a2f2a0eae9061aede8a73c07286932e656237fe85e4d0f76b346b4ab
|
data/CHANGELOG.markdown
CHANGED
@@ -16,6 +16,7 @@ module Lacerda
|
|
16
16
|
Lacerda.validate_reporter(reporter)
|
17
17
|
@comparator = Compare::JsonSchema.new(@schema)
|
18
18
|
result = @comparator.contains?(consumer.consume.scoped_schema(service), consumer.name)
|
19
|
+
reporter.try(:consume_specification_errors,consumer, errors)
|
19
20
|
reporter.try(:consume_specification_satisfied, consumer, result)
|
20
21
|
result
|
21
22
|
end
|
@@ -25,16 +26,16 @@ module Lacerda
|
|
25
26
|
!!@schema[:definitions][scoped_name]
|
26
27
|
end
|
27
28
|
|
28
|
-
def object(name)
|
29
|
-
|
29
|
+
def object(name, scoped: true)
|
30
|
+
object_name = scoped ? scopify_name(name) : Lacerda.underscore(name.to_s)
|
30
31
|
schema_dup = Lacerda.deep_copy(@schema)
|
31
32
|
|
32
33
|
# It's critical to delete this object from the definitions
|
33
34
|
# or else the json validator gem will go into an endless loop
|
34
|
-
object_schema = schema_dup['definitions'].delete
|
35
|
+
object_schema = schema_dup['definitions'].delete object_name.to_s
|
35
36
|
|
36
37
|
unless object_schema
|
37
|
-
msg = "Unknown object type: #{
|
38
|
+
msg = "Unknown object type: #{object_name.to_s.to_json} not in #{schema['definitions'].keys.to_json} - did you specify it in publish.mson?"
|
38
39
|
raise Lacerda::Service::InvalidObjectTypeError.new(msg)
|
39
40
|
end
|
40
41
|
|
@@ -42,7 +43,7 @@ module Lacerda
|
|
42
43
|
# object in case its properties include json pointers
|
43
44
|
object_schema['definitions'] = schema_dup['definitions']
|
44
45
|
|
45
|
-
Lacerda::PublishedObject.new(service,
|
46
|
+
Lacerda::PublishedObject.new(service, object_name, object_schema)
|
46
47
|
end
|
47
48
|
|
48
49
|
private
|
data/lib/lacerda/reporter.rb
CHANGED
@@ -13,9 +13,11 @@ module Lacerda
|
|
13
13
|
# Called before one single publisher is checked against its consumers
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
|
17
|
+
def object_publish_specification_errors(consumed_object, errors)
|
17
18
|
# Called after a consumed object's specification has been checked against
|
18
|
-
# the publisher's specification of that object.
|
19
|
+
# the publisher's specification of that object. It returns an array of
|
20
|
+
# errors
|
19
21
|
end
|
20
22
|
|
21
23
|
def check_consuming
|
@@ -7,21 +7,40 @@ module Lacerda
|
|
7
7
|
@group = group
|
8
8
|
end
|
9
9
|
|
10
|
+
def consume_specification_satisfied(consumer, is_valid)
|
11
|
+
@current_publisher.it "satisfies #{consumer.name}" do
|
12
|
+
expect(is_valid).to be true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# errors is a hash with the following structure:
|
17
|
+
# { "publisher_name -> consumer_name" => [
|
18
|
+
# { :error => :ERR_MISSING_DEFINITION,
|
19
|
+
# :message =>"Some text",
|
20
|
+
# :location => 'consumer_name/publisher_name::object_name
|
21
|
+
# }]
|
22
|
+
# }
|
23
|
+
def consume_specification_errors(consumer, errors)
|
24
|
+
error_messages = errors.map do |error|
|
25
|
+
"- #{error[:error]} in #{error[:location]}: #{error[:message]}"
|
26
|
+
end
|
27
|
+
msg = "expected #{@current_publisher.description} to satisfy "\
|
28
|
+
"#{consumer.name} but found these errors:\n"\
|
29
|
+
" #{error_messages.join("\n")}"
|
30
|
+
@current_publisher.it "satisfies #{consumer.name}" do
|
31
|
+
expect(error_messages).to be_empty, msg
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
10
35
|
def check_publishing
|
36
|
+
@current_consumer.try(:run)
|
11
37
|
@publish_group = @group.describe("publishers")
|
12
38
|
end
|
13
39
|
|
14
40
|
def check_publisher(service)
|
15
|
-
@current_publisher.try(:run)
|
16
41
|
@current_publisher = @publish_group.describe(service.try(:name))
|
17
42
|
end
|
18
43
|
|
19
|
-
def object_publish_specificaiton_valid(object, valid)
|
20
|
-
@current_publisher.it "-> #{object.try(:consumer).try(:name)}" do
|
21
|
-
expect(valid).to be true
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
44
|
def check_consuming
|
26
45
|
@current_publisher.try(:run)
|
27
46
|
@consume_group = @group.describe("consumers")
|
@@ -39,8 +58,6 @@ module Lacerda
|
|
39
58
|
end
|
40
59
|
|
41
60
|
def result(errors)
|
42
|
-
@current_consumer.try(:run)
|
43
|
-
@group.run
|
44
61
|
end
|
45
62
|
|
46
63
|
end
|
data/lib/lacerda/service.rb
CHANGED
@@ -78,6 +78,11 @@ module Lacerda
|
|
78
78
|
object_description.validate_data!(data)
|
79
79
|
end
|
80
80
|
|
81
|
+
def validate_internal_publish_object!(type, data)
|
82
|
+
object_description = @publish.object(type, scoped: false)
|
83
|
+
object_description.validate_data!(data)
|
84
|
+
end
|
85
|
+
|
81
86
|
def validate_object_to_consume(type, data)
|
82
87
|
validate_object_to_consume!(type, data)
|
83
88
|
true
|
data/lib/lacerda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lacerda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jannis Hermanns
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|