module SerialSpec

Constants

SERIAL_VALID_VERBS
VERSION

Public Instance Methods

failed_message(msg, remainder, selector, current_selector) click to toggle source
# File lib/serial_spec/parsed_body.rb, line 121
def failed_message(msg, remainder, selector, current_selector)
  case msg
  when :expected_object
    "expected an object to have #{formatted_selector([current_selector])}, but found #{remainder.class}:\"#{remainder}\" at #{formatted_selector(selector[0..-2])}"
  when :expected_array
    "expected an array at \"#{formatted_selector(selector[0..-2])}\", but found #{remainder.class}:'#{remainder}'"
  end
end
formatted_selector(selector) click to toggle source
# File lib/serial_spec/parsed_body.rb, line 108
def formatted_selector(selector)
  output = ""

  selector.each do |item|
    if item.first == :[]
      output << "[#{item.last.inspect}]"
    else
      output << "[#{item.first.inspect}]"
    end
  end
  output
end