Dynamic Hash in Ruby
Youssef Chaker

Sounds like a great case for extracting out a new object, say TestObjectDefinition , that addresses this, and a TestUser class that inherits from or imports from it and defers to the relevant model class:

class TestUser < TestObjectDefinition.new(User)
def initialize(default_params = {})
self.default_params = default_params
  def seed(specific_params)
load_or_create default_params.merge(specific_params)
# ...

Which would tidy up those seeds significantly:

user = TestUser.initialize(default: true)
user.seed(default: false, foo: 'Foo!')
Like what you read? Give Corey Ward a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.