Build model with nested model in rspec integration test

Posted by user1116573 on Stack Overflow See other posts from Stack Overflow or by user1116573
Published on 2012-09-29T09:20:59Z Indexed on 2012/09/29 9:37 UTC
Read the original article Hit count: 160

I understand that I can do something like in rspec:

let(:project) { Project.new }

but in my app a project accepts_nested_attributes_for tasks and when I generate the Project form I build a task along with it using:

@project = Project.new
@project.tasks.build

I need something like:

let(:project) { Project.new.tasks.build }

but that doesn't seem to work.

How can I do this as a let in my rspec test?

© Stack Overflow or respective owner

Related posts about ruby-on-rails-3

Related posts about rspec