I'm impressed at the brevity and usefulness of Cucumber's Scenarios, they're a great way to test a load of different cases.
e.g. example Cucumber scenario
Feature: Manage Users
In order to manage user details
As a security enthusiast
I want to edit user profiles only when authorized
Scenario Outline: Show or hide edit profile link
Given the following user records
| username | password | admin |
| bob | secret | false |
| admin | secret | true |
Given I am logged in as "<login>" with password "secret"
When I visit profile for "<profile>"
Then I should <action>
Examples:
| login | profile | action |
| admin | bob | see "Edit Profile" |
| bob | bob | see "Edit Profile" |
| | bob | not see "Edit Profile" |
| bob | admin | not see "Edit Profile" |
(Code taken from Ryan Bates' More on Cucumber Screencast)
Is there an equivalent in RSpec?
I'd like to do the same thing in RSpec and to DRY up my code by reducing different tests down to a row in a scenario table.
Although I could write the code to do this myself, the fact that I'm considering it makes me wonder two things
If this is useful it probably already exists in which case how do I use it?
If it doesn't exist it suggests it shouldn't be done this way and that I'm approaching the problem incorrectly, how should I rethink my approach to RSpec?
Which answer is right and if it is useful, how do I do it?