Repeating the title, my question is how to test for form submission using "Enter Key" using poltergeist through capybara. In other words, i expect when i fill in the username, password and then press "Enter" while on either input i'll submit the form. From what I can tell poltergeist achieves this through "send_keys". However my current test:
When(/^I log in with enter key$/) do
visit_login
fill_in "app-email", :with => admin_user.email
fill_in "app-password", :with => admin_user.password
login = find("#app-password")
login.native.send_key :Enter
end
works with the following (original) code which uses ng-click. I expected the above test to fail on the code below as with the code below you can't hit enter and submit the form in the browser. Here is the ng-click code:
%form{name: "form"}
%input#app-email{name: "email", "ng-model" => "email", type: 'email'}
%input#app-password{name: "password", "ng-model" => "password", type: "password"}
%a.btn.btn-primary.login-btn#app-login{"ng-click" => "login(email, password)"} LOG IN
and here is the code with ng-submit, this both works manually and with the test:
%form{name: "form", "ng-submit" => "login(email, password)"}
%input#app-email{name: "email", "ng-model" => "email", type: 'email'}
%input#app-password{name: "password", "ng-model" => "password", type: "password"}
%input.btn.btn-primary.login-btn#app-login{type: "submit", value: "LOG IN"}
there is a rather lengthy discussion on getting this to work here: Is there a way to send key presses to Webkit using Capybara?. However, I couldn't modify any of those solutions to work for me.