Skip to content

Commit 4babeed

Browse files
dpoguealindeman
authored andcommitted
Change some version checks to use ActiveRecord.
This allow using ActiveRecord fixtures without pulling in all of Rails.
1 parent 9764f3d commit 4babeed

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Bug fixes
1010

1111
* Fixes "warning: instance variable @orig\_routes not initialized" raised by
1212
controller specs when `--warnings` are enabled. (Andy Lindeman)
13+
* Where possible, check against the version of ActiveRecord, rather than
14+
Rails. It is possible to use some of rspec-rails without all of Rails.
15+
(Darryl Pogue)
1316

1417
### 2.14.0 / 2013-07-06
1518
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.14.0.rc1...v2.14.0)

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 ::Rails::VERSION::STRING < '4'
13+
attr_accessible :name if ::ActiveRecord::VERSION::STRING < '4'
1414
1515
validates_length_of :name, :minimum => 10, :on => :publication
1616
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module ActiveRecord
1010
# ModelClass.should have(:no).records
1111
# ModelClass.should have(1).record
1212
# ModelClass.should have(n).records
13-
if ::Rails::VERSION::STRING >= '4'
13+
if ::ActiveRecord::VERSION::STRING >= '4'
1414
def records
1515
all.to_a
1616
end

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 ::Rails::VERSION::STRING > '4'
7+
include RSpec::Rails::MiniTestLifecycleAdapter if ::ActiveRecord::VERSION::STRING > '4'
88
include RSpec::Rails::TestUnitAssertionAdapter
99
include ActiveRecord::TestFixtures
1010

0 commit comments

Comments
 (0)