In Rails 4, the following construct:
has_many :children, conditions: { adopted: true }
changes to:
has_many :children, lambda { where(adopted: true) }
As a result, the way we check the conditions attached to a has_many
changes too: instead of accessing `reflection.options`, we have to use
`reflection.scope` -- this which refers to the lambda above, so we have
to evaluate it and then grab the `where` from the Relation that the
lambda returns.
The "flashes" instance variable that lives within FlashHash has changed
in Rails 4. I have added a shim to get the proper name.
Additionally, the set_the_flash matcher will dup the flash hash for the
controller on which it operates. As #dup does a shallow copy we need to
make sure to also copy the instance variables within the flash hash when
we do this. The Rails 4 version of FlashHash has an extra @discard
variable unlike the Rails 3 version so we make sure to copy that.
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.