← Back to Upcase

How to test Strong Parameters with RSpec


(Nafaa Boutefer) #1

I am writing an application folowing TDD/BDD, and using RSpec for that. I reached the point where I need to test the strong parameters filtering function. Is it worthy to do that? if so how can I do it? I know about the permit matcher from shoulda-matchers gem? but I am wondering what other methods I can use to do that.


(Geoff Harcourt) #2

Hey @nafaabout, shoulda-matchers has a matcher for testing strong params: http://robots.thoughtbot.com/shoulda-matchers-2-6-0


(Nafaa Boutefer) #3

Thank you Geoff, I know about the permit matcher of shoulda-matchers, but I want to know, how can I test it without using shoulda-matchers.


(Derek Prior) #4

I don’t think I’ve ever explicitly tested strong parameters. Instead, I configure them to raise in dev and test when there are unpermitted parameters and then drive the functionality that way, usually via feature specs.