RubyMine 2024.1 Help

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:

  1. In a spec file, select a required code fragment and select Refactor | Extract/Introduce | RSpec 'let' ⌘ ⇧ L from the main menu.

  2. Specify the desired name of a helper method and press Enter.

  3. If more than one occurrence of the code fragment is found, RubyMine will suggest replacing these occurrences with a helper method call.

    Extract method

    Click Yes to replace the found occurrences. If you want to replace the selected occurrence only, click No.


describe "GetTime" do it "gets the same time" do puts sleep(3) puts end end
describe "GetTime" do let(:current_time) { } it "gets the same time" do puts current_time sleep(3) puts current_time end end
Last modified: 08 April 2024