I solved this issue by defining a new tag for VCR:
#./test_helper/vcr.rb
VCR.cucumber_tags do |t|
t.tag '@vcr', use_scenario_name: true
t.tag '@foo'
end
And then i added a before and after hook, which loads my wanted cassette:
# ./features/support/env.rb
Before('@foo') do
VCR.insert_cassette('cassettes/bar/foo')
end
After('@foo') do
VCR.eject_cassette
end
So now i simply needed to annotate my new defined tag for the similar scenarios:
feature bar
@foo
scenario foo
@foo
scenario foo1
...
@foo
scenario fooX
So now i only have one recorded cassette file left.