Skip to content

Commit

Permalink
Add extra debugging tool for specs expected to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed May 15, 2020
1 parent 1f723f5 commit 0cd56e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions 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,
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions 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

0 comments on commit 0cd56e6

Please sign in to comment.