【发布时间】:2015-09-19 01:40:55
【问题描述】:
describe User do
it { should belong_to(:shop) }
it { should respond_to(:shop) }
it { should respond_to (:first_name)}
it { should respond_to (:last_name)}
it { should respond_to (:email)}
工作正常。但只要我添加:
it { should validate_presence_of (:first_name)}
it { should validate_presence_of (:last_name)}
它坏了,特别是在这个回调方法中:
def get_url
source = "http://www.randomsite.com/"+ first_name + "+" + last_name
end
对于 + 没有将 nil 隐式转换为字符串
我该如何解决这个问题?
【问题讨论】:
标签: ruby-on-rails rspec shoulda