Skip to content

Commit 412a3a7

Browse files
committed
Rely on ::Rails::VERSION::STRING instead of an overly complex module
* I did not know about ::Rails::VERSION::STRING until recently. It seems to be defined all the way back to 3.0.0, which is all we need.
1 parent 6ac1262 commit 412a3a7

File tree

14 files changed

+11
-61
lines changed

14 files changed

+11
-61
lines changed

features/model_specs/errors_on.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Feature: errors_on
1010
validates_presence_of :name
1111
1212
# In Rails 4, mass assignment protection is implemented on controllers
13-
attr_accessible :name if RSpec::Rails.rails_version_satisfied_by?('< 4.0.0.beta1')
13+
attr_accessible :name if ::Rails::VERSION::STRING < '4'
1414
1515
validates_length_of :name, :minimum => 10, :on => :publication
1616
end

lib/generators/rspec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'rails/generators/named_base'
2-
require 'rspec/rails/rails_version'
32

43
module Rspec
54
module Generators
@@ -8,7 +7,7 @@ def self.source_root
87
@_rspec_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'rspec', generator_name, 'templates'))
98
end
109

11-
if RSpec::Rails.rails_version_satisfied_by?('< 3.1')
10+
if ::Rails::VERSION::STRING < '3.1'
1211
def module_namespacing
1312
yield if block_given?
1413
end

lib/generators/rspec/install/install_generator.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'rspec/rails/rails_version'
2-
31
module Rspec
42
module Generators
53
class InstallGenerator < ::Rails::Generators::Base

lib/generators/rspec/install/templates/spec/spec_helper.rb.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require 'rspec/autorun'
88
# in spec/support/ and its subdirectories.
99
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
1010

11-
<% if RSpec::Rails.rails_version_satisfied_by?('>= 4.0.0.beta1') -%>
11+
<% if ::Rails::VERSION::STRING >= '4' -%>
1212
# Checks for pending migrations before tests are run.
1313
# If you are not using ActiveRecord, you can remove this line.
1414
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

lib/generators/rspec/scaffold/templates/controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
# specifies that the <%= class_name %> created on the previous line
110110
# receives the :update_attributes message with whatever params are
111111
# submitted in the request.
112-
<%- if RSpec::Rails.rails_version_satisfied_by?('>= 4.0.0.beta1') -%>
112+
<%- if ::Rails::VERSION::STRING >= '4' -%>
113113
<%= class_name %>.any_instance.should_receive(:update).with(<%= formatted_hash(example_params_for_update) %>)
114114
<%- else -%>
115115
<%= class_name %>.any_instance.should_receive(:update_attributes).with(<%= formatted_hash(example_params_for_update) %>)

lib/rspec/rails.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
c.backtrace_exclusion_patterns << /lib\/rspec\/rails/
66
end
77

8-
require 'rspec/rails/rails_version'
8+
require 'rails/version'
99
require 'rspec/rails/extensions'
1010
require 'rspec/rails/view_rendering'
1111
require 'rspec/rails/adapters'

lib/rspec/rails/example/rails_example_group.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Temporary workaround to resolve circular dependency between rspec-rails' spec
22
# suite and ammeter.
33
require 'rspec/rails/matchers'
4-
require 'rspec/rails/rails_version'
54

65
module RSpec
76
module Rails
87
module RailsExampleGroup
98
extend ActiveSupport::Concern
109
include RSpec::Rails::SetupAndTeardownAdapter
11-
include RSpec::Rails::MiniTestLifecycleAdapter if RSpec::Rails.rails_version_satisfied_by?('>= 4.0.0.beta1')
10+
include RSpec::Rails::MiniTestLifecycleAdapter if ::Rails::VERSION::STRING >= '4'
1211
include RSpec::Rails::TestUnitAssertionAdapter
1312
include RSpec::Rails::Matchers
1413
end

lib/rspec/rails/example/view_example_group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _default_file_to_render
107107
end
108108

109109
def _default_render_options
110-
if RSpec::Rails.rails_version_satisfied_by?('>= 3.2')
110+
if ::Rails::VERSION::STRING >= '3.2'
111111
# pluck the handler, format, and locale out of, eg, posts/index.de.html.haml
112112
template, *components = _default_file_to_render.split('.')
113113
handler, format, locale = *components.reverse

lib/rspec/rails/fixture_support.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Rails
44
module FixtureSupport
55
extend ActiveSupport::Concern
66
include RSpec::Rails::SetupAndTeardownAdapter
7-
include RSpec::Rails::MiniTestLifecycleAdapter if RSpec::Rails.rails_version_satisfied_by?('>= 4.0.0.beta1')
7+
include RSpec::Rails::MiniTestLifecycleAdapter if ::Rails::VERSION::STRING > '4'
88
include RSpec::Rails::TestUnitAssertionAdapter
99
include ActiveRecord::TestFixtures
1010

lib/rspec/rails/rails_version.rb

Lines changed: 0 additions & 17 deletions
This file was deleted.

spec/generators/rspec/install/install_generator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
File.read( file('spec/spec_helper.rb') ).should =~ /^require 'rspec\/autorun'$/m
1717
end
1818

19-
if RSpec::Rails.rails_version_satisfied_by?('>= 4.0.0.beta1')
19+
if ::Rails::VERSION::STRING >= '4'
2020
it "generates spec/spec_helper.rb with a check for pending migrations" do
2121
run_generator
2222
File.read( file('spec/spec_helper.rb') ).should =~ /ActiveRecord::Migration\.check_pending!/m

spec/rspec/rails/example/view_example_group_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def _assigns
118118
view_spec.stub(:_default_file_to_render) { "widgets/new.en.html.erb" }
119119
view_spec.render
120120

121-
if RSpec::Rails.rails_version_satisfied_by?('>= 3.2')
121+
if ::Rails::VERSION::STRING >= '3.2'
122122
view_spec.received.first.should == [{:template => "widgets/new", :locales=>['en'], :formats=>['html'], :handlers=>['erb']}, {}, nil]
123123
else
124124
view_spec.received.first.should == [{:template => "widgets/new.en.html.erb"}, {}, nil]

spec/rspec/rails/matchers/relation_match_array_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
let!(:models) { Array.new(3) { MockableModel.create } }
77

8-
if RSpec::Rails.rails_version_satisfied_by?('>= 4.0.0.beta1')
8+
if ::Rails::VERSION::STRING >= '4'
99
it "verifies that the scope returns the records on the right hand side, regardless of order" do
1010
MockableModel.all.should =~ models.reverse
1111
end

spec/rspec/rails/rails_version_spec.rb

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)