Created
August 8, 2014 11:09
-
-
Save rummelonp/d317832b022f9131e604 to your computer and use it in GitHub Desktop.
RSpec 3 で default_params
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
module DefaultParamsHelpers | |
extend ActiveSupport::Concern | |
included do | |
let(:default_params) { {} } | |
alias_method_chain :process, :default_params | |
end | |
private | |
def process_with_default_params(action, http_method = 'GET', *args) | |
parameters = args.shift | |
parameters = default_params.reverse_merge(parameters || {}) | |
args.unshift(parameters) | |
process_without_default_params(action, http_method, *args) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment