I have a factory module which returns class, like this
# frozen_string_literal: truemodule Factory module Subscriptions module SubscriptionSelector class << self def select_by_plan_type_for_subscription(plan) case plan.type when 'UpsellSubscription' UpsellSubscription else NewSubscription end end end end endend
and I am using this module like this
subscription = Factory::Subscriptions::SubscriptionSelector .select_by_plan_type_for_subscription(plan) .create!( account: account, product: plan.product, status: 'active', active_plan: plan, active_plan_end_date: end_date, renewal_date: end_date )
but somehow my tests are failing with NameError: uninitialized constant Factory::Subscriptions::SubscriptionSelector
both NewSubscription and UpsellSubscription are ActiveRecord and they share same logics via concern
Trying to write factory method for dynamically class calling