Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Check to see that the necessary modules are actually loaded before extending #467

Merged
merged 2 commits into from

2 participants

@jasonmk

In our setup, there are times when we load pieces of ActiveRecord but not the entire thing. For example, we have a plugin that does all its work over ActiveResource but still pulls in ActiveRecord's DynamicFinderMatch class to avoid having to reimplement the functionality. However, if our app isn't using ActiveRecord, then RSpec fails to load. The attached changes solve the problem by checking for the needed parts of ActiveRecord instead of if the top-level constant exists.

@dchelimsky dchelimsky merged commit ffdac58 into rspec:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 1, 2011
  1. @jasonmk

    Check to see if the module we're actually working with is loaded (in …

    jasonmk authored
    …case only pieces of ActiveRecord are loaded).
  2. @jasonmk

    Check to see if the module we're actually working with is loaded (in …

    jasonmk authored
    …case only pieces of ActiveRecord are loaded).
This page is out of date. Refresh to see the latest.
View
2  lib/rspec/rails/fixture_support.rb
@@ -1,6 +1,6 @@
module RSpec
module Rails
- if defined?(ActiveRecord)
+ if defined?(ActiveRecord::TestFixtures)
module FixtureSupport
extend ActiveSupport::Concern
View
2  lib/rspec/rails/matchers/relation_match_array.rb
@@ -1,3 +1,3 @@
-if defined?(ActiveRecord)
+if defined?(ActiveRecord::Relation)
RSpec::Matchers::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::MatchArray)
end
Something went wrong with that request. Please try again.