我正在使用Ruby on Rails 3.0.10,RSpec 2和FactoryGirl。我正在尝试验证用户帐户数据。
在我的模特中,我有:
class Users::Account < ActiveRecord::Base
...
def get_account_password_salt(password)
make_user_account_password_salt(password)
end
end
在我的spec文件中我有
it "should have a valid password salt" do
users_account.password_salt.should == Users::Account.get_account_password_salt('123456')
end
当我运行rspec
命令时,出现以下错误:
Users::Account should have a valid password salt
Failure/Error: users_account.password_salt.should == Users::Account.get_account_password_salt('123456')
NoMethodError:
undefined method `get_account_password_salt' for #<Class:0x0000010729c9f0>
问题是什么?如何解决?
我还尝试使用::Users::Account.get_account_password_salt('123456')
(请注意开头的::
),但它仍然不起作用。
答案 0 :(得分:0)
<强>解强>
问题在于我必须运行
users_account.get_account_password_salt('123456')
而不是:
Users::Account.get_account_password_salt('123456')