Created
February 28, 2017 16:34
-
-
Save jasonnoble/fe58e521502c363165c708d15035fd40 to your computer and use it in GitHub Desktop.
Memoizing test setup
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
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 |
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 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