I have implemented a JQuery-file-upload in my Rails4 app. File upload works when I manually test it from the browser, but my test for it fails.
Below is my spec for the JQuery-file-upload: require 'spec_helper'
feature 'Evidences' do
context "as an assessor user" do
let!(:assessor) { User.make! :assessor }
let!(:assessment) { Assessment.make! }
background { sign_in assessor }
scenario "it uploads evidence", js: true do
evidences_count_before_upload = assessment.evidences.count
visit edit_assessment_path(assessment)
path = "#{Rails.root}/spec/fixtures/files/sample1.doc"
attach_file 'evidence_file_url', path
expect(assessment.evidences.count).to eq(evidences_count_before_upload + 1)
end
end
end
I'm using RSpec 2, Capybara 2 and Poltergeist for this feature spec.