UseCase "Helper methods"
Component 158387
Jump to navigation
Jump to search
|
Content
MINIMIZE INDIRECTION! That means minimizing the cases in which you have to look elsewhere to understand something.
Re-use code within example groups describe() or context()
describe ... do def helper_method() end it helper_method() end end
describe ... do def helper_method() yield object do end end it "idiom{{Footnote|Keep clean and consistent!" helper_method() do |yielded_object| end end end
Sharing across example groups
module MyHelpers def ... end end
describe ... do include MyHelpers it ... do end end
OR
RSpec.configure do |config| config.include(MyHelpers) end