Tôi đã triển khai tải lên tệp JQuery trong ứng dụng Rails4 của mình. Tải lên tệp hoạt động khi tôi kiểm tra thủ công từ trình duyệt nhưng thử nghiệm của tôi cho nó không thành công.Cách kiểm tra tải lên tệp JQuery bằng RSpec và Capybara
Dưới đây là spec của tôi cho 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
Tôi đang sử dụng RSpec 2, Capybara 2 và Poltergeist cho tính năng này spec.