Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Improve DatabaseCleaner Configuration API

Aperta
#546 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
ruby
Ambito
testing

Direzione di ricerca

La issue non indica file di implementazione o test; inizia esaminando l’attuale API di configurazione di DatabaseCleaner ::[] e i relativi casi d’uso documentati. La direzione proposta è ancora in attesa di feedback e non è stata prototipata, quindi per considerarla completata sarebbero necessari un design dell’API concordato e un comportamento validato per tutte le configurazioni semplici e complesse elencate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Way back in 2012, 016d66c4c9621fceadbebeb80feb5744d810c681 changed the ::[] API to act as both a command and query, in a decision based on pragmatism. At the time, @bmabey noted his dislike for this, and his desire to deprecate it. Now that we're talking about a v2.0 release, I think this is a good time to talk about improving this situation in a backwards-incompatible way.

I have an alternative API proposal that I've been exploring, which splits the ::[] method into ::[] for queries, and ::[]= for commands. Complex configuration is also simplified to a hash, or array of hashes:

# simple config
DatabaseCleaner[:active_record].strategy = :truncation
# complex config
DatabaseCleaner[:active_record] = {
  connection: :test,
  strategy: :truncation,
  except: %w[goats donkeys],
}
# complex multiple db config
DatabaseCleaner[:active_record] = [
  { connection: :test, strategy: :truncation, except: %w[goats donkeys] },
  { connection: :test_2, strategy: :transaction },
]

I have been working on a document exploring what this API change would look like for DatabaseCleaner's many different use-cases, ranging from the most simplistic all the way up to very complex multiple ORM and database configuration, and this seems like this could work well, while also simplifying internals. I haven't prototyped it yet to confirm, but I even think its possible to add API this to the 1.x series in a backwards-compatible way, which would ease the v2.0 transition.

However, I want to get some feedback on this general direction before going too deep down the rabbit hole. Perhaps there is already an alternative API that you folks have in mind? Or perhaps we don't want to change the API at all at this point? But if this API looks promising, I'll post the document, and we can go from there!

Lingua principale
Ruby
Stelle
3k
Fork
484
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DatabaseCleaner/database_cleaner

Tutte le issue di DatabaseCleaner/database_cleaner

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.