Created
October 19, 2009 04:01
-
-
Save thumblemonks/213066 to your computer and use it in GitHub Desktop.
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
# ... | |
context "for a given user" do | |
setup do | |
topic.user = User.create(:name => "acme", :email => "[email protected]", | |
:password => "h3ll0", :password_confirmation => "h3ll0") | |
topic.description = "Foo Bar" | |
topic.name = "foo_bar" | |
topic.save! | |
topic | |
end | |
topic.validates_uniqueness_of :name | |
end.delete_all(User) | |
# ... |
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
module Riot | |
module ActionController | |
module ContextMacros | |
# Meant to be a teardown method. Apply to any context and it will be called at the end | |
# | |
# context "foo" do | |
# setup { User.create( ... ) } | |
# ... | |
# end.delete_all(User) | |
def delete_all(model_class) | |
model_class.delete_all | |
end | |
end # ContextMacros | |
end # ActionController | |
end # Riot | |
Riot::Context.instance_eval do | |
include Riot::ActionController::ContextMacros | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment