Permalink
Browse files

just ask if AR is defined instead

- Closes #254.
  • Loading branch information...
1 parent b8ae95e commit a5949a566862fa0ac2ec4148f52ea05cc64352a9 @dchelimsky dchelimsky committed Nov 6, 2010
View
@@ -1,13 +1,3 @@
-module RSpec
- module Rails
- class << self
- def using_active_record?
- ::Rails.configuration.generators.options[:rails][:orm] == :active_record
- end
- end
- end
-end
-
require 'rspec/core'
RSpec::configure do |c|
@@ -1,6 +1,6 @@
module RSpec
module Rails
- if using_active_record?
+ if defined?(ActiveRecord)
module Extensions
module ActiveRecord
# :call-seq:
@@ -1,6 +1,6 @@
module RSpec
module Rails
- if using_active_record?
+ if defined?(ActiveRecord)
module FixtureSupport
extend ActiveSupport::Concern
View
@@ -70,7 +70,7 @@ def mock_model(string_or_model_class, stubs = {})
m.extend ActiveModelInstanceMethods
m.singleton_class.__send__ :include, ActiveModel::Conversion
m.singleton_class.__send__ :include, ActiveModel::Validations
- if RSpec::Rails::using_active_record?
+ if defined?(ActiveRecord)
m.extend ActiveRecordInstanceMethods
[:save, :update_attributes].each do |key|
if stubs[key] == false
@@ -175,7 +175,7 @@ def connection
def stub_model(model_class, stubs={})
model_class.new.tap do |m|
m.extend ActiveModelStubExtensions
- if RSpec::Rails::using_active_record? && model_class < ActiveRecord::Base
+ if defined?(ActiveRecord) && model_class < ActiveRecord::Base
m.extend ActiveRecordStubExtensions
primary_key = model_class.primary_key.to_sym
stubs = stubs.reverse_merge(primary_key => next_id)

0 comments on commit a5949a5

Please sign in to comment.