Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Add cleaning_with method

未關閉
#425 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
42/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
ruby
領域
testing

研究方向

先閱讀 issue 所參照的現有 cleaning 與 strategy API,尤其是 Base 和模組層級的 DatabaseCleaner 進入點。在不全域變更 strategy 的情況下,加入所要求的每個 test 清理行為,然後透過針對兩個進入點的聚焦測試,確認它能在所有已設定的 connection 上正常運作。

由索引模型根據 Issue 內容生成。

描述

Hi,

I'm slowly transitioning my tests to use transaction based cleaning instead of truncation. To do this, I'm currently using an around method which will use the strategy I want only for that test;

around(:each) { |example| DatabaseCleaner.cleaning_with(:transaction, &example) }

This is my extension:

module DatabaseCleaner
  class Base
    def cleaning_with(*args, &block)
      create_strategy(*args).cleaning(&block)
    end
  end

  class << self
    def cleaning_with(*args, &inner_block)
      connections.reduce(inner_block) do |curr_block, connection|
        proc { connection.cleaning_with(*args, &curr_block) }
      end.call
    end
  end
end

Would you consider adding this to the project itself? Btw, I realise doing this introduces some code repetition, I haven't yet looked at that because I didn't want to touch the original source code yet ;-)

主要語言
Ruby
星號
3k
分支
485
PR 合併指標
30 天內沒有已合併 PR

環境準備

我們還沒有檢查這個專案的環境設定檔。先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

DatabaseCleaner/database_cleaner 的其他 Issue

查看 DatabaseCleaner/database_cleaner 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。