I am having an issue where a feature works fine but the corresponding
test fails, and I can't understand why.
I created a mock application to demonstrate the problem.
All it does is show an input form with a clear button. The clearing
happens by redirecting back to the same form. It does clear it when you
run the app, but the test for it fails.
If you feel inclined to help, please clone the repo and run the test
mentioned in the readme (or the full suite, which is very short). The
test fails (at least for me) but if you run the app
(http://localhost:3000/pages/input) the 'Clear' button does seem
to be doing the right thing.
Just a quick glance, but you probably should move lines 10-16 (the
before and it blocks) inside their own describe block, as the before
block at line 10 is also running before every it in the other describe
blocks.
Okay, as near as I can figure out, capybara is choking on the fact
that you have commit=Show in your query string, you're using
method=GET in your form, and commit=Clear is coming in the request
body. Somehow, when rails is called by the browser, this is handled in
the way you want (which is the request body's commit=Clear overrides
the one in the query string), but in capybara, it isn't.
On Mon, May 13, 2013 at 11:20 PM, tamouse mailing lists
Tamouse, thank you.
However, your pull nullifies the test.
Your test clicks the clear button without first writing anything in the
input field, so obviously clearing the empty input field leaves you with
an empty input field.
In order that the test actually tests something, it must first write
something into the input field and then try to clear it.