title: RSpec: undefined method for #<ActionController::TestResponse. Testing a dynamic flash message
body: <p>I have a simple spec testing the creation of an object of the Baseline class. </p>
  
  <pre><code> it "allows a user to create a baseline score with valid content" do
    expect(@user.baselines.count).to eq(0)
    @baseline = post(:create, :user_id =&gt; @user.id, :baseline =&gt; valid_attributes)
    expect(response).to redirect_to '/patients/list'
    expect(flash[:notice]).to eq("Baseline scores for case #{@baseline.case_id} was successfully created.")
    expect(Baseline.all.count).to eq(1)
   end
  </code></pre>
  
  <p>But I get this. I am uncertain where to begin with this - I am uncertain why I can't access the case_id attribute of @baseline. </p>
  
  <pre><code>   NoMethodError:undefined method `case_id' for &lt;ActionController::TestResponse:0x007f8f5ab4f3c0&gt;
  </code></pre>
  
  <p>Just to show...these are the valid attributes</p>
  
  <pre><code> let(:valid_attributes) do {
      :dx1 =&gt; "IPF",
      :dxcon1 =&gt; 100,
      :db1 =&gt; "Progressive",
      :dbcon1 =&gt; 100,
      :mgt=&gt; "Drugs",
      :biopsy =&gt; "Yes",
      :patient_id =&gt; @patient.id,
      :case_id =&gt; @patient.case,
      }
   end
  </code></pre>