Use this gem to test execution of before/around/after filters of controller actions with RSpec. http://www.arubystory.com/2014/10/testing-execution-of-beforefilter-with.html
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
In your controller specs you may use the new matchers:
it { should execute_before_filter :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
it { should_not execute_around_filter :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
it { should execute_after_filter :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
The with parameter is optional.
- Fork it ( https://github.com/iridakos/rspec-matchers-controller_filters/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
This is my first gem so please:
- Use it at your own risk
- Any feedback is welcome!