I am writing a test for my rails app function that handles admission requests to a school. my tests that is currently does not work tests whether the total count of admission requests changes by 1 after submitting an admission request form. this is the test
describe "with valid information" do
before do
fill_in "Name", with: "Example User"
fill_in "Email", with: "user@example.com"
fill_in "Address", with: "68 High St"
fill_in "Phone", with: "2035846857"
fill_in "Card", with: "4242424242424242"
fill_in "CVC", with: "557"
fill_in "admission_request_exp_month", with: "08"
fill_in "admission_request_exp_year", with: "2017"
end
it "should create a request", :js => true do
expect { click_button 'Submit Request' }.to change(AdmissionRequest, :count).by(1)
end
...
this is what I get when I run the test
1) Admission requests pages new admission request with valid information should create a request
Failure/Error: expect { click_button 'Submit Request' }.to change(AdmissionRequest, :count).by(1)
count should have been changed by 1, but was changed by 0
But if I submit the form manually, everything works perfectly fine, a new admission request is saved into the database and the count changes by 1. What might be the problem? I am using rails 3.2.13 and capybara 1.1.2
Thanks