https://github.com/iridakos/rspec-matchers-controller_filters
Test execution of before/around and after filters of controller actions with RSpec
https://github.com/iridakos/rspec-matchers-controller_filters
Last synced: about 2 months ago
JSON representation
Test execution of before/around and after filters of controller actions with RSpec
- Host: GitHub
- URL: https://github.com/iridakos/rspec-matchers-controller_filters
- Owner: iridakos
- License: mit
- Created: 2015-03-08T21:31:32.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-04-18T13:41:31.000Z (about 7 years ago)
- Last Synced: 2024-04-24T13:16:15.316Z (about 1 year ago)
- Language: Ruby
- Homepage: https://iridakos.com/how-to/2014/10/14/testing-execution-of-filters-with-rspec.html
- Size: 11.7 KB
- Stars: 23
- Watchers: 6
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Rspec::Matchers::ControllerFilters [](https://badge.fury.io/rb/rspec-matchers-controller_filters) [](https://travis-ci.org/iridakos/rspec-matchers-controller_filters)
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](https://iridakos.com/how-to/2014/10/14/testing-execution-of-filters-with-rspec.html)## Installation
Add this line to your application's Gemfile:
```ruby
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:
```ruby
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](https://opensource.org/licenses/MIT) terms.