1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/lib/shoulda/matchers/rails_shim.rb
Derek Prior c4927b73f2 Fix render_with_layout_matcher on Rails 4.
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.
2013-08-16 15:32:08 -06:00

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