title: Browser gem testing with capybara
body: <p>I am using the gem <a href="https://github.com/fnando/browser" rel="nofollow">Browser</a>
  to detect mobile devices and redirect them to a different landing on a rails app. The code I'm using is this one :</p>
  
  <pre><code>Rails.configuration.middleware.use Browser::Middleware do
    redirect_to mobile_landing_path if browser.device.mobile? || browser.device.ipad? || browser.device.tablet?
  end
  </code></pre>
  
  <p>Now I need to do a feature test using Rspec and capybara, and I'm a little lost here. Really appreciate the help .</p>
  
  <p>Tests I have right now is using <a href="https://github.com/mururu/capybara-user_agent/blob/master/README.md" rel="nofollow">capybara user agent</a> and looks like this: but it seems it stills gets the base landing and not the mobile one</p>
  
  <pre><code>feature 'Visiting the site from an' do
   context 'Android device' do
    background do
     set_user_agent(:android)
    end
  
    scenario 'I should be redirected to mobile landing' do
      visit root_path
      expect(page).to have_current_path(mobile_landing_path)
    end
   end
  end
  </code></pre>