/vendor/bundle/jruby/2.1/gems/rspec-core-2.14.8/features/configuration/backtrace_clean_patterns.feature

https://github.com/delowong/logstash · Gherkin Specification · 102 lines · 92 code · 10 blank · 0 comment · 0 complexity · fb81d6d9d343f5afd5cb12bac74bd292 MD5 · raw file

  1. Feature: Backtrace cleaning
  2. To aid in diagnozing spec failures, RSpec cleans matching lines from backtraces. The default patterns cleaned are:
  3. /\/lib\d*\/ruby\//,
  4. /org\/jruby\//,
  5. /bin\//,
  6. /gems/,
  7. /spec\/spec_helper\.rb/,
  8. /lib\/rspec\/(core|expectations|matchers|mocks)/
  9. This list can be modified or replaced with the `backtrace_clean_patterns` option. Additionally, rspec can be run with the `--backtrace` option to skip backtrace cleaning entirely.
  10. Scenario: default configuration
  11. Given a file named "spec/failing_spec.rb" with:
  12. """ruby
  13. describe "2 + 2" do
  14. it "is 5" do
  15. (2+2).should eq(5)
  16. end
  17. end
  18. """
  19. When I run `rspec`
  20. Then the output should contain "1 example, 1 failure"
  21. And the output should not contain "lib/rspec/expectations"
  22. Scenario: With a custom setting for backtrace_clean_patterns
  23. Given a file named "spec/spec_helper.rb" with:
  24. """ruby
  25. RSpec.configure do |config|
  26. config.backtrace_clean_patterns = [
  27. /spec_helper/
  28. ]
  29. end
  30. def foo
  31. "bar"
  32. end
  33. """
  34. And a file named "spec/example_spec.rb" with:
  35. """ruby
  36. require 'spec_helper'
  37. describe "foo" do
  38. it "returns baz" do
  39. foo.should eq("baz")
  40. end
  41. end
  42. """
  43. When I run `rspec`
  44. Then the output should contain "1 example, 1 failure"
  45. And the output should contain "lib/rspec/expectations"
  46. Scenario: Adding a pattern
  47. Given a file named "spec/matchers/be_baz_matcher.rb" with:
  48. """ruby
  49. RSpec::Matchers.define :be_baz do |_|
  50. match do |actual|
  51. actual == "baz"
  52. end
  53. end
  54. """
  55. And a file named "spec/example_spec.rb" with:
  56. """ruby
  57. RSpec.configure do |config|
  58. config.backtrace_clean_patterns << /be_baz_matcher/
  59. end
  60. describe "bar" do
  61. it "is baz" do
  62. "bar".should be_baz
  63. end
  64. end
  65. """
  66. When I run `rspec`
  67. Then the output should contain "1 example, 1 failure"
  68. But the output should not contain "be_baz_matcher"
  69. And the output should not contain "lib/rspec/expectations"
  70. Scenario: Running with the --backtrace option
  71. Given a file named "spec/matchers/be_baz_matcher.rb" with:
  72. """ruby
  73. RSpec::Matchers.define :be_baz do |_|
  74. match do |actual|
  75. actual == "baz"
  76. end
  77. end
  78. """
  79. And a file named "spec/example_spec.rb" with:
  80. """ruby
  81. RSpec.configure do |config|
  82. config.backtrace_clean_patterns << /be_baz_matcher/
  83. end
  84. describe "bar" do
  85. it "is baz" do
  86. "bar".should be_baz
  87. end
  88. end
  89. """
  90. When I run `rspec --backtrace`
  91. Then the output should contain "1 example, 1 failure"
  92. And the output should not contain "be_baz_matcher"