Class: TestAssistant::Configuration
- Inherits:
-
Object
- Object
- TestAssistant::Configuration
- Defined in:
- lib/test_assistant/configuration.rb
Overview
Class that provides configuration methods to control what parts of Test Assistant are included in an RSpec test suite. Instances of this class are managed internally by Test Assistant when using the TestAssistant#configure method.
Instance Method Summary collapse
-
#debug_failed_responses(options = {}) ⇒ Object
Configures under what circumstances a failing test should open an debugger session.
-
#initialize(rspec_config) ⇒ TestAssistant::Configuration
constructor
Creates a new TestAssistant::Configuration object - called internally by Test Assistant.
-
#render_failed_responses(options = {}) ⇒ Object
Configures under what circumstances a failing test should open a failure report detailing the last HTTP request and response in a browser.
Constructor Details
#initialize(rspec_config) ⇒ TestAssistant::Configuration
Creates a new TestAssistant::Configuration object - called internally by Test Assistant
16 17 18 |
# File 'lib/test_assistant/configuration.rb', line 16 def initialize(rspec_config) @rspec_config = rspec_config end |
Instance Method Details
#debug_failed_responses(options = {}) ⇒ Object
Configures under what circumstances a failing test should open an debugger session
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/test_assistant/configuration.rb', line 110 def debug_failed_responses( = {}) tag_filter = .fetch(:tag, :debugger) type_filter = [:type] no_type_filter = !type_filter @rspec_config.after(:each) do |example| next unless example.exception = example. next unless (.key?(tag_filter)) && ([:type] == type_filter || no_type_filter) # noinspection RubyResolve if defined? binding binding.pry elsif defined? byebug byebug else debugger end end end |
#render_failed_responses(options = {}) ⇒ Object
Configures under what circumstances a failing test should open a failure report detailing the last HTTP request and response in a browser
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/test_assistant/configuration.rb', line 55 def render_failed_responses( = {}) tag_filter = [:tag] no_tag_filter = !tag_filter type_filter = [:type] no_type_filter = !type_filter @rspec_config.after(:each) do |example| next unless example.exception = example. next unless ([tag_filter] || no_tag_filter) && ([:type] == type_filter || no_type_filter) if [:type] == :feature save_and_open_page else reporter = FailureReporter.report(request, response) reporter.write reporter.open end end end |