我已经在我的 Rails4 应用程序中实现了一个 JQuery 文件上传。当我从浏览器手动测试文件上传时,文件上传有效,但我的测试失败。
以下是我的 JQuery 文件上传规范:需要 '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
我正在使用 RSpec 2、Capybara 2 和 Poltergeist 来实现此功能规范。