Skip to content

Instantly share code, notes, and snippets.

@germs12
Last active February 14, 2017 22:38
Show Gist options
  • Save germs12/f64bec8ad131677cfa640f2319ee2d1f to your computer and use it in GitHub Desktop.
Save germs12/f64bec8ad131677cfa640f2319ee2d1f to your computer and use it in GitHub Desktop.
Fix rails 5.1 rspec warnings

Fixing this issue...

DEPRECATION WARNING: Using positional arguments in functional tests has been deprecated,
in favor of keyword arguments, and will be removed in Rails 5.1.

Deprecated style:
get :show, { id: 1 }, nil, { notice: "This is a flash message" }

New keyword style:
get :show, params: { id: 1 }, flash: { notice: "This is a flash message" },
  session: nil # Can safely be omitted.

FIND #1:

^(.*(?:get|post|put|delete).*(?::index|:show),)(.*)$

FIND #2:

^(\s*(?:get|post|put|delete).*(?::[a-z_]+),)(.*(?:}|json|id))$

REPLACE:

$1 params: {$2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment