Created
October 28, 2011 19:53
-
-
Save bbasata/1323368 to your computer and use it in GitHub Desktop.
First draft: wondering if anyone else would love to see a RSpec-like lazy-initializing let() function introduced into @jasminebdd
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
function lazy(fn) { | |
return _.once(fn); | |
} | |
describe('Expired Item View', function() { | |
var item, view, rendered; | |
beforeEach(function() { | |
item = lazy(function() { return {}; }); | |
view = lazy(function() { return new APP.Views.ExpiredItem({ item: item() }); }); | |
rendered = lazy(function() { return view().render().el }); | |
}); | |
it('renders as a list item', function() { | |
expect($(rendered())).toBe('li'); | |
}); | |
context('when it can be renewed', function() { | |
beforeEach(function() { | |
item = lazy(function() { return { renewable: true }; }); | |
}); | |
it('has the renewable class', function() { | |
expect($(rendered()).toBe('li.renewable'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment