Class: Lacerda::Reporters::RSpec
Instance Method Summary
collapse
#check_published_object, #object_publish_specification_errors
Constructor Details
#initialize(group = RSpec.describe("Lacerda infrastructure contract validation")) ⇒ RSpec
Returns a new instance of RSpec.
6
7
8
|
# File 'lib/lacerda/reporters/rspec.rb', line 6
def initialize(group = RSpec.describe("Lacerda infrastructure contract validation"))
@group = group
end
|
Instance Method Details
#check_consumed_object(consumed_object_name, publisher_name, publisher_exists, is_published) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/lacerda/reporters/rspec.rb', line 45
def check_consumed_object(consumed_object_name, publisher_name, publisher_exists, is_published)
error = if !publisher_exists
"Publisher #{publisher_name} does not exist"
elsif !is_published
"#{publisher_name} does not publish #{consumed_object_name}"
end
@current_consumer.it "#{consumed_object_name} from #{publisher_name}" do
expect(publisher_exists && is_published).to eq(true), error
end
end
|
#check_consumer(service) ⇒ Object
41
42
43
|
# File 'lib/lacerda/reporters/rspec.rb', line 41
def check_consumer(service)
@current_consumer = @consume_group.describe("#{service.try(:name)} consuming")
end
|
#check_consuming ⇒ Object
37
38
39
|
# File 'lib/lacerda/reporters/rspec.rb', line 37
def check_consuming
@consume_group = @group.describe("consumers")
end
|
#check_publisher(service) ⇒ Object
33
34
35
|
# File 'lib/lacerda/reporters/rspec.rb', line 33
def check_publisher(service)
@current_publisher = @publish_group.describe(service.try(:name))
end
|
#check_publishing ⇒ Object
29
30
31
|
# File 'lib/lacerda/reporters/rspec.rb', line 29
def check_publishing
@publish_group = @group.describe("publishers")
end
|
#consume_specification_errors(consumer, errors) ⇒ Object
errors is a hash with the following structure:
{ "publisher_name -> consumer_name" => [
{ :error => :ERR_MISSING_DEFINITION,
:message =>"Some text",
:location => 'consumer_name/publisher_name::object_name
}]
}
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/lacerda/reporters/rspec.rb', line 17
def consume_specification_errors(consumer, errors)
error_messages = errors.map do |error|
"- #{error[:error]} in #{error[:location]}: #{error[:message]}"
end
msg = "expected #{@current_publisher.description} to satisfy "\
"#{consumer.name} but found these errors:\n"\
" #{error_messages.join("\n")}"
@current_publisher.it "satisfies #{consumer.name}" do
expect(error_messages).to be_empty, msg
end
end
|
#result(errors) ⇒ Object
56
57
|
# File 'lib/lacerda/reporters/rspec.rb', line 56
def result(errors)
end
|