我知道我可以用它assigns
来查看实例变量是否被分配给某个东西,但是我如何测试另一个属性是否已设置?
class UsersController < ApplicationController
def new
@user = User.new
@user.name = "Tom Lehrer"
end
end
describe UsersController do
it "assigns a user" do
get :new
expect(assigns(:user)).to be_a_new(User)
end
it "sets the new users name" do
# ??
end
end