Skip to content

Commit

Permalink
Make RSpec inclusion it's own thing
Browse files Browse the repository at this point in the history
Previously, depending on order of libary loading,
RSpec constant might not have been defined at the
time the Checkpoint class was evaluated.  As such,
the RSpec expectations were not added to the list of
`Checkpoint.rescuable_errors` even though they were
defined at runtime.

This makes rspec inclusion a more 'first-class' citizen
and explicitly requires users to include RSpec support
if they want it.
  • Loading branch information
cpjolicoeur committed May 11, 2016
1 parent 8e1d015 commit fcd486e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ If using with Cucumber, add the following to your `support/env.rb`.
require 'capybara/ui/cucumber'
```

If you are using with RSpec, add the following to your `spec_helper.rb` or
`support/env.rb` file.

```ruby
require 'capybara/ui/rspec'
```

## Contributing
We welcome pull requests. Please make sure tests accompany any PRs. Email Adam at ags@mojotech.com if you have questions.

Expand Down
5 changes: 0 additions & 5 deletions lib/capybara/ui/checkpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ class << self

self.rescuable_errors = [StandardError]

if defined?(RSpec)
require 'rspec/expectations'
self.rescuable_errors << RSpec::Expectations::ExpectationNotMetError
end

class Timer
class Frozen < StandardError; end

Expand Down
3 changes: 3 additions & 0 deletions lib/capybara/ui/rspec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'rspec/expectations'

Capybara::UI::Checkpoint.rescuable_errors << RSpec::Expectations::ExpectationNotMetError

0 comments on commit fcd486e

Please sign in to comment.