How to test Strong Parameters with RSpec

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.

Hey @nafaabout, shoulda-matchers has a matcher for testing strong params:

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.

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.

1 Like