Aaron McAdam
Aaron McAdam

Reputation: 706

Cucumber only showing Capybara errors when there's an error in a Controller

I keep having an annoying issue with Cucumber. If there are any errors in the Controller, it only shows the errors raised by capybara. I'm sure that's not the way it used to work?

For example, if an exception was raised, the only output I see is: expected to find css "h1" with text "blah"

In order to actually see the error, I have to puts page.body in order to see the Controller error

Is this expected behaviour?

Upvotes: 0

Views: 111

Answers (1)

Steve Jorgensen
Steve Jorgensen

Reputation: 12341

It is the expected behavior. Capybara is acting in the role of the user and responding to what it sees back from the server. Yes, it is annoying and makes failures hard to debug.

After you find the problem using tricks like puts page.body you should improve your lower-level test coverage to detect the cause of the error, giving a more informative failure, and then fix the problem. The better your lower-level test coverage is, the less often you'll have an error in Ruby code when running a full-stack test.

By the way, I would characterize this as an issue with full-stack testing (e.g. Capybara) and not a Cucumber-related issue. Cucumber can run tests that are not full-stack, and you can run full-stack tests outside of Cucumber (e.g. by using Capybara in RSpec)

Upvotes: 0

Related Questions