mattheworiordan/capybara-screenshot — pull request #108 by neodude (2014-12-09 01:48:27+00:00)
Title: Don't initialize a new Capybara::Session in after hook

The current way that capybara-screenshot tests for the inclusion of `Capybara::DSL` will initialize a new `Capybara::Session` even in tests that don't use Capybara - e.g., model tests. We ran into this when we realized some plain ruby tests were booting up Capybara, Poltergeist and PhantomJS.

I switched the after hook to explicitly test for inclusion of the `Capybara::DSL` mixin, and fixed all the tests as ran through appraisal. This change is working successfully in our Rails 3.2 app with model + controller unit tests as well as integration tests on Capybara 2.4 and Poltergeist. Please let me know if there's a reason not to merge this change - as far as I can figure, it's safe to test for `Capybara::DSL` directly since there's no way to take screenshots if you aren't in a Capybara-powered test :)