Method initialize_configuration
has 85 lines of code (exceeds 25 allowed). Consider refactoring.
def self.initialize_configuration(config)
config.backtrace_exclusion_patterns << /vendor\//
config.backtrace_exclusion_patterns << %r{lib/rspec/rails}
Class Base
has 27 methods (exceeds 20 allowed). Consider refactoring.
class Base < RSpec::Rails::Matchers::BaseMatcher
def initialize
@args = []
@queue = nil
@at = nil
Method initialize_configuration
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
def self.initialize_configuration(config)
config.backtrace_exclusion_patterns << /vendor\//
config.backtrace_exclusion_patterns << %r{lib/rspec/rails}
Class HaveBroadcastedTo
has 22 methods (exceeds 20 allowed). Consider refactoring.
class HaveBroadcastedTo < RSpec::Matchers::BuiltIn::BaseMatcher
def initialize(target, channel:)
@target = target
@channel = channel
@block = proc { }
File active_job.rb
has 260 lines of code (exceeds 250 allowed). Consider refactoring.
require "active_job/base"
require "active_job/arguments"
module RSpec
module Rails
Method controller
has 43 lines of code (exceeds 25 allowed). Consider refactoring.
def controller(base_class = nil, &body)
if RSpec.configuration.infer_base_class_for_anonymous_controllers?
base_class ||= controller_class
end
base_class ||= defined?(ApplicationController) ? ApplicationController : ActionController::Base
Method failure_message
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
def failure_message
[].tap do |message|
unless actual.is_a?(expected) && actual.new_record?
message << "expected #{actual.inspect} to be a new #{expected.inspect}"
end
Method controller
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def controller(base_class = nil, &body)
if RSpec.configuration.infer_base_class_for_anonymous_controllers?
base_class ||= controller_class
end
base_class ||= defined?(ApplicationController) ? ApplicationController : ActionController::Base
Method initialize_activerecord_configuration
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def self.initialize_activerecord_configuration(config)
config.before :suite do
if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && defined?(::RSpec::Mocks) && (::RSpec::Mocks.respond_to?(:configuration))
::RSpec::Mocks.configuration.when_declaring_verifying_double do |possible_model|
Method name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def self.name
root_controller = defined?(ApplicationController) ? ApplicationController : ActionController::Base
if superclass == root_controller || superclass.abstract?
"AnonymousController"
else
Method check
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def check(messages)
@matching_msgs, @unmatching_msgs = messages.partition do |msg|
decoded = ActiveSupport::JSON.decode(msg)
decoded = decoded.with_indifferent_access if decoded.is_a?(Hash)
Method _default_render_options
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def _default_render_options
formats = if ActionView::Template::Types.respond_to?(:symbols)
ActionView::Template::Types.symbols
else
[:html, :text, :js, :css, :xml, :json].map(&:to_s)
Method initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def initialize(*assertion_modules)
assertion_class = Class.new(SimpleDelegator) do
include ::RSpec::Rails::Assertions
include ::RSpec::Rails::MinitestCounters
assertion_modules.each { |mod| include mod }
Method base_message
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def base_message
"#{message_expectation_modifier} #{@expected_number} jobs,".tap do |msg|
msg << " with #{@args}," if @args.any?
msg << " on queue #{@queue}," if @queue
msg << " at #{@at.inspect}," if @at
Method passed?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def passed?
return false if RSpec.current_example.exception
return true unless defined?(::RSpec::Expectations::FailureAggregator)
failure_notifier = ::RSpec::Support.failure_notifier
Method rails_fixture_file_wrapper
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def rails_fixture_file_wrapper
RailsFixtureFileWrapper.fixture_path = nil
resolved_fixture_path =
if respond_to?(:fixture_path) && !fixture_path.nil?
fixture_path.to_s
Method generate_view_specs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def generate_view_specs
return if options[:api]
return unless options[:view_specs] && options[:template_engine]
copy_view :edit
Method at_match?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def at_match?(job)
return true unless @at
return job[:at].nil? if @at == :no_wait
return false unless job[:at]
Method base_message
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def base_message
[mailer_class_name, @method_name].compact.join('.').tap do |msg|
msg << " #{expected_count_message}"
msg << " with #{@mail_args}," if @mail_args.any?
msg << " on queue #{@queue}," if @queue