Skip to content

Instantly share code, notes, and snippets.

@mz026
Created November 18, 2014 03:55
Show Gist options
  • Save mz026/33430e40db74124f50b7 to your computer and use it in GitHub Desktop.
Save mz026/33430e40db74124f50b7 to your computer and use it in GitHub Desktop.
RSpec required in controller params
# Usage:
# include_examples 'require_in_params', :tag, ->(group) { post :create, params }
shared_examples "require_in_params" do |attr, block|
it "returns 400 if no `#{attr}` in params" do
params.delete attr
self.instance_eval &block
expect(response.status).to eq(400)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment