How do you test a submit button being disabled after clicking in capybara?

We are trying to disable a certain submit button after clicking on it. Something like this:

assert !page.has_css?("#review_button[disabled='disabled']")
click_button "Review"
assert page.has_css?("#review_button[disabled='disabled']")

The problem, of course, is that the form submits before the second assertion is checked. Is there any way to disable the actual submission of the form, or suspend it until after the second assertion is checked?

Answers


I remember having this same issue and never found a good way to do this, because as you said, it only gets to the next assert when the "Review" action completes.

What I ended up doing, considering that the action that the button did took a long time (and thus justifies having the button be disabled) is to make the action create a Delayed Job job and then let it run asynchronously. Then it's pretty easy to mock that out and make it sleep for a few seconds (or what have you) to check that the button is disabled.


Need Your Help

call same function on different non-related objects?

.net function object c++-cli

I have a set of objects, all of a different type, lets say

send an HTML formatted email using MFMailComposeViewController

iphone html sdk mfmailcomposeviewcontroller

I am formatting a mail with HTML content and sending it using MFMailComposeViewController.But on the receiver side mail is not reaching in HTML format.Only Plain text is visible.How could I resolve...