Class: TestAssistant::Configuration
- Inherits:
-
Object
- Object
- TestAssistant::Configuration
- Defined in:
- lib/test_assistant/configuration.rb
Instance Method Summary collapse
- #debug_failed_responses(options = {}) ⇒ Object
- #include_email_helpers(options = {}) ⇒ Object
- #include_json_helpers(options = {}) ⇒ Object
-
#initialize(rspec_config) ⇒ Configuration
constructor
A new instance of Configuration.
- #render_failed_responses(options = {}) ⇒ Object
Constructor Details
#initialize(rspec_config) ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 |
# File 'lib/test_assistant/configuration.rb', line 7 def initialize(rspec_config) @rspec_config = rspec_config end |
Instance Method Details
#debug_failed_responses(options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/test_assistant/configuration.rb', line 41 def debug_failed_responses( = {}) tag_filter = .fetch(:tag, :debugger) type_filter = [:type] no_type_filter = !type_filter @rspec_config.after(:each) do |example| if example.exception if (example.[tag_filter]) && (example.[:type] == type_filter || no_type_filter) if defined? binding binding.pry elsif defined? byebug byebug else debugger end end end end end |
#include_email_helpers(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/test_assistant/configuration.rb', line 15 def include_email_helpers( = {}) @rspec_config.include Email::Helpers, @rspec_config.after :each, type: :request do # clear emails after every request spec ActionMailer::Base.deliveries = [] end end |
#include_json_helpers(options = {}) ⇒ Object
11 12 13 |
# File 'lib/test_assistant/configuration.rb', line 11 def include_json_helpers( = {}) @rspec_config.include Json::Helpers, end |
#render_failed_responses(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/test_assistant/configuration.rb', line 24 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| if example.exception if (example.[tag_filter] || no_tag_filter) && (example.[:type] == type_filter || no_type_filter) reporter = FailureReporter.report(request, response) reporter.write reporter.open end end end end |