class Lacerda::Reporters::RSpec
Public Class Methods
new(group = ::RSpec.describe("Lacerda infrastructure contract validation"))
click to toggle source
# File lib/lacerda/reporters/rspec.rb, line 6 def initialize(group = ::RSpec.describe("Lacerda infrastructure contract validation")) @group = group end
Public Instance Methods
check_consumed_object(consumed_object_name, publisher_name, publisher_exists, is_published)
click to toggle source
# File lib/lacerda/reporters/rspec.rb, line 47 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 |example| # We need to set the location to avoid rspec STDOUT errors example.metadata[:location] = 'spec/config/zeta_spec.rb' expect(publisher_exists && is_published).to eq(true), error end end
check_consumer(service)
click to toggle source
# File lib/lacerda/reporters/rspec.rb, line 43 def check_consumer(service) @current_consumer = @consume_group.describe("#{service.try(:name)} consuming") end
check_consuming()
click to toggle source
# File lib/lacerda/reporters/rspec.rb, line 39 def check_consuming @consume_group = @group.describe("consumers") end
check_publisher(service)
click to toggle source
# File lib/lacerda/reporters/rspec.rb, line 35 def check_publisher(service) @current_publisher = @publish_group.describe(service.try(:name)) end
check_publishing()
click to toggle source
# File lib/lacerda/reporters/rspec.rb, line 31 def check_publishing @publish_group = @group.describe("publishers") end
consume_specification_errors(consumer, errors)
click to toggle source
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 }] }
# 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 |example| # We need to set the location to avoid rspec STDOUT errors example.metadata[:location] = 'spec/config/zeta_spec.rb' expect(error_messages).to be_empty, msg end end
result(errors)
click to toggle source
# File lib/lacerda/reporters/rspec.rb, line 60 def result(errors) end