Skip to content

Commit c43051b

Browse files
committed
fixup! Remove hidden Rails < 5 support code
1 parent 1ec8213 commit c43051b

File tree

9 files changed

+9
-38
lines changed

9 files changed

+9
-38
lines changed

example_app_generator/generate_action_mailer_specs.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
require 'active_support'
22
require 'active_support/core_ext/module'
33

4-
# We need to copy this method from Thor for older Rails versions
5-
def comment_lines(path, flag, *args)
6-
flag = flag.respond_to?(:source) ? flag.source : flag
7-
gsub_file(path, /^(\s*)([^#|\n]*#{flag})/, '\1# \2', *args)
8-
end
9-
104
using_source_path(File.expand_path('..', __FILE__)) do
115
# Comment out the default mailer stuff
126
comment_lines 'config/environments/development.rb', /action_mailer/

example_app_generator/spec/support/default_preview_path

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ require_file_stub 'config/environment' do
4747
end
4848
end
4949

50-
I18n.enforce_available_locales = true if I18n.respond_to?(:enforce_available_locales)
50+
I18n.enforce_available_locales = true
5151
end
5252

5353
# Initialize the Rails application.

lib/rspec/rails/adapters.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,11 @@ module ClassMethods
146146
# examples without exposing non-assertion methods in Test::Unit or
147147
# Minitest.
148148
def assertion_method_names
149-
methods = ::RSpec::Rails::Assertions.
149+
::RSpec::Rails::Assertions.
150150
public_instance_methods.
151151
select do |m|
152152
m.to_s =~ /^(assert|flunk|refute)/
153153
end
154-
methods + test_unit_specific_methods
155154
end
156155

157156
def define_assertion_delegators
@@ -161,12 +160,6 @@ def define_assertion_delegators
161160
end
162161
end
163162
end
164-
165-
# Starting on Rails 4, Minitest is the default testing framework so no
166-
# need to add TestUnit specific methods.
167-
def test_unit_specific_methods
168-
[]
169-
end
170163
end
171164

172165
class AssertionDelegator

lib/rspec/rails/example/feature_example_group.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ module FeatureExampleGroup
1515
include app.routes.url_helpers if app.routes.respond_to?(:url_helpers)
1616
include app.routes.mounted_helpers if app.routes.respond_to?(:mounted_helpers)
1717

18-
if respond_to?(:default_url_options)
19-
default_url_options[:host] ||= ::RSpec::Rails::FeatureExampleGroup::DEFAULT_HOST
20-
end
18+
default_url_options[:host] ||= ::RSpec::Rails::FeatureExampleGroup::DEFAULT_HOST
2119
end
2220
end
2321

lib/rspec/rails/example/view_example_group.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ module ExampleMethods
4343

4444
included do
4545
include ::Rails.application.routes.url_helpers
46-
47-
if ::Rails.application.routes.respond_to?(:mounted_helpers)
48-
include ::Rails.application.routes.mounted_helpers
49-
end
46+
include ::Rails.application.routes.mounted_helpers
5047
end
5148

5249
# @overload render
@@ -188,10 +185,7 @@ def _include_controller_helpers
188185

189186
before do
190187
_include_controller_helpers
191-
if view.lookup_context.respond_to?(:prefixes)
192-
# rails 3.1
193-
view.lookup_context.prefixes << _controller_path
194-
end
188+
view.lookup_context.prefixes << _controller_path
195189

196190
controller.controller_path = _controller_path
197191

lib/rspec/rails/extensions/active_record/proxy.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@
22
# Delay this in order to give users a chance to configure `expect_with`...
33
rspec.before(:suite) do
44
if defined?(RSpec::Matchers) && RSpec::Matchers.configuration.syntax.include?(:should) && defined?(ActiveRecord::Associations)
5-
# In Rails 3.0, it was AssociationProxy.
6-
# In 3.1+, it's CollectionProxy.
7-
const_name = [:CollectionProxy, :AssociationProxy].find do |const|
8-
ActiveRecord::Associations.const_defined?(const)
9-
end
10-
11-
proxy_class = ActiveRecord::Associations.const_get(const_name)
12-
13-
RSpec::Matchers.configuration.add_should_and_should_not_to proxy_class
5+
RSpec::Matchers.configuration.add_should_and_should_not_to ActiveRecord::Associations::CollectionProxy
146
end
157
end
168
end

rspec-rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
1111
s.email = "[email protected]"
1212
s.homepage = "https://github.com/rspec/rspec-rails"
1313
s.summary = "RSpec for Rails"
14-
s.description = "rspec-rails is a testing framework for Rails 4+."
14+
s.description = "rspec-rails is a testing framework for Rails 5+."
1515

1616
s.metadata = {
1717
'bug_tracker_uri' => 'https://github.com/rspec/rspec-rails/issues',

spec/generators/rspec/scaffold/scaffold_generator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
it { is_expected.to contain(/assert_select "input\[name=\?\]", "post\[title\]/) }
127127
end
128128
end
129-
when Rails.version.to_f >= 4.0
129+
when Rails.version.to_f >= 5.0
130130
describe 'with reference attribute' do
131131
before { run_generator %w(posts title:string author:references) }
132132
describe 'edit' do

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Application < ::Rails::Application
1111
end
1212
end
1313
end
14-
I18n.enforce_available_locales = true if I18n.respond_to?(:enforce_available_locales)
14+
I18n.enforce_available_locales = true
1515

1616
require 'rspec/support/spec'
1717
require 'rspec/rails'

0 commit comments

Comments
 (0)