How can I tag cucumber scenario outline examples for use with VCR cassettes?

667 Views Asked by At

I'd like to apply a different VCR cassette based on the tag on the example. As far as I can tell, tagging cucumber scenario outline examples is possible, but I can't get VCR to recognize any of the tags. Is this possible?

VCR.cucumber_tags do |t|
  t.tag '@premium-successful-payment'
  t.tag '@premium-card-declined'
end


Feature:

  Background:
    Given I am signed in 
    And I am on the premium payment page

  @javascript
  Scenario Outline: Submitting payment information
    When I fill in "Credit Card Number" with "<card_number>"
    And I fill in "Security Code" with "<security_code>"
    And I select "<expires_month>" from "credit_card_expires_month"
    And I select "<expires_year>" from "credit_card_expires_year"
    And I press "Activate Premium"
    Then I should see a payment success message

    @premium-successful-payment
    Examples:
      | card_number      | security_code | expires_month | expires_year |
      | 4242424242424242 | 123           | 6             | 2020         |

    @premium-card-declined
    Examples:
      | card_number      | security_code | expires_month | expires_year |
      | 4000000000000002 | 123           | 6             | 2020         |
1

There are 1 best solutions below

0
On

There's an open Pull Request on github about this. I'd like to merge it at some point, but I had some concerns about the implementation and the author of the PR hasn't responded to my comments yet.

In the meantime, you can consider writing your own VCR/cucumber integration using the available cucumber hooks and VCR's VCR.insert_cassette/ VCR.eject_cassette API. The cucumber integration isn't meant to the main or only way people use VCR with cucumber; it's just a convenient way to get started for the most common need.