Created
October 22, 2013 23:47
-
-
Save rhunter/7110157 to your computer and use it in GitHub Desktop.
One way to do Cucumber-style scenario tables in RSpec (in reply to @jbrains's question <https://twitter.com/jbrains/status/392794624416579584> )
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
describe 'scenario tables' do | |
scenarios = [ | |
{given_balance: 10, when_withdrawing: 10, expected_balance: 0}, | |
{given_balance: 20, when_withdrawing: 10, expected_balance: 10}, | |
{given_balance: 30, when_withdrawing: 30, expected_balance: 0} | |
] | |
scenarios.each_with_index do |scenario, n| | |
context "given a starting balance of #{scenario[:given_balance]} (scenario #{n})" do | |
it "should have #{scenario[:expected_balance]} left after withdrawing #{scenario[:when_withdrawing]}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment