You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

output.rb 1.3 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. require 'rspec/expectations'
  2. def clean_output(output)
  3. output.split("\n").map do |line|
  4. next if line.include?(CUCUMBER_FEATURES_PATH)
  5. line
  6. .gsub(/\e\[([;\d]+)?m/, '') # Drop colors
  7. .gsub(/^.*cucumber_process\.rb.*$\n/, '')
  8. .gsub(/^\d+m\d+\.\d+s$/, '0m0.012s') # Make duration predictable
  9. .gsub(/Coverage report generated .+$\n/, '') # Remove SimpleCov message
  10. .sub(/\s*$/, '') # Drop trailing whitespaces
  11. end.compact.join("\n")
  12. end
  13. def remove_self_ref(output)
  14. output
  15. .split("\n")
  16. .reject { |line| line.include?(CUCUMBER_FEATURES_PATH) }
  17. .join("\n")
  18. end
  19. RSpec::Matchers.define :be_similar_output_than do |expected|
  20. match do |actual|
  21. @actual = clean_output(actual)
  22. @expected = clean_output(expected)
  23. @actual == @expected
  24. end
  25. diffable
  26. end
  27. RSpec::Matchers.define :start_with_output do |expected|
  28. match do |actual|
  29. @actual = clean_output(actual)
  30. @expected = clean_output(expected)
  31. @actual.start_with?(@expected)
  32. end
  33. diffable
  34. end
  35. RSpec::Matchers.define :include_output do |expected|
  36. match do |actual|
  37. @actual = clean_output(actual)
  38. @expected = clean_output(expected)
  39. @actual.include?(@expected)
  40. end
  41. diffable
  42. end

No Description

Contributors (1)