Adds several additional operations useful for customizing your Rails middleware stack.
gem install rails-middleware-extensions
Just add this gem to your gemfile like so:
Currently two extensions are supported:
Insert Unless Exists
As the name implies, the given middleware will only be inserted if it has not already been added to the middleware stack. For example, here's how we might insert our custom
MyCustomMiddleware middleware before
#insert_unless_exists supports all the arguments regular 'ol
#insert supports, meaning you can also pass an index to insert before. Here's how to insert our custom middleware at the very beginning of the stack:
#insert_after_unless_exists to insert a particular middleware after another one. For example, to insert
As of Rails 5.0, it's not possible to delete a middleware and then re-add it (see this issue) because delete operations are always applied last. Instead, consider using
#move. For example, to move our custom middleware before
#move_after, to move a piece of middleware after another:
#move_after also support numeric indices:
bundle exec rspec should do the trick :) Rails-middleware extensions supports a number of Rails versions, hence all the Gemfiles. There is one Gemfile per supported Rails version. If you'd like to run tests against a particular version, use the
BUNDLE_GEMFILE environment variable like so:
BUNDLE_GEMFILE=Gemfile-rails-4.1.x bundle exec rspec
By default tests will run against Rails 5.2.x.
Licensed under the MIT license. See LICENSE for details.
- Cameron C. Dutro: http://github.com/camertron