我正在尝试对我的应用进行集成测试,以涵盖所有功能。我的应用程序只是上传了一个文件,它会引导您进入另一个页面,其中包含“您的数据库已更新”的消息。用户无法看到它,但是当他上传excel文件时,它会更新数据库。好吧,我已经使用Capybara和Rspec来测试我上传了一个excel文件。测试通过绿色,但我不明白为什么,因为我写了一个错误的消息,检查测试是否正常工作,仍然通过...我是新的,所以我需要一些帮助,请
规格/ app_integration_spec.rb
require File.join(File.dirname(__FILE__), '..', 'app.rb')
require 'capybara'
require 'capybara/rspec'
Capybara.app = LaMareta
describe "Updating Vip customers database", :type => :feature do
before {
DataMapper.setup(:default, 'postgres://david:123456@localhost/usersmareta')
DataMapper.finalize.auto_upgrade!
}
after {
clients_database = VipClient.all
clients_database.each { |client| client.destroy }
}
it "Uploads succesfully an excel file with Vip customers data birhtday" do
visit '/'
attach_file('birthdayFile', 'spec/fixtures/databasetest.xlsx')
click_button 'Upload_excel'
expect(page).to have_content 'Hola'
end
end
upload.rb
<h1>My file uploader!!</h1>
<form action="/upload" method="post" enctype='multipart/form-data'>
<input type='file' name='birthdayFile' accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel">
<input type='submit' value='Upload!' id="Upload_excel">
</form>
uploaded_file.rb
<h1>Your database has been updated¡¡</h1>
编辑我的问题
规格/ spec_helper.rb
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
end