On Thu, 4 Aug 2011 16:05:25 -0400
Matt Wagner <matt.wagner(a)redhat.com> wrote:
Hi all,
I've been working on trying to get Cucumber tests (and, in the
process, the rest of our app) to run successfully[1]. I'm still a
long way from done, and, since I'm going to be going on PTO starting
tomorrow, I wanted to make sure I shared the status of things.
I've just sent a patch with a bunch of changes which move us forward a
bit, but not nearly all the way, or even most of the way.
It bears mention that moving from cucumber-rails 0.3.2 to 1.0.2 has
caused webrat to be cease being supported[2]. I'm running into some
maybe-tangential problems. Here are the big two I'm aware of:
1.) We have tests that use the "response" object, such as to check
whether we get JSON or a partial back. This isn't really supported in
Capybara, and looking into it, it was pointed out that tests for
response type probably don't belong in Cucumber in the first place.
I'm not sure whether we want to throw them away or try to port to
RSpec or something else. Some are weird, in that we practically
duplicate tests -- once 'normally' for HTML, and then a second time
by setting an Accept header to request JSON or a partial. (Some of
these are my doing.) It probably doesn't make sense to do that if we
just want to check that, when we request JSON, we get JSON back.
For this kind of tests i suggest using rspec request specs, for what I
know it is lot faster then cucumber.
http://relishapp.com/rspec/rspec-rails/v/2-6/dir/request-specs/request-spec
Nice example of using rspec with capybara is also on railscasts
http://asciicasts.com/episodes/257-request-specs-and-capybara
2.) I think there's a bug in haml[3][4]. Throughout the app, we're
seeing double delete buttons. We had suspected that
rack-restful_submit was to blame, but it's not. (At least, not for
the double inclusion.) Instead, what's happening is that capture_haml
is printing the captured HAML on the page when it's called!
This is actually causing two separate problems. One is the
double-display of the delete, the first of which doesn't actually
work. The second problem is that its first inclusion is causing tests
to fail[5] in multiple places. It has a duplicate ID
('delete_button'), but the first occurs outside of the <form> tag, so
capybara refuses to click it since it's not a valid button. The
second button *is* in the form (that's the whole reason for using
capture_haml, in fact), but capybara isn't seeing it. If we can
un-break capture_html, I think these tests will start passing.
I'm not entirely sure what we're to do here. There's a pull request
(in [4]), but unless we're going to try to fork and carry it (or
monkey-patch it), it's not helpful for us. I'm hoping to devise a
workaround, but I'm not sure how to go about it.
These two issues don't account for all of the test failures, but
they're the ones that I've seen in multiple places and that aren't
trivially fixed.
I may send a few more fixes before the day's over, but I have no
illusions of being able to finish this today, so I'm hoping someone
(or some people) will be able to pick up where I've left off.
I am going to contiue fixing the tests.