Instantly share code, notes, and snippets.

View view_resource_macros.rb
module ViewResourceMacros
def has_resource(name, &block)
before do
# Creates the resource
@resource ||= yield
# Assign to the symbol we wanted, so it's available in the view
assign(name, @resource)
# Assigns to @name so that we can use that in our assertions
instance_variable_set("@#{name}", @resource)