Skip to content

Instantly share code, notes, and snippets.

View paulkoegel's full-sized avatar

Paul Kögel paulkoegel

View GitHub Profile
@paulkoegel
paulkoegel / strong_parameter_matcher.rb
Created September 12, 2013 16:01 — forked from DonSchado/example_spec.rb
Thoughtbot retracted their initial implementation of strong parameters matchers in v2.0.0 of shoulda-matchers, so we decided to build our own until new officail ones are released. The following is a small matcher for testing what params should be permitted in controllers. The matcher's syntax is based on validation matchers. If you're not follow…
# usage:
#
# it { should permit_params(:email, :name) }
# it { should permit_params(:email, :name).for_class(SpecialUser) }
# it { should permit_params(:name).params_method(:my_params_method) }
module StrongParameterMatcher
class PermitMatcher
attr_reader :permitted_params, :errors_protected, :errors_permitted