ajvargo / ruby-refactor

A minor mode for Emacs that provides some Ruby refactoring methods.
63 stars 19 forks source link

Extract to Method doesn't work if in a test/spec file #28

Closed jmromer closed 7 years ago

jmromer commented 8 years ago

Given the following (for example):

  test "is always created with default expiry time" do
    @current_time = Time.local(2020, 11, 10)
    @expire_time = @current_time + RepositoryUnlock::DEFAULT_EXPIRY

    Timecop.freeze(current_time) do
      unlock = RepositoryUnlock.create_unlock(@staff, @staff_grant, @reason)
      assert_equal unlock.repository, @repo
      assert_equal unlock.reason, @reason
      assert_equal unlock.expires_at, @expire_time
    end
  end

Selecting the top two lines and running ruby-refactor-extract-to-method prompts for a method name and argument list as it normally does, and replaces the selection with the method name:

  test "is always created with default expiry time" do
    setup_steps
    # . . .

But doesn't actually insert the method definition anywhere, echoing the following error message:

Search failed: "^\\s *def"