我应怎样看待这一nes建:
#projects_controller.rb
def new
@account.projects.build
end
到目前为止,我有这样的情况:
#projects_controller_spec.rb
describe ProectssController do
describe "GET new" do
let(:account) { mock_model(Account) }
let(:project) { mock_model(Project).as_null_object }
before do
Account.stub(:find_by_subdomain!).and_return(account)
#Project.should_receive(:build).with(:account_id => account.id).and_return(project)
end
it "assigns @project" do
get :new
assigns[:project].should eq(project)
end
end
end
不要确定我应如何看待这一点......