title: RSpec / FactoryGirl - How to pass params in post request spec
body: <p>I have a Rails API backend set up with restful routes. I'm trying to pass in parameters for a post request spec, but I've run into some troubles.</p>
  
  <p>In my app a user has many timelines, and a timeline has many entries.
  I can correctly create a timeline with a post request by doing the following:</p>
  
  <pre><code>post '/timelines', '{ "timeline": { "title":"My timeline", "body":"My timeline body"}}', @token_header
  </code></pre>
  
  <p>The problem i have is when i have to pass more than just string, i.e. an image. My entry model has an <code>image</code> attribute, but I can't figure out how to pass in into the parameters.</p>
  
  <p>I have the following test which illustrates what i want to do. As you can see I've declared some entry_attributes but I can't figure out how to correctly pass them as I did with the timeline params.:</p>
  
  <pre><code>    context 'POST /timelines/:id/entries' do
            it 'creates an entry for the given timeline' do
              entry_attr = FactoryGirl.attributes_for(:entry)
              post "/timelines/#{@timeline.id}/entries", {}, @token_header
  
              expect(response.status).to eq 201
            end
      end
  </code></pre>
  
  <p>Any help is greatly appreciated...</p>