Class: Approvals
- Inherits:
-
Object
- Object
- Approvals
- Defined in:
- lib/simple_approvals/rspec/approvals.rb
Overview
Top-level class to provide approval test support (inspired by approvaltests.com/)
Class Method Summary collapse
Class Method Details
.verify(rendered_content, approved_path, **options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/simple_approvals/rspec/approvals.rb', line 4 def verify(rendered_content, approved_path, **) scrubbed_content = apply_optional_scrubber(rendered_content, ) pre_approve_if_asked(approved_path, scrubbed_content, ) expected_content = load_expected_content(approved_path, ) received_path = received_path_for approved_path if scrubbed_content.strip.empty? raise_verify_error_with_diff(approved_path, received_path, scrubbed_content, ) unless [:allow_empty] elsif scrubbed_content.strip == expected_content.strip handle_match(received_path, scrubbed_content, ) else raise_verify_error_with_diff(approved_path, received_path, scrubbed_content, ) end end |