mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
c4927b73f2
Rails 4 moved the layouts ivar from `@layouts` to `@_layouts`. This change introduces what I have (for now) called the 'RailsShim'. The idea is that this single class will house the rail version workarounds, which can then be reused through the code. This paid off here because both the spec and the implementation need access to the layouts ivar.
20 lines
325 B
Ruby
20 lines
325 B
Ruby
module Shoulda # :nodoc:
|
|
module Matchers
|
|
class RailsShim # :nodoc:
|
|
|
|
def self.layouts_ivar
|
|
if rails_major_version >= 4
|
|
'@_layouts'
|
|
else
|
|
'@layouts'
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def self.rails_major_version
|
|
Rails::VERSION::MAJOR
|
|
end
|
|
end
|
|
end
|
|
end
|