Add cleaning_with method
還沒有人認領這個 Issue。
評估
研究方向
先閱讀 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,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
DatabaseCleaner/database_cleaner 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 67/100
-
難度 4/5 3-5 天 新手友好度 25/100
-
難度 3/5 1-2 天 新手友好度 45/100
-
難度 4/5 3-5 天 新手友好度 35/100
DatabaseCleaner/database_cleaner#717 · 5 則留言 · 1 個 reaction ·
-
難度 4/5 3-5 天 新手友好度 25/100
DatabaseCleaner/database_cleaner#716 · 2 則留言 ·
查看 DatabaseCleaner/database_cleaner 的全部 Issue
相似的 Issue
-
security
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
OSCON 2016未關閉content
難度 2/5 1-3 小時 新手友好度 68/100
rubyevents/rubyevents#2148 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
we-promise/sure#3838 · 2 則留言 ·
維護者通常 1 天內回覆
-
Mend: dependency security vulnerability
難度 2/5 1-3 小時 新手友好度 68/100
ManageIQ/manageiq-ui-classic#10341 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
rubocop/ruby-style-guide#984 ·