Skip to content

Instantly share code, notes, and snippets.

@thumblemonks
Created October 19, 2009 04:01
Show Gist options
  • Save thumblemonks/213066 to your computer and use it in GitHub Desktop.
Save thumblemonks/213066 to your computer and use it in GitHub Desktop.
# ...
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)
# ...
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