Skip to content

Instantly share code, notes, and snippets.

@calo81
Created January 23, 2015 17:26
Show Gist options
  • Save calo81/562b5c412c713a11b111 to your computer and use it in GitHub Desktop.
Save calo81/562b5c412c713a11b111 to your computer and use it in GitHub Desktop.
Testing a feature file from another feature in Turnip - Rspec
# Whi I did this
# Recently I had a scenario where I needed to run a test int two different contexts, mutually exclusive and with different step implementations.
# These exclusion of tests was achieved through using Tags. And this feature needed to exclusive tags.
# I didn't want to duplicate the feature file. So I created one feature file with one of the Tags that invoked the scenarios in the other.
include Turnip::RSpec::Execute
steps_for :tests_1 do
step "feature file :feature_file" do |feature_file|
@feature_file = "#{__dir__}/../features/#{feature_file}"
end
step "it should run a random :percent% sample of the tests" do |percentage|
Turnip::Builder.build(@feature_file).features.each do |feature|
feature.scenarios.each do |scenario|
example.example_group.describe(scenario.name) do
it(scenario.steps.map(&:description).join(" -> ")) do
scenario.steps.each do |step|
run_step(@feature_file, step)
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment