-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Eager def (similiar to rspec's let!) #138
base: master
Are you sure you want to change the base?
Conversation
@@ -7,23 +7,33 @@ module.exports = (context, tracker, options) => { | |||
|
|||
get.definitionOf = get.variable = (varName) => get.bind(null, varName); | |||
|
|||
function def(varName, definition) { | |||
function def(varName, definition, defOptions = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function def(varName, definition, defOptions = {}) { | |
function def(varName, definition, defOptions = {lazy: true}) { |
Not that my opinion matters much, but as a user who would like to see this feature, I'd imagined it being more of a whole new keyword/method rather than an option passed to the existing ’def’ method. It feels kinda verbose to have to do that for each one and if my tests already have a ’beforeEach’ I'd likely still just leave the options out and call them in there. I dunno. Just my thoughts. Perhaps this is good but also alias it somehow? ’deff’? ’defE’? |
How about following
On the PR, I think the evaluation should happen in |
Hey everyone! thanks for the comments :) loved your ideas |
Solves
This PR Solves #113
Context
This PR allows you to specify a
def
with{lazy: false}
to make it eagerly evaluate instead of lazily.This is very similiar to how
let
andlet!
are different in the RSpec library.My use case for this feature is a sequelize ORM creation of an object.
Not all
it
s needs theid
of the object or even the object at all, because they are testing other side effects of the call. (for example, validations, errors being thrown, HTTP calls being sent out).Some however, do test the object.