rspec-core: Backtrace exclusion doesn't work in RSpec 3.5.4

I have this part in my spec_helper.rb, starting with default configuration

# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
# have no way to turn it off -- the option exists only for backwards
# compatibility in RSpec 3). It causes shared context metadata to be
# inherited by the metadata hash of host groups and examples, rather than
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups

puts "HERE!!!"

# removes too long exception backtrace messages
config.backtrace_exclusion_patterns = [
  /rspec/,
  /\/lib\d*\/ruby\//,
  /org\/jruby\//,
  /bin\//,
  /gems/,
  /spec\/spec_helper\.rb/,
  /lib\/rspec\/(core|expectations|matchers|mocks)/
]

All of these are ignored. I have even put rspec out of desperation. Backtrace is so long that I have to use mouse and scroll up every time. 😦

Here is the output I get

$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
$ rspec -v
3.5.4
$ rspec
HERE!!!
/home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:724:in `method_missing': `get_property` is not available on an example group (e.g. a `describe` or `context` block). It is only available from within individual examples (e.g. `it` blocks) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). (RSpec::Core::ExampleGroup::WrongScopeError)
	from /data/sites/scripts/sw_scripts/ruby/gallery/spec/specs/specs_spec.rb:33:in `block (3 levels) in <top (required)>'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/shared_example_group.rb:36:in `class_exec'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/shared_example_group.rb:36:in `block in include_in'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:797:in `with_frame'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/shared_example_group.rb:35:in `include_in'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:373:in `find_and_eval_shared'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:341:in `include_examples'
	from /data/sites/scripts/sw_scripts/ruby/gallery/spec/specs/specs_spec.rb:68:in `block (3 levels) in <top (required)>'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `module_exec'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `subclass'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:258:in `block in define_example_group_method'
	from /data/sites/scripts/sw_scripts/ruby/gallery/spec/specs/specs_spec.rb:66:in `block (2 levels) in <top (required)>'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `module_exec'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `subclass'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:258:in `block in define_example_group_method'
	from /data/sites/scripts/sw_scripts/ruby/gallery/spec/specs/specs_spec.rb:14:in `block in <top (required)>'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `module_exec'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `subclass'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:258:in `block in define_example_group_method'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/dsl.rb:43:in `block in expose_example_group_alias'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/dsl.rb:84:in `block (2 levels) in expose_example_group_alias_globally'
	from /data/sites/scripts/sw_scripts/ruby/gallery/spec/specs/specs_spec.rb:6:in `<top (required)>'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
	from /home/marko/.gem/ruby/2.3.1/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
	from /home/marko/.gem/ruby/2.3.1/bin/rspec:22:in `load'
	from /home/marko/.gem/ruby/2.3.1/bin/rspec:22:in `<main>'

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (10 by maintainers)

Most upvoted comments

I believe you’ve configured RSpec to show the full backtrace. This can be done in a few ways:

  • --backtrace or -b in .rspec
  • --backtrace or -b in ~/.rspec
  • --backtrace or -b in .rspec-local
  • config.backtrace = true in a Ruby file loaded as part of your suite

This option provides a way to easily see the full backtrace for a specific run (which is why it overrides the exclusion patterns you have set–no matter what exclusion you’ve set, there are occasions where you really need to see the entire backtrace). In general, I recommend you only pass it via the command line, and do not commit it to a file as it sounds like must have happened for you.