mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
c6e1f86fa6
Under Rails 3 when using an association matcher in conjunction with a submatcher such as #order, we have to take the options on the association (:conditions, :order, etc.) and convert them to an ActiveRecord::Relation object. This happens in ModelReflector. Unfortunately, converting an :includes option was broken. This is in part due to ModelReflector not having proper tests, but also, the method that does the conversion to Relation is rather complex and could be broken up so it can be tested better. In fact I noticed that there's a lot of stuff in ModelReflector that does stuff around a Reflection object, so it would be better to define a ModelReflection class that simply decorates a Reflection. That's what I've done and also added proper tests.
18 lines
368 B
Ruby
18 lines
368 B
Ruby
module RailsVersions
|
|
def rails_version
|
|
Gem::Version.new(Rails::VERSION::STRING)
|
|
end
|
|
|
|
def rails_3_x?
|
|
Gem::Requirement.new('~> 3.0').satisfied_by?(rails_version)
|
|
end
|
|
|
|
def rails_4_x?
|
|
Gem::Requirement.new('~> 4.0').satisfied_by?(rails_version)
|
|
end
|
|
end
|
|
|
|
RSpec.configure do |config|
|
|
config.include(RailsVersions)
|
|
config.extend(RailsVersions)
|
|
end
|