开发者

Rspec Faker has_one fail in view

开发者 https://www.devze.com 2022-12-22 13:16 出处:网络
I开发者_如何学编程\' trying to fix this for hours... I have this on a controller rspec test: it \"show action should render show template\" do

I开发者_如何学编程' trying to fix this for hours...

I have this on a controller rspec test:

  it "show action should render show template" do
    task = Task.make
    task.mission = Mission.make
    get :show, :id => task
    response.should render_template(:show)
  end

But it fails rendering the view because of this:

<%=h @task.mission.name %>

I don't get it... :/


I propose to change you factories generation :

task = Task.make(:mission => Mission.make)

The association mission is not save to Task because you don't save it you can try save task after Mission association

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号