Created
January 23, 2015 17:26
-
-
Save calo81/562b5c412c713a11b111 to your computer and use it in GitHub Desktop.
Testing a feature file from another feature in Turnip - Rspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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