我的规格有一个非常奇怪的问题。我的表格看起来像这样:
= simple_form_for [:admin, @provider] do |f|
= f.input :provider_type_id
= f.input :provider_username
= f.input :first_name
= f.input :last_name
= f.input :athena_health_provider_id
= f.input :display_name
= f.input :specialty
= f.input :entity_type
= f.input :home_department
= f.input :billable
= f.input :npi
= f.input :ansi_specialty_code
= f.input :ansi_name_code
= f.input :languages
= f.input :description
= f.input :photo, as: :file
= f.submit class: 'btn btn-primary'
功能规格看起来像这样:
require 'rails_helper'
feature 'Provider edit' do
let(:admin) { create(:user, :admin) }
let(:provider) { create(:provider) }
before do
login_as admin
visit edit_admin_provider_path(provider)
end
context 'when form is filled with invalid data' do
before do
fill_in 'First name', with: nil
click_button 'Update provider'
end
scenario 'redirects to :edit' do
expect(current_path).to eq admin_provider_path(provider)
end
scenario 'contains errors' do
expect(page).to have_text "can't be blank"
end
end
end
此规范失败。 Capybara没有使用nil值更新First name输入。但是当我改变输入时:
= f.input :photo
一切都按预期工作。那是为什么?