title: Testing Carrierwave file uploads to s3 with Capybara and Rspec
body: <p>I've implemented carrierwave file uploads to Amazon s3 just like in <a href="http://railscasts.com/episodes/383-uploading-to-amazon-s3?view=asciicast" rel="noreferrer">this Railscast</a>.</p>
  
  <p>I'm  having trouble testing this though. I can attach a file with Capybara, but when I click the button to upload it doesn't redirect to the correct action. I checked with save_and_open_page and it's displaying the the homepage instead.</p>
  
  <p>When I test it in the browser it works fine, but the info about the s3 upload does get added to the url (<a href="https://www.evernote.com/shard/s3/sh/ef158d64-66c5-482c-ac5a-ec181371f894/f765db2858ba786cd2fdc623d803bad4" rel="noreferrer">screenshot</a>). Not sure why this wouldn't work in the test.</p>
  
  <p>Here are some relevant files:</p>
  
  <p>example_spec.rb - <a href="https://gist.github.com/leemcalilly/1e159f1b93005b8113f2" rel="noreferrer">https://gist.github.com/leemcalilly/1e159f1b93005b8113f2</a></p>
  
  <p>initializers/carrierwave.rb - <a href="https://gist.github.com/leemcalilly/924e8755f7c76ecbf5cf" rel="noreferrer">https://gist.github.com/leemcalilly/924e8755f7c76ecbf5cf</a></p>
  
  <p>models/work.rb - <a href="https://gist.github.com/leemcalilly/cfda1a7f15d87dbab731" rel="noreferrer">https://gist.github.com/leemcalilly/cfda1a7f15d87dbab731</a></p>
  
  <p>controllers/works_controller.rb - <a href="https://gist.github.com/leemcalilly/7fca5f2c81c6cb4de6bc" rel="noreferrer">https://gist.github.com/leemcalilly/7fca5f2c81c6cb4de6bc</a></p>
  
  <p>How can I test this type of form with capybara and rspec?</p>