Skip to content

Instantly share code, notes, and snippets.

@toothrot
Created July 9, 2010 21:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toothrot/470111 to your computer and use it in GitHub Desktop.
Save toothrot/470111 to your computer and use it in GitHub Desktop.
how setups get run in Riot
context setups
+ asserts should only run the setup once
+ asserts even with multiple assertions
context setups that are nested
+ asserts gets run again
+ asserts only once per nesting, even with multiple assertions
4 passes, 0 failures, 0 errors in 0.000148 seconds
require 'rubygems'
require 'riot'
context "context setups" do
setup do
$i ||= 0
$i += 1
end
asserts('should only run the setup once') { $i == 1 }
asserts('even with multiple assertions') { $i == 1}
context "that are nested" do
asserts('gets run again') { $i == 2 }
asserts('only once per nesting, even with multiple assertions') { $i == 2}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment