Class: CodeClimate::TestReporter::PayloadValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/code_climate/test_reporter/payload_validator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ PayloadValidator

Returns a new instance of PayloadValidator.



6
7
8
# File 'lib/code_climate/test_reporter/payload_validator.rb', line 6

def initialize(payload)
  @payload = payload
end

Class Method Details

.validate(payload) ⇒ Object



10
11
12
# File 'lib/code_climate/test_reporter/payload_validator.rb', line 10

def self.validate(payload)
  new(payload).validate
end

Instance Method Details

#validateObject

Raises:



14
15
16
17
18
19
20
21
# File 'lib/code_climate/test_reporter/payload_validator.rb', line 14

def validate
  raise InvalidPayload, "A git commit sha was not found in the test report payload" unless commit_sha
  raise InvalidPayload, "A git commit timestamp was not found in the test report payload" unless committed_at
  raise InvalidPayload, "A run at timestamp was not found in the test report payload" unless run_at
  raise InvalidPayload, "No source files were found in the test report payload" unless source_files?
  raise InvalidPayload, "Invalid source files were found in the test report payload" unless valid_source_files?
  true
end