title: Is it possible to use 'form_authenticity_token' inside a spec?
body: <p>It's possible to use <code>form_authencity_token</code> inside a controller in Rails.</p>
  
  <pre><code>def create
    @user = self.resource = warden.authenticate!(auth_options)
    sign_in(resource_name, resource)
    @csrfToken = form_authenticity_token
    @user
  end
  </code></pre>
  
  <p>My question is: is it possible to have <code>form_authencity_value</code> inside a spec? I'm testing a controller and a JSON response from <code>SessionsController</code> (<strong>Devise</strong>). And I have to update <code>csrf-token</code> constantly to don't get erros like: <em>Can't verify CSRF token authenticity</em> in my requests.</p>
  
  <p>Please, I'm already sending to the server my <code>csrf-token</code> and it's working perfectly. My problem here is with <strong>RSpec</strong>, to test my <strong>RABL</strong> response after logging in (and logout - that is not a <strong>RABL</strong> view).</p>
  
  <p>My test is something like this:</p>
  
  <pre><code>expected_response = {
    'id'          =&gt; @user.id,
    'email'       =&gt; @user.email,
    'first_name'  =&gt; @user.first_name,
    'last_name'   =&gt; @user.last_name,
    'created_at'  =&gt; @user.created_at,
    'updated_at'  =&gt; @user.updated_at,
    'csrfToken'   =&gt; # PROBLEM
  }.to_json
  
  expect(response.body).to eq(expected_response)
  </code></pre>
  
  <p>How can I have <code>form_authencity_value</code> inside my spec?</p>