{"id":273324,"date":"2016-02-01T12:32:03","date_gmt":"2016-02-01T09:32:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=273324"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=273324","title":{"rendered":"Aka rspe\u0441, \u0442.\u0435. \u043b\u0435\u043d\u0438\u0432\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445"},"content":{"rendered":"<p>       \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f: \u00ab\u0417\u0430\u043f\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u043b\u043e\u0434 \u0441\u043b\u0430\u0434\u043e\u043a\u00bb, \u0442\u0430\u043a \u0438 \u0443 \u043c\u0435\u043d\u044f. \u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043d\u0430 RSpec, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 BDD DSL \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u0412\u043e\u0442 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 JavaScript, \u0438\u043c\u0435\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 mocha.js, jasmine.js, etc. \u041d\u043e \u043d\u0435\u0442, \u043c\u0430\u043b\u043e. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u044f\u043a\u0438\u0445 describe-\u043e\u0432 \u0438\u043b\u0438 it-\u043e\u0432 \u0430 \u0435\u0449\u0435 \u0438 \u043b\u0435\u043d\u0438\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u044f \u0438\u043c\u0435\u044e \u0432\u0432\u0435\u0434\u0443 subject \u0438 let.<\/p>\n<p>  \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0433\u043b\u0443\u043f\u043e! \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0433\u043e\u043b\u043e\u0441 \u043a\u0440\u0438\u0447\u0438\u0442 \u00ab\u0417\u0430\u0447\u0435\u043c?\u00bb, \u0430 \u0441\u043e\u0432\u0435\u0441\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442: \u00ab\u0427\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u2014 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e! \u041d\u0443 \u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u2014 \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u0435\u0433\u0430 \u0432\u0430\u0436\u043d\u043e!\u00bb.<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a \u0438 \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f mochajs, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u0435\u043d\u0438\u0432\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 (aka let) \u0438 `subject`. <\/p>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u043e \u0447\u0435\u043c \u044f \u0438 \u0443\u0436\u0435 <s>\u043d\u0430\u043f\u0440\u044f\u0433\u0441\u044f<\/s> \u0437\u0430\u0441\u0432\u0435\u0442\u0438\u043b\u0441\u044f \u043e\u0442 \u0440\u0430\u0434\u043e\u0441\u0442\u0438, \u043c\u0438\u043b\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0438\u043c \u043d\u0430 <a href=\"https:\/\/github.com\/stalniy\/bdd-lazy-var\">Github<\/a>.<br \/>  \u0412\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c, \u0430 \u0432 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0441\u043a\u0435\u043f\u0442\u0438\u043a\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043f\u043e\u0434 cut.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043a\u043e\u043c\u0443-\u0442\u043e \u0432\u0430\u0436\u043d\u043e?<\/h4>\n<p>  \u0412\u043e\u0442 <a href=\"http:\/\/blog.codinghorror.com\/coding-for-violent-psychopaths\/\">\u043f\u043e\u0447\u0435\u043c\u0443!<\/a>.<\/p>\n<h4>\u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e<\/h4>\n<p>  \u0427\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0438\u0448\u0443\u0442 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445?  <\/p>\n<pre><code class=\"javascript\">describe('Invoice', function() {   var invoice, user;    beforeEach(function() {     user = User.create({ role: 'member' });     invoice = user.invoices.create({ price: 10, currency: 'USD' });   });    it('has status &quot;fraud&quot; if amount does not equal to invoice amount', function() {       invoice.paid(1, 'USD');       expect(invoice.status).to.equal('fraud');   });    it('has status &quot;fraud&quot; if currency does not equal to invoice currency', function() {       invoice.paid(10, 'ZWD');       expect(invoice.status).to.equal('fraud');   });  ..... }) <\/code><\/pre>\n<p>  \u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0432\u0441\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u0441\u0447\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043e\u0437\u0434\u0430\u043d, \u043e\u043f\u043b\u0430\u0442\u0430 \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u0435\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u043e\u0442 \u043f\u043b\u0430\u0442\u0435\u0436\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0438\u0448\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0435\u043d\u0435\u0433, \u0447\u0435\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c\u2026 \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0447\u0435\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043c\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043c \u043a \u0431\u043e\u043b\u0435\u0435 \u043f\u043b\u0430\u0447\u0435\u0432\u043d\u043e\u043c\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0443  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u044b!<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">describe('Invoice', function() {   var invoice, user;    describe('by default', function() {     beforeEach(function() {       user = User.create({ role: 'member' });       invoice = user.invoices.create({ price: 10, currency: 'USD' });     });      it('has status &quot;fraud&quot; if amount does not equal to invoice amount', function() {         invoice.paid(1, 'USD');         expect(invoice.status).to.equal('fraud');     });      it('has status &quot;fraud&quot; if currency does not equal to invoice currency', function() {         invoice.paid(10, 'ZWD');         expect(invoice.status).to.equal('fraud');     });   });    describe('when user is admin', function() {     beforeEach(function() {       user = User.create({ role: 'member' });       invoice = user.invoices.create({ price: 10, currency: 'USD' });     });      it('has status &quot;paid&quot; if amount does not equal to invoice amount', function() {         invoice.paid(1, 'USD');         expect(invoice.status).to.equal('paid');     });   });  ..... }) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422.\u0435., \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u0435\u043c setup, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432\u043e\u0443\u043b\u044f! \u0414\u0430 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043f\u0438-\u043f\u0430\u0441\u0442\u2026 \u0410 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0432 `afterEach`? <\/p>\n<h4>\u041b\u0435\u043d\u044c \u043f\u0440\u043e\u0442\u0438\u0432 \u043a\u043e\u043f\u0438-\u043f\u0430\u0441\u0442\u0430!<\/h4>\n<p>  \u041e\u0434\u043d\u0430 \u0438\u0437 \u0437\u0430\u0434\u0430\u0447 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0430 \u2014 \u044d\u0442\u043e \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u043f\u0438-\u043f\u0430\u0441\u0442\u0430! \u041a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e? \u0414\u0430 \u043f\u0440\u043e\u0441\u0442\u043e  <\/p>\n<pre><code class=\"javascript\">describe('Invoice', function() {   def('user', function() {     return User.create({ role: 'member' });   });    def('invoice', function() {     return $user.invoices.create({ price: 10, currency: 'USD' });   });    describe('by default', function() {     it('has status &quot;fraud&quot; if amount does not equal to invoice amount', function() {         $invoice.paid(1, 'USD');         expect($invoice.status).to.equal('fraud');     });   });    describe('when user is admin', function() {     def('user', function() {       return User.create({ role: 'admin' });     });            it('has status &quot;paid&quot; if amount does not equal to invoice amount', function() {         $invoice.paid(1, 'USD');         expect($invoice.status).to.equal('paid');     });   });  ..... }) <\/code><\/pre>\n<p>  \u041a\u043e\u0434\u0430 \u0441\u0442\u0430\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435, \u043a\u043e\u043f\u0438-\u043f\u0430\u0441\u0442\u044b \u043c\u0435\u043d\u044c\u0448\u0435, \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0448\u0435! \u0423\u0440\u0430! \u041c\u0430\u043b\u043e \u0442\u043e\u0433\u043e, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u0412\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c `afterEach` \u0431\u043b\u043e\u043a\u0438. \u0423\u0434\u043e\u0431\u043d\u043e?<\/p>\n<p>  <b>Note<\/b>: \u0437\u043d\u0430\u043a `$` \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c exception.<\/p>\n<h4>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h4>\n<p>  \u041b\u0435\u043d\u0438\u0432\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u0442\u043e \u0438 \u043b\u0435\u043d\u0438\u0432\u044b\u0435, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0438\u043c. \u0422.\u0435., \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c `describe` \u043d\u0430\u0448 `$invoice` \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 `it` (\u0430 \u043d\u0435 `beforeEach`), \u043d\u043e \u0443\u0436\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c: \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0430\u0434\u043c\u0438\u043d. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043f\u043e\u0434\u043c\u0435\u043d\u0430 \u0438 \u0441\u0447\u0435\u0442\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0430\u0434\u043c\u0438\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0443\u043c\u0430\u044e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043b\u0435\u043d\u0438\u0432\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 suite-\u0430, \u0430 \u043d\u0435 \u0442\u0435\u0441\u0442\u0430 \u0438 \u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c `def` \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0435\u0441\u0442\u0430 \u043d\u0435\u043b\u043e\u0433\u0438\u0447\u043d\u043e (\u0437\u043d\u0430\u044e, \u0437\u043d\u0430\u044e \u0432\u0441\u0435 \u043c\u044b \u0443\u043c\u043d\u044b\u0435 \u043b\u044e\u0434\u0438, \u043d\u043e \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c). <\/p>\n<h4>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u0447\u0442\u043e \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435?<\/h4>\n<p>  <\/p>\n<ol>\n<li>\u041b\u0435\u043d\u0438\u0432\u043e\u0441\u0442\u044c! \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. \u041d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u043c \u0442\u0435\u0441\u0442\u0430\u043c \u0431\u044b\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c\u0438<\/li>\n<li>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/li>\n<li>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043a\u043e\u043f\u0438-\u043f\u0430\u0441\u0442\u0430<\/li>\n<li>\u041f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e `it`<\/li>\n<li>\u0418 \u0435\u0449\u0435 \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0444\u0438\u0447 \u0432 \u043f\u0440\u0438\u0434\u0430\u0447\u0443 \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0434\u043e\u0441\u0443\u0433\u0435 \u0432 <a href=\"https:\/\/github.com\/stalniy\/bdd-lazy-var\/blob\/master\/README.md\">README<\/a><\/li>\n<\/ol>\n<p>  <\/p>\n<h4>\u0422\u0435\u0441\u0442\u044b \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443?<\/h4>\n<p>  \u041a\u0430\u043a \u0443\u0436\u0435 \u0432\u044b\u0448\u0435 \u0431\u044b\u043b\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c `subject` \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 subject<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">describe('Invoice', function() {   subject(function() {     var admin = User.create({ role: 'member' });      return Invoice.create({ price: 10, currency: 'USD', user: admin })   });    it('has status &quot;pending&quot; by default', function() {     expect($subject.status).to.equal('pending');   }); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0427\u0442\u043e \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0441 \u043a \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0443  <\/p>\n<pre><code class=\"javascript\">describe('Invoice', function() {   subject(function() {     var admin = User.create({ role: 'member' });      return Invoice.create({ price: 10, currency: 'USD', user: admin })   });    its('status', () =&gt; isExpected.to.equal('pending'));    \/\/ or even better    it(() =&gt; isExpected.to.be.pending) <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0433\u043e \u043f\u043e\u043a\u0430 \u043d\u0435\u0442, \u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043c\u0435\u044f ES6 \u0444\u0438\u0447\u0438 \u0432 \u0440\u0443\u043a\u0430\u0432\u0435 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c `subject` \u0432 \u0442\u0435\u0441\u0442\u0430\u0445.<\/p>\n<p>  <b>P.S.<\/b>: \u0434\u043b\u044f \u0442\u0435\u0445 \u043a\u043e\u043c\u0443 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 `sharedExamples` \u0432 JavaScript \u0442\u0435\u0441\u0442\u0430\u0445 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0449\u0435 \u0438 <a href=\"https:\/\/habrahabr.ru\/post\/207794\/\">\u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e<\/a><\/p>\n<p>  <b>P.P.S.<\/b>: SOLID \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u0432\u0430\u0436\u043d\u0435\u0435 SOLID \u0432\u043e \u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/114047\/\"> https:\/\/habrahabr.ru\/post\/114047\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f: \u00ab\u0417\u0430\u043f\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u043b\u043e\u0434 \u0441\u043b\u0430\u0434\u043e\u043a\u00bb, \u0442\u0430\u043a \u0438 \u0443 \u043c\u0435\u043d\u044f. \u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043d\u0430 RSpec, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 BDD DSL \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u0412\u043e\u0442 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 JavaScript, \u0438\u043c\u0435\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 mocha.js, jasmine.js, etc. \u041d\u043e \u043d\u0435\u0442, \u043c\u0430\u043b\u043e. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u044f\u043a\u0438\u0445 describe-\u043e\u0432 \u0438\u043b\u0438 it-\u043e\u0432 \u0430 \u0435\u0449\u0435 \u0438 \u043b\u0435\u043d\u0438\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u044f \u0438\u043c\u0435\u044e \u0432\u0432\u0435\u0434\u0443 subject \u0438 let.<\/p>\n<p>  \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0433\u043b\u0443\u043f\u043e! \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0433\u043e\u043b\u043e\u0441 \u043a\u0440\u0438\u0447\u0438\u0442 \u00ab\u0417\u0430\u0447\u0435\u043c?\u00bb, \u0430 \u0441\u043e\u0432\u0435\u0441\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442: \u00ab\u0427\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u2014 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e! \u041d\u0443 \u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u2014 \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u0435\u0433\u0430 \u0432\u0430\u0436\u043d\u043e!\u00bb.<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a \u0438 \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f mochajs, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u0435\u043d\u0438\u0432\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 (aka let) \u0438 `subject`. <\/p>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u043e \u0447\u0435\u043c \u044f \u0438 \u0443\u0436\u0435 <s>\u043d\u0430\u043f\u0440\u044f\u0433\u0441\u044f<\/s> \u0437\u0430\u0441\u0432\u0435\u0442\u0438\u043b\u0441\u044f \u043e\u0442 \u0440\u0430\u0434\u043e\u0441\u0442\u0438, \u043c\u0438\u043b\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0438\u043c \u043d\u0430 <a href=\"https:\/\/github.com\/stalniy\/bdd-lazy-var\">Github<\/a>.<br \/>  \u0412\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c, \u0430 \u0432 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0441\u043a\u0435\u043f\u0442\u0438\u043a\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043f\u043e\u0434 cut.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-273324","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=273324"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273324\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=273324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=273324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=273324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}