Created
April 12, 2017 09:40
-
-
Save suchov/cb964b629d4baf2509478935257b2f3a to your computer and use it in GitHub Desktop.
Extracting Helper Methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Common helper methods should be extracted to `spec/support`, where they can be | |
| organized by utility and automatically included into a specific subset of the tests. | |
| # spec/support/kaminari_helper.rb | |
| module KaminariHelper | |
| def with_kaminari_per_page(value, &block) | |
| old_value = Kaminari.config.default_per_page | |
| Kaminari.config.default_per_page = value | |
| block.call | |
| ensure | |
| Kaminari.config.default_per_page = old_value | |
| end | |
| end | |
| RSpec.configure do |config| | |
| config.include KaminariHelper, type: :request | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment