diff --git a/spec/rspec/rails/example/view_example_group_spec.rb b/spec/rspec/rails/example/view_example_group_spec.rb index de8e595acd..3ca3c93976 100644 --- a/spec/rspec/rails/example/view_example_group_spec.rb +++ b/spec/rspec/rails/example/view_example_group_spec.rb @@ -1,3 +1,5 @@ +require 'support/group_failure_formatter' + module RSpec::Rails RSpec.describe ViewExampleGroup do it_behaves_like "an rspec-rails example group mixin", :view, @@ -242,9 +244,10 @@ def _view; end # Stub method run_count += 1 end group = RSpec::Core::ExampleGroup.describe 'a view', type: :view do - specify { true } + specify { expect(true).to eq true } end - group.run + group.run(failure_reporter) + expect(failure_reporter.exceptions).to eq [] expect(run_count).to eq 1 end end diff --git a/spec/support/group_failure_formatter.rb b/spec/support/group_failure_formatter.rb new file mode 100644 index 0000000000..8692a1bd3a --- /dev/null +++ b/spec/support/group_failure_formatter.rb @@ -0,0 +1,23 @@ +module RSpec::Rails::TestSupport + class FailureReporter + def initialize + @exceptions = [] + end + attr_reader :exceptions + + def example_failed(example) + @exceptions << example.exception + end + + def method_missing(name, *_args, &_block) + end + end + + def failure_reporter + @failure_reporter ||= FailureReporter.new + end +end + +RSpec.configure do |config| + config.include RSpec::Rails::TestSupport +end