/vendor/bundle/jruby/2.1/gems/rspec-core-2.14.8/features/step_definitions/additional_cli_steps.rb

https://github.com/delowong/logstash · Ruby · 49 lines · 35 code · 9 blank · 5 comment · 0 complexity · 9630f544c0f0a381f6e5466c05c1defd MD5 · raw file

  1. require 'rspec/core' # to fix annoying "undefined method `configuration' for RSpec:Module (NoMethodError)"
  2. Then /^the output should contain all of these:$/ do |table|
  3. table.raw.flatten.each do |string|
  4. assert_partial_output(string, all_output)
  5. end
  6. end
  7. Then /^the output should not contain any of these:$/ do |table|
  8. table.raw.flatten.each do |string|
  9. all_output.should_not =~ regexp(string)
  10. end
  11. end
  12. Then /^the output should contain one of the following:$/ do |table|
  13. matching_output = table.raw.flatten.select do |string|
  14. all_output =~ regexp(string)
  15. end
  16. matching_output.should have(1).item
  17. end
  18. Then /^the example(?:s)? should(?: all)? pass$/ do
  19. step %q{the output should contain "0 failures"}
  20. step %q{the output should not contain "0 examples"}
  21. step %q{the exit status should be 0}
  22. end
  23. Then /^the process should succeed even though no examples were run$/ do
  24. step %q{the output should contain "0 examples, 0 failures"}
  25. step %q{the exit status should be 0}
  26. end
  27. Then /^the backtrace\-normalized output should contain:$/ do |partial_output|
  28. # ruby 1.9 includes additional stuff in the backtrace,
  29. # so we need to normalize it to compare it with our expected output.
  30. normalized_output = all_output.split("\n").map do |line|
  31. line =~ /(^\s+# [^:]+:\d+)/ ? $1 : line # http://rubular.com/r/zDD7DdWyzF
  32. end.join("\n")
  33. normalized_output.should =~ regexp(partial_output)
  34. end
  35. # This step can be generalized if it's ever used to test other colors
  36. Then /^the failing example is printed in magenta$/ do
  37. # \e[35m = enable magenta
  38. # \e[0m = reset colors
  39. expect(all_output).to include("\e[35m" + "F" + "\e[0m")
  40. end