[LRUG] Writing readable feature tests with RSpec

Tom Stuart tom at codon.com
Mon Jul 28 01:30:31 PDT 2014


On 26 Jul 2014, at 15:51, Will <william at theappbusiness.com> wrote:
> For some reason you have to add capybara to your gemfile to use the feature/scenario syntax in RSpec feature specs. I work on a lot of APIs, so really don't need capybara as a dependency.

To clarify, the `feature`/`scenario` syntax (actually just aliases for `describe`/`it`) is a feature of Capybara: https://github.com/jnicklas/capybara/blob/304e2fb/lib/capybara/rspec/features.rb#L11-L12

What rspec-rails calls “feature specs” are vanilla RSpec example groups with standard Rails spec helpers and Capybara setup included. If you don’t want to use Capybara (or indeed Rails), there’s no reason to use feature specs (or indeed rspec-rails) at all.

If all you want is to be able to write `feature`/`scenario` instead of `describe`/`it`, just put `config.alias_example_group_to :feature` and `config.alias_example_to :scenario` in your spec_helper.

(Or use Cucumber! :D)

Cheers,
-Tom


More information about the Chat mailing list