require 'pry' require 'factory_bot' module PryFactoryBot # TODO FactoryBot::Internal::DEFAULT_STRATEGIESでとれるようになるかも? DEFAULT_STRATEGIES_NAMES = [:build, :create, :attributes_for, :build_stubbed, :null].freeze Commands = Pry::CommandSet.new do DEFAULT_STRATEGIES_NAMES.each do |strategy| command "#{strategy}", "FactoryBot.#{strategy}" do FactoryBot.class_eval <<-EOS #{Readline::HISTORY.to_a.last.strip} EOS end end end end Pry.config.commands.import PryFactoryBot::Commands