No commit activity in last 3 years
No release in over 3 years
This gem defines custom matchers that can be used to test execution of filters before, around or after controller actions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0

Runtime

>= 3.1, ~> 3
 Project Readme

Rspec::Matchers::ControllerFilters Gem Version Build Status

Use this gem to test the execution of before/around/after filters of your controller actions with RSpec.

Here's a post describing the general idea of the gem: https://iridakos.com/how-to/2014/10/14/testing-execution-of-filters-with-rspec.html

Installation

Add this line to your application's Gemfile:

gem 'rspec-matchers-controller_filters'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rspec-matchers-controller_filters

Usage

In your controller specs you may use the new matchers:

it { should execute_before_action :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
it { should_not execute_around_action :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
it { should execute_after_action :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }

The with parameter is optional.

Contributing

  1. Fork it ( https://github.com/iridakos/rspec-matchers-controller_filters/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

This gem is open source under the MIT License terms.