Extract RSpec 'let'
The Extract RSpec 'let' refactoring allows you to extract a specified code fragment into a memoized helper method. To do this, perform the following steps:
In a spec file, select a required code fragment and select
Meta+Shift+L from the main menu.Specify the desired name of the helper method and press Enter.
(Optional) If more than one occurrence of the code fragment is found, RubyMine will show the following dialog.
Click Yes to replace the found occurrences with a helper method call. If you want to replace only the selected occurrence, click No.
(Optional) If you clicked Yes in the previous step, RubyMine suggests replacing the found occurrences one by one or all at a time.