Skip to content

Instantly share code, notes, and snippets.

@stalniy
Created June 25, 2018 18:22
Show Gist options
  • Save stalniy/c9ccbebd4ac1a750e47c758653a1f598 to your computer and use it in GitHub Desktop.
Save stalniy/c9ccbebd4ac1a750e47c758653a1f598 to your computer and use it in GitHub Desktop.
Lazy vars variable shadowing
describe('Article', function() {
subject(function() {
return Article.create({ title: 'BDD lazy vars' });
});
its('status', () => is.expected.to.equal('draft'));
describe('changes history', function() {
subject(function() {
return $subject.changes(); // $subject refers to parent subject, i.e. created article
});
it('is empty by default', function() {
expect($subject).to.be.empty; // $subject refers to local subject, i.e. article changes
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment