How is spec/rails_helper.rb different from spec/spec_helper.rb? Do I need it?

rspec-rails 3 generates spec_helper.rb and rails_helper.rb. spec_helper.rb is for specs which don’t depend on Rails (such as specs for classes in the lib directory). rails_helper.rb is for specs which do depend on Rails (in a Rails project, most or all of them). rails_helper.rb requires spec_helper.rb. So no, don’t get rid of rails_helper.rb; require it (and … Read more

test a file upload using rspec – rails

You can use fixture_file_upload method to test file uploading: Put your test file in “{Rails.root}/spec/fixtures/files” directory before :each do @file = fixture_file_upload(‘files/test_lic.xml’, ‘text/xml’) end it “can upload a license” do post :uploadLicense, :upload => @file response.should be_success end In case you were expecting the file in the form of params[‘upload’][‘datafile’] it “can upload a license” … Read more