Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/support/acceptance/line_validation.rb
Views: 11779
module Acceptance1###2# A utility object representing the validation of a a line of output generated3# by the acceptance test suite.4###5class LineValidation6# @param [string|Array<String>] values A line string, or array of lines7# @param [Object] options Additional options for configuring this failure, i.e. if it's a known flaky test result etc.8def initialize(values, options = {})9@values = Array(values)10@options = options11end1213def flatten14@values.map { |value| self.class.new(value, @options) }15end1617def value18raise StandardError, 'More than one value present' if @values.length > 11920@values[0]21end2223# @return [boolean] returns true if the current failure applies under the current environment or the result is flaky, false otherwise.24# @param [Hash] environment The current execution environment25# @return [TrueClass, FalseClass] True if the line is flaky - and may not always be present, false otherwise26def flaky?(environment = {})27value = @options.fetch(:flaky, false)2829evaluate_predicate(value, environment)30end3132# @return [boolean] returns true if the current failure applies under the current environment or the result is flaky, false otherwise.33# @param [Hash] environment34# @return [TrueClass, FalseClass] True if the line should be considered valid, false otherwise35def if?(environment = {})36value = @options.fetch(:if, true)37evaluate_predicate(value, environment)38end3940def to_h41{42values: @values,43options: @options44}45end4647private4849# (see Acceptance::Session#eval_predicate)50def evaluate_predicate(value, environment)51Acceptance::Session.eval_predicate(value, environment)52end53end54end555657