I am writing RSpec Tests for a view and getting the following error when trying to fill in a text field.
1) coordinators/new.html.erb populate page name text entry field filled checks for presence of filled in text field
Failure/Error: fill_in "coordinator_name", with: 'JoeJoe'
Capybara::ElementNotFound:
Unable to find field "coordinator_name"
# ./spec/views/coordinators/new.html.erb_spec.rb:47:in `block (4 levels) in <top (required)>'
Here is part of my code, including the preceding test where the field "coordinator_name" is found. I am confused as to why it's not found in the 2nd test?
describe 'name text entry field' do
it 'checks for presence of empty text field for name' do
expect(rendered).to have_field('coordinator_name', text: nil)
end
end
describe 'name text entry field filled' do
it 'checks for presence of filled in text field' do
fill_in "coordinator_name", with: 'JoeJoe'
expect(rendered).to have_field('coordinator_name', text: 'JoeJoe')
end
end
Any suggestions on how to find a solution?
:textoption to have_field -- have_field doesn't take a:textoption it takes a:withoption if you're trying to test the value of the field, also what isrendered? - nevermind I see what you're doing wrong. - Thomas Walpole