title: omniauth-facebook and testing with rspec
body: <p>I am trying to just test omniauth. I have put in config/environments/test.rb</p>
  
  <pre><code>OmniAuth.config.test_mode = true
  </code></pre>
  
  <p>and in my spec_helper.rb</p>
  
  <pre><code>OmniAuth.config.add_mock(:facebook,
                               { :provider =&gt; 'facebook',
                                 :uid =&gt; '1234567',
                                 :info =&gt; { :first_name =&gt; 'Jonathan', :name=&gt; 'Jonathan', :email =&gt; 'jon@jak.com', :image =&gt; 'http://graph.facebook.com/1234567/picture?type=square'},
                                 :credentials =&gt; {
                                   :expires_at =&gt; 1351270850,
                                   :token=&gt; 'AAADzk0b791YBAHCNhBI3n6ScmWvuXTY4yIUqXr9WiZCg1R808RYzaHxsHnrbn62IwrIgZCfSBZAVIP6ptF41nm8YtRtZCeBbxbbz1mF8RQZDZD'
                                  } })
  </code></pre>
  
  <p>and then in my request controller:</p>
  
  <pre><code>it "testing omniauth hash" do
    visit '/auth/facebook'
    request.env["omniauth.auth"][:uid].should == '1234567'
  end
  </code></pre>
  
  <p>and get:</p>
  
  <pre><code>Failures:
  
    1) Login logins with the OmniAuth auth hash
       Failure/Error: request.env["omniauth.auth"][:uid].should == '1234567'
       NoMethodError:
         undefined method `env' for nil:NilClass
       # ./spec/requests/login_spec.rb:38:in `block (2 levels) in &lt;top (required)&gt;'
  
  Finished in 2.4 seconds
  9 examples, 1 failure
  </code></pre>
  
  <p>Any idea what is going on?  thx in advance</p>
  
  <p><strong>edit 1</strong>
  <img src="https://i.stack.imgur.com/DJfZq.png" alt="enter image description here"></p>