Module: Museo::TestIntegration
- Included in:
- MinitestIntegration, RSpecIntegration
- Defined in:
- lib/museo/test_integration.rb
Instance Method Summary collapse
- #_add_snapshot_helper_methods ⇒ Object
- #_museo_setup ⇒ Object
- #_museo_teardown ⇒ Object
- #_redefine_render_with_snapshot_layout ⇒ Object
- #_remove_snapshot_helper_methods ⇒ Object
Instance Method Details
#_add_snapshot_helper_methods ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/museo/test_integration.rb', line 12 def _add_snapshot_helper_methods @controller.class.helper do Museo.configuration.stubbed_methods.each do |method_name, callable| alias_method("_original_#{method_name}", method_name) if method_defined?(method_name) define_method(method_name) do |*args, &block| output = callable.respond_to?(:call) ? instance_exec(*args, block, &callable) : callable [ "<!--", "Stubbed method call: #{method_name}", Museo.configuration.formatter.format(output), "-->", "", ].join("\n").html_safe end end end end |
#_museo_setup ⇒ Object
3 4 5 6 |
# File 'lib/museo/test_integration.rb', line 3 def _museo_setup _add_snapshot_helper_methods _redefine_render_with_snapshot_layout end |
#_museo_teardown ⇒ Object
8 9 10 |
# File 'lib/museo/test_integration.rb', line 8 def _museo_teardown _remove_snapshot_helper_methods end |
#_redefine_render_with_snapshot_layout ⇒ Object
44 45 46 47 48 49 |
# File 'lib/museo/test_integration.rb', line 44 def _redefine_render_with_snapshot_layout @controller.define_singleton_method(:render) do |*args| = args.length > 1 ? args.last : {} super(*args[1..-2], .merge(layout: "museo/snapshot")) end end |
#_remove_snapshot_helper_methods ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/museo/test_integration.rb', line 32 def _remove_snapshot_helper_methods @controller.class.helper do Museo.configuration.stubbed_methods.each do |method_name, _callable| remove_method method_name if method_defined?("_original_#{method_name}") alias_method method_name, "_original_#{method_name}" end end end end |