expect_checkout_and_pull

in spec/lib/gdk/project/git_worktree_spec.rb [215:241]


    def expect_checkout_and_pull(checkout_success: true, pull_success: true)
      checkout_stderr = checkout_success ? '' : 'checkout failed'
      expect_shellout("git checkout #{revision}", success: checkout_success, stderr: checkout_stderr)

      if checkout_success
        expect(GDK::Output).to receive(:success).with("Successfully fetched and checked out '#{revision}' for '#{short_worktree_path}'")

        if %w[master main].include?(revision)
          pull_stderr = pull_success ? '' : 'pull failed'
          command = %w[git pull --ff-only]
          command = %w[git pull --ff-only test-origin master] if expected_fetch_type == :fast
          expect_shellout(command, success: pull_success, stderr: pull_stderr,
            args: { retry_attempts: described_class::NETWORK_RETRIES })

          if pull_success
            expect(GDK::Output).to receive(:success).with("Successfully pulled (--ff-only) for '#{short_worktree_path}'")
          else
            expect(GDK::Output).to receive(:puts).with(pull_stderr, stderr: true)
            expect(GDK::Output).to receive(:error).with("Failed to pull (--ff-only) for for '#{short_worktree_path}'", pull_stderr)
          end
        end
      else
        expect(GDK::Output).to receive(:puts).with(checkout_stderr, stderr: true)
        expect(GDK::Output).to receive(:error).with("Failed to fetch and check out '#{revision}' for '#{short_worktree_path}'", checkout_stderr)
      end
    end