Skip to content

Commit f470bbb

Browse files
committed
Add extra debugging tool for specs expected to pass
1 parent d33432a commit f470bbb

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

spec/rspec/rails/example/view_example_group_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'support/group_failure_formatter'
2+
13
module RSpec::Rails
24
RSpec.describe ViewExampleGroup do
35
it_behaves_like "an rspec-rails example group mixin", :view,
@@ -242,9 +244,10 @@ def _view; end # Stub method
242244
run_count += 1
243245
end
244246
group = RSpec::Core::ExampleGroup.describe 'a view', type: :view do
245-
specify { true }
247+
specify { expect(true).to eq true }
246248
end
247-
group.run
249+
group.run(failure_reporter)
250+
expect(failure_reporter.exceptions).to eq []
248251
expect(run_count).to eq 1
249252
end
250253
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module RSpec::Rails::TestSupport
2+
class FailureReporter
3+
def initialize
4+
@exceptions = []
5+
end
6+
attr_reader :exceptions
7+
8+
def example_failed(example)
9+
@exceptions << example.exception
10+
end
11+
12+
def method_missing(name, *_args, &_block)
13+
end
14+
end
15+
16+
def failure_reporter
17+
@failure_reporter ||= FailureReporter.new
18+
end
19+
end
20+
21+
RSpec.configure do |config|
22+
config.include RSpec::Rails::TestSupport
23+
end

0 commit comments

Comments
 (0)