如果我有以下模块
module UserSession
$user_array = factory_girl_users.values
def factory_girl_users
Hash[:user_1 => FactoryGirl.attributes_for(:automated_user), :user_2 => FactoryGirl.attributes_for(:automated_user_1)]
end
end
World(UserSession)
我如何访问factory_girl_users方法,就像我正在获取
一样undefined method `factory_girl_users' for UserSession:Module (NoMethodError)
简单的猜测,但不能想到目前的情况
谢谢
答案 0 :(得分:1)
我认为您可以定义模块方法
module UserSession
def self.factory_girl_users
Hash[:user_1 => FactoryGirl.attributes_for(:automated_user), :user_2 => FactoryGirl.attributes_for(:automated_user_1)]
end
def self.user_array
factory_girl_users.values
end
end
要访问user_array
,您需要执行UserSession.user_array
。