10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/approvals/extensions/rspec/dsl.rb', line 10
def verify(options = {}, &block)
fetch_current_example = ::RSpec.respond_to?(:current_example) ? proc { ::RSpec.current_example } : proc { |context| context.example }
group = eval "self", block.binding
namer = ::RSpec.configuration.approvals_namer_class.new(fetch_current_example.call(group))
defaults = {
:namer => namer
}
format = ::RSpec.configuration.approvals_default_format
defaults[:format] = format if format
Approvals.verify(block.call, defaults.merge(options))
rescue ApprovalError => e
if diff_on_approval_failure?
::RSpec::Expectations.fail_with(e.message, e.approved_text, e.received_text)
else
raise e
end
end
|