Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old predicates before redefining #2354

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/rspec/rails/configuration.rb
Expand Up @@ -56,7 +56,7 @@ def self.add_test_type_configurations(config)
end

# @private
def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength
def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity
config.backtrace_exclusion_patterns << /vendor\//
config.backtrace_exclusion_patterns << %r{lib/rspec/rails}

Expand Down Expand Up @@ -109,6 +109,7 @@ def render_views?
rendering_views?
end

undef :rendering_views? if respond_to?(:rendering_views?)
def rendering_views?
!!rendering_views
end
Expand All @@ -117,22 +118,27 @@ def rendering_views?
# to the bug fix in rspec/rspec-core#2736, note some of these
# predicates are a bit nonsensical, but they exist for backwards
# compatibility, we can tidy these up in `rspec-rails` 5.
undef :fixture_path? if respond_to?(:fixture_path?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the fence between this and

config.singleton_class.class_eval { attr_accessor :fixture_path }
# ...
def fixture_path?
  !!fixture_path
end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not, I want to stick with add_setting as much as possible, these work arounds will be removed in the next version major version of rspec-rails.

def fixture_path?
!!fixture_path
end

undef :global_fixtures? if respond_to?(:global_fixtures?)
def global_fixtures?
!!global_fixtures
end

undef :infer_base_class_for_anonymous_controllers? if respond_to?(:infer_base_class_for_anonymous_controllers?)
def infer_base_class_for_anonymous_controllers?
!!infer_base_class_for_anonymous_controllers
end

undef :use_instantiated_fixtures? if respond_to?(:use_instantiated_fixtures?)
def use_instantiated_fixtures?
!!use_instantiated_fixtures
end

undef :use_transactional_fixtures? if respond_to?(:use_transactional_fixtures?)
def use_transactional_fixtures?
!!use_transactional_fixtures
end
Expand Down