Title: Rspec Cucumber avoid repeated tests
Tags: ruby-on-rails;ruby;ruby-on-rails-3;rspec;cucumber
Question: very often I see people writing tests (specs) in both capybara and rspec.
By default RSpec generates all kind of specs, actually I'm just disabling these one:

```config.generators do |g|
  g.test_framework :rspec,
    :view_specs    =&gt; false,
    :request_specs =&gt; false,
    :routing_specs =&gt; false
  end
end
```

I'm doing this because I want to test views with Cucumber, am I right? Maybe there's some other spec I should disable to avoid repeated tests among the two frameworks?

Thanks!



Here is another answer: You see people writing specs in both Cucumber and RSpec because they are two frameworks that do the same thing (Behavior Driven Development). Cucumber simply provides a business readable specification document that gets translated into code, wheras RSpec has the business specification mixed into the code within described, it and context blocks.

Generally speaking, if you are using both, you are probably just going to use RSpec for the UNIT testing capabilities (Model, Controller, View and Routing Specs, although there is a strong argument that you only need to do model specs). Then you'll do your Acceptance Tests in either Cucumber or through Request Specs in RSpec, there is no reason to use both.

My general rule of thumb is to use RSpec if only technical folks are using the specs because I find it easier to use, and Cucumber if your product owner is hands on enough to want to see the specification.

Request Specs and Cucumber Features are both a form of Integration Tests, which means you are going to be using all aspects of your application, not just one part in isolation. It generally accepted that you can push off responsibility for testing the controller, routes and views to integration tests, so you are correct that you can disable those in RSpec if you agree that you don't need them.

Myself I still like to write the odd controller test, usually to make sure that if I post with extra parameters the application won't let a user make themselves an admin or something similar.

Comment for this answer: +1 - Really good answer. However, I would say that even if only technical folks are using the specs, I find using Cucumber pretty useful as a documentation of what the application is supposed to do.
Comment for this answer: Very true, although I find the output of rspec in documentation format is usually as good as a cucumber feature file.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:07/11/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ruby-on-rails><ruby><ruby-on-rails-3><rspec><cucumber>', 'Title': 'Rspec Cucumber avoid repeated tests', 'ViewCount': 165, 'id': 11430920, 'user_AboutMe': None, 'user_AccountId': None, 'user_DisplayName': None, 'user_Reputation': None, 'user_Views': None, 'user_id': None}}