Skip to content

Instantly share code, notes, and snippets.

@jasonnoble
Created February 28, 2017 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonnoble/fe58e521502c363165c708d15035fd40 to your computer and use it in GitHub Desktop.
Save jasonnoble/fe58e521502c363165c708d15035fd40 to your computer and use it in GitHub Desktop.
Memoizing test setup
require_relative './path/to/sales_engine_test_setup'
class InvoiceRepositoryTest < Minitest::Test
include SalesEngineTestSetup
def setup
super
# Any additional setup needed for InvoiceRepository tests
end
# tests go here...
end
module SalesEngineTestSetup
attr_reader :sales_engine
def setup
@@sales_engine ||= load_sales_engine_data
@sales_engine = @@sales_engine.dup
end
private
def load_sales_engine_data
puts 'Loading sales engine data!!!!'
SalesEngine.from_csv({
:invoices => "./data/invoices.csv",
:items => "./data/items.csv",
:merchants => "./data/merchants.csv",
})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment