I'm using let(:foo) { create_foo() } inside my tests. create_foo is a test helper that does some fairly time expensive setup.
So everytime a test is run, foo is created, and that takes some time. However, the foo object itself does not change, I just want to unit test methods on that object, one by one, seperated into single tests.
So, is there a RSpec equivalent of
letto share the variable across multiple examples, but keep the nice things like lazy loading (iffooisn't needed) and also the automatic method definition offooso that it can be used in shared examples, without referencing it with a@foo?
Or do I have to simply define a
def foo
create_foo()
end
create_footo aFOOconstant in somebefore(:suite)configuration allow you to do what you want? - Paul Fioravanti