Re: [nodejs] Re: Losing scope of variable

2015-03-21 Thread klrumpf

  
  
+1 for  moderation

+1 for your competent answers, Aria

   
On 20/03/15 18:42, Aria Stewart wrote:


  

  
On Mar 20, 2015, at 11:58 AM, CoffeeManiac dschin...@gmail.com wrote:

It's very very very very annoying that these posts are moderated.  What forum does that!

  
  
Ones where people post job ads all the time, where people double-post when things are vaguely slow, and ones where people bring dead threads back from the grave about something tangentially related, when they should start a new thread instead!

Also ones where we expect a minimum standard of kindness and decency and intend to enforce that.

Sorry I've been slow approving messages -- I suspect we're on opposite ends of the world!

Aria




  




-- 
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/550D5450.2010409%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: Losing scope of variable

2015-03-20 Thread zladuric
phantom.create() and then the createPage() are async. That means that by 
the time the interpreter gets to the module.exports section, your _page is 
stil not bound. It only fired a phantom.create, and it's still waiting for 
its callback and phantom.createPage callback. You could probably add a 
console.log('Creating exports') just above creating module.exports and I 
bet that one would be shown before the other two log lines.

Now, you would have to defer creating the exports, or at least put page in 
something like `var locals = {page: placeholder}`, and then calling it as 
locals.page.open() later. I think something like that would work.

On Thursday, March 19, 2015 at 9:39:36 PM UTC+1, CoffeeManiac wrote:

 I can't figure out why I lose the object instance for my variable _page 
 once it gets inside the function for the module.exports.  It bombs out here 
 because _page is undefined but it's fine and has an instance BEFORE this 
 _page.open 

 var phantom = require('phantom'), _ph, _page;
 var should = require('chai').should();

 phantom.create(--web-security=no, --ignore-ssl-errors=yes, { port: 12345 
 }, function (ph) {
 console.log(Phantom Bridge Initiated);
 _ph = ph;

 _ph.createPage(function(page) {
 console.log(Page created!);
 _page = page;
 });

 phaçntom.exit();
 });


 module.exports = function() {
 use strict;

 this.Given(/^I visit the episodes display page$/, function (callback) {

 console.log(_page:  + _page);
 _page.open(/, function(status){

 status.should.equal(success);
 });

 callback();

 });


 this.Then(/^I should not see any episodes listed$/, function (callback) {
 //page.should.have.content(There are no episodes available);

 callback.pending();
 });



 this.Given(/^there are some episodes to view$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.When(/^I go to the episodes display page$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.Then(/^I should see a list of episodes grouped by Topic$/, function 
 (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });


 };



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/dcb07f98-06e6-4603-b8fe-61da7a66dcc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: Losing scope of variable

2015-03-20 Thread CoffeeManiac
Right but I do not know how to resolve this.  How can I get this to work?



On Thursday, March 19, 2015 at 4:16:37 PM UTC-5, Zach Rollyson wrote:

 Initial assumption would be that _page gets defined in a callback within a 
 callback and _page.open gets called in a different callback so all that is 
 asynchronous and there could be no guarantee that _page is defined by the 
 time _page.open is called.

 On Thursday, March 19, 2015 at 4:39:36 PM UTC-4, CoffeeManiac wrote:

 I can't figure out why I lose the object instance for my variable _page 
 once it gets inside the function for the module.exports.  It bombs out here 
 because _page is undefined but it's fine and has an instance BEFORE this 
 _page.open 

 var phantom = require('phantom'), _ph, _page;
 var should = require('chai').should();

 phantom.create(--web-security=no, --ignore-ssl-errors=yes, { port: 12345 
 }, function (ph) {
 console.log(Phantom Bridge Initiated);
 _ph = ph;

 _ph.createPage(function(page) {
 console.log(Page created!);
 _page = page;
 });

 phaçntom.exit();
 });


 module.exports = function() {
 use strict;

 this.Given(/^I visit the episodes display page$/, function (callback) {

 console.log(_page:  + _page);
 _page.open(/, function(status){

 status.should.equal(success);
 });

 callback();

 });


 this.Then(/^I should not see any episodes listed$/, function (callback) {
 //page.should.have.content(There are no episodes available);

 callback.pending();
 });



 this.Given(/^there are some episodes to view$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.When(/^I go to the episodes display page$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.Then(/^I should see a list of episodes grouped by Topic$/, function 
 (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });


 };



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/35cd9427-87d1-464a-aea8-2c10d34a1f2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: Losing scope of variable

2015-03-20 Thread CoffeeManiac
right so how would I solve this and share _page?

On Thursday, March 19, 2015 at 4:16:37 PM UTC-5, Zach Rollyson wrote:

 Initial assumption would be that _page gets defined in a callback within a 
 callback and _page.open gets called in a different callback so all that is 
 asynchronous and there could be no guarantee that _page is defined by the 
 time _page.open is called.

 On Thursday, March 19, 2015 at 4:39:36 PM UTC-4, CoffeeManiac wrote:

 I can't figure out why I lose the object instance for my variable _page 
 once it gets inside the function for the module.exports.  It bombs out here 
 because _page is undefined but it's fine and has an instance BEFORE this 
 _page.open 

 var phantom = require('phantom'), _ph, _page;
 var should = require('chai').should();

 phantom.create(--web-security=no, --ignore-ssl-errors=yes, { port: 12345 
 }, function (ph) {
 console.log(Phantom Bridge Initiated);
 _ph = ph;

 _ph.createPage(function(page) {
 console.log(Page created!);
 _page = page;
 });

 phaçntom.exit();
 });


 module.exports = function() {
 use strict;

 this.Given(/^I visit the episodes display page$/, function (callback) {

 console.log(_page:  + _page);
 _page.open(/, function(status){

 status.should.equal(success);
 });

 callback();

 });


 this.Then(/^I should not see any episodes listed$/, function (callback) {
 //page.should.have.content(There are no episodes available);

 callback.pending();
 });



 this.Given(/^there are some episodes to view$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.When(/^I go to the episodes display page$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.Then(/^I should see a list of episodes grouped by Topic$/, function 
 (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });


 };



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/b890026f-d6ce-4aa0-a9c1-801127406825%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: Losing scope of variable

2015-03-20 Thread CoffeeManiac
Thanks.  So where exactly would you put var locals, in the create method or 
outside that?


On Friday, March 20, 2015 at 9:50:24 AM UTC-5, zladuric wrote:

 phantom.create() and then the createPage() are async. That means that by 
 the time the interpreter gets to the module.exports section, your _page is 
 stil not bound. It only fired a phantom.create, and it's still waiting for 
 its callback and phantom.createPage callback. You could probably add a 
 console.log('Creating exports') just above creating module.exports and I 
 bet that one would be shown before the other two log lines.

 Now, you would have to defer creating the exports, or at least put page in 
 something like `var locals = {page: placeholder}`, and then calling it as 
 locals.page.open() later. I think something like that would work.

 On Thursday, March 19, 2015 at 9:39:36 PM UTC+1, CoffeeManiac wrote:

 I can't figure out why I lose the object instance for my variable _page 
 once it gets inside the function for the module.exports.  It bombs out here 
 because _page is undefined but it's fine and has an instance BEFORE this 
 _page.open 

 var phantom = require('phantom'), _ph, _page;
 var should = require('chai').should();

 phantom.create(--web-security=no, --ignore-ssl-errors=yes, { port: 12345 
 }, function (ph) {
 console.log(Phantom Bridge Initiated);
 _ph = ph;

 _ph.createPage(function(page) {
 console.log(Page created!);
 _page = page;
 });

 phaçntom.exit();
 });


 module.exports = function() {
 use strict;

 this.Given(/^I visit the episodes display page$/, function (callback) {

 console.log(_page:  + _page);
 _page.open(/, function(status){

 status.should.equal(success);
 });

 callback();

 });


 this.Then(/^I should not see any episodes listed$/, function (callback) {
 //page.should.have.content(There are no episodes available);

 callback.pending();
 });



 this.Given(/^there are some episodes to view$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.When(/^I go to the episodes display page$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.Then(/^I should see a list of episodes grouped by Topic$/, function 
 (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });


 };



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/8ca70616-3973-4dd2-b0e0-f186b63bc27f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: Losing scope of variable

2015-03-20 Thread CoffeeManiac
It's very very very very annoying that these posts are moderated.  What 
forum does that!

On Friday, March 20, 2015 at 9:50:24 AM UTC-5, zladuric wrote:

 phantom.create() and then the createPage() are async. That means that by 
 the time the interpreter gets to the module.exports section, your _page is 
 stil not bound. It only fired a phantom.create, and it's still waiting for 
 its callback and phantom.createPage callback. You could probably add a 
 console.log('Creating exports') just above creating module.exports and I 
 bet that one would be shown before the other two log lines.

 Now, you would have to defer creating the exports, or at least put page in 
 something like `var locals = {page: placeholder}`, and then calling it as 
 locals.page.open() later. I think something like that would work.

 On Thursday, March 19, 2015 at 9:39:36 PM UTC+1, CoffeeManiac wrote:

 I can't figure out why I lose the object instance for my variable _page 
 once it gets inside the function for the module.exports.  It bombs out here 
 because _page is undefined but it's fine and has an instance BEFORE this 
 _page.open 

 var phantom = require('phantom'), _ph, _page;
 var should = require('chai').should();

 phantom.create(--web-security=no, --ignore-ssl-errors=yes, { port: 12345 
 }, function (ph) {
 console.log(Phantom Bridge Initiated);
 _ph = ph;

 _ph.createPage(function(page) {
 console.log(Page created!);
 _page = page;
 });

 phaçntom.exit();
 });


 module.exports = function() {
 use strict;

 this.Given(/^I visit the episodes display page$/, function (callback) {

 console.log(_page:  + _page);
 _page.open(/, function(status){

 status.should.equal(success);
 });

 callback();

 });


 this.Then(/^I should not see any episodes listed$/, function (callback) {
 //page.should.have.content(There are no episodes available);

 callback.pending();
 });



 this.Given(/^there are some episodes to view$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.When(/^I go to the episodes display page$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.Then(/^I should see a list of episodes grouped by Topic$/, function 
 (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });


 };



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/3e555ffb-fe0f-45db-8f8e-fa09371037e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: Losing scope of variable

2015-03-20 Thread CoffeeManiac
Also wouldn't the fact that I am doing a pre-mature .exit() dispose any 
page that was created?  I think that would also be another issue besides 
just the async issue I'm assuming...

On Friday, March 20, 2015 at 9:50:24 AM UTC-5, zladuric wrote:

 phantom.create() and then the createPage() are async. That means that by 
 the time the interpreter gets to the module.exports section, your _page is 
 stil not bound. It only fired a phantom.create, and it's still waiting for 
 its callback and phantom.createPage callback. You could probably add a 
 console.log('Creating exports') just above creating module.exports and I 
 bet that one would be shown before the other two log lines.

 Now, you would have to defer creating the exports, or at least put page in 
 something like `var locals = {page: placeholder}`, and then calling it as 
 locals.page.open() later. I think something like that would work.

 On Thursday, March 19, 2015 at 9:39:36 PM UTC+1, CoffeeManiac wrote:

 I can't figure out why I lose the object instance for my variable _page 
 once it gets inside the function for the module.exports.  It bombs out here 
 because _page is undefined but it's fine and has an instance BEFORE this 
 _page.open 

 var phantom = require('phantom'), _ph, _page;
 var should = require('chai').should();

 phantom.create(--web-security=no, --ignore-ssl-errors=yes, { port: 12345 
 }, function (ph) {
 console.log(Phantom Bridge Initiated);
 _ph = ph;

 _ph.createPage(function(page) {
 console.log(Page created!);
 _page = page;
 });

 phaçntom.exit();
 });


 module.exports = function() {
 use strict;

 this.Given(/^I visit the episodes display page$/, function (callback) {

 console.log(_page:  + _page);
 _page.open(/, function(status){

 status.should.equal(success);
 });

 callback();

 });


 this.Then(/^I should not see any episodes listed$/, function (callback) {
 //page.should.have.content(There are no episodes available);

 callback.pending();
 });



 this.Given(/^there are some episodes to view$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.When(/^I go to the episodes display page$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.Then(/^I should see a list of episodes grouped by Topic$/, function 
 (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });


 };



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/4186ef17-3235-4f8a-90f0-8d2399f5270a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [nodejs] Re: Losing scope of variable

2015-03-20 Thread Aria Stewart

 On Mar 20, 2015, at 11:58 AM, CoffeeManiac dschin...@gmail.com wrote:
 
 It's very very very very annoying that these posts are moderated.  What forum 
 does that!

Ones where people post job ads all the time, where people double-post when 
things are vaguely slow, and ones where people bring dead threads back from the 
grave about something tangentially related, when they should start a new thread 
instead!

Also ones where we expect a minimum standard of kindness and decency and intend 
to enforce that.

Sorry I've been slow approving messages -- I suspect we're on opposite ends of 
the world!

Aria

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/7972C72E-4E20-4AA0-B306-7EB4BD2CA915%40dinhe.net.
For more options, visit https://groups.google.com/d/optout.


smime.p7s
Description: S/MIME cryptographic signature


[nodejs] Re: Losing scope of variable

2015-03-20 Thread Zach Rollyson
CoffeeManiac you could either use a promises to synchronize your async 
issues 
(https://www.google.com/webhp?sourceid=chrome-instantion=1espv=2ie=UTF-8#q=q%20promise)
 
or you could move phantom.create down into the module and call _page.open 
inside the _ph.createPage callback (or some abstraction of the same).

On Friday, March 20, 2015 at 10:50:18 AM UTC-4, CoffeeManiac wrote:

 Right but I do not know how to resolve this.  How can I get this to work?



 On Thursday, March 19, 2015 at 4:16:37 PM UTC-5, Zach Rollyson wrote:

 Initial assumption would be that _page gets defined in a callback within 
 a callback and _page.open gets called in a different callback so all that 
 is asynchronous and there could be no guarantee that _page is defined by 
 the time _page.open is called.

 On Thursday, March 19, 2015 at 4:39:36 PM UTC-4, CoffeeManiac wrote:

 I can't figure out why I lose the object instance for my variable _page 
 once it gets inside the function for the module.exports.  It bombs out here 
 because _page is undefined but it's fine and has an instance BEFORE this 
 _page.open 

 var phantom = require('phantom'), _ph, _page;
 var should = require('chai').should();

 phantom.create(--web-security=no, --ignore-ssl-errors=yes, { port: 
 12345 }, function (ph) {
 console.log(Phantom Bridge Initiated);
 _ph = ph;

 _ph.createPage(function(page) {
 console.log(Page created!);
 _page = page;
 });

 phaçntom.exit();
 });


 module.exports = function() {
 use strict;

 this.Given(/^I visit the episodes display page$/, function (callback) {

 console.log(_page:  + _page);
 _page.open(/, function(status){

 status.should.equal(success);
 });

 callback();

 });


 this.Then(/^I should not see any episodes listed$/, function (callback) 
 {
 //page.should.have.content(There are no episodes available);

 callback.pending();
 });



 this.Given(/^there are some episodes to view$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.When(/^I go to the episodes display page$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.Then(/^I should see a list of episodes grouped by Topic$/, 
 function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });


 };



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/745d505a-f573-4cf4-ad00-86c9c6743089%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [nodejs] Re: Losing scope of variable

2015-03-20 Thread Zlatko Đurić
Off-topic first:
Didn't know Aria was a moderator here (although I read a lot of your
posts), and I thank you heartily for your effort. You're doing a great job.

At the OP:

In all test frameworks there's an usual way of setting up and dismantling
test suites. I'm not sure what you use there, but there should be something
like `before()` and `after()` for that where you'd setup the page and make
it accessible in the test suites' scopes.


2015-03-20 18:42 GMT+01:00 Aria Stewart aredri...@dinhe.net:


  On Mar 20, 2015, at 11:58 AM, CoffeeManiac dschin...@gmail.com wrote:
 
  It's very very very very annoying that these posts are moderated.  What
 forum does that!

 Ones where people post job ads all the time, where people double-post when
 things are vaguely slow, and ones where people bring dead threads back from
 the grave about something tangentially related, when they should start a
 new thread instead!

 Also ones where we expect a minimum standard of kindness and decency and
 intend to enforce that.

 Sorry I've been slow approving messages -- I suspect we're on opposite
 ends of the world!

 Aria

 --
 Job board: http://jobs.nodejs.org/
 New group rules:
 https://gist.github.com/othiym23/9886289#file-moderation-policy-md
 Old group rules:
 https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups nodejs group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/nodejs/QRX6t4c3ViY/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 nodejs+unsubscr...@googlegroups.com.
 To post to this group, send email to nodejs@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/nodejs/7972C72E-4E20-4AA0-B306-7EB4BD2CA915%40dinhe.net
 .
 For more options, visit https://groups.google.com/d/optout.




-- 
Zlatko

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CADu3pbzAN8MmFCLGtiidofV0%2BhNudD-VkSebCXPV89ykOEVB_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: Losing scope of variable

2015-03-19 Thread Zach Rollyson
Initial assumption would be that _page gets defined in a callback within a 
callback and _page.open gets called in a different callback so all that is 
asynchronous and there could be no guarantee that _page is defined by the 
time _page.open is called.

On Thursday, March 19, 2015 at 4:39:36 PM UTC-4, CoffeeManiac wrote:

 I can't figure out why I lose the object instance for my variable _page 
 once it gets inside the function for the module.exports.  It bombs out here 
 because _page is undefined but it's fine and has an instance BEFORE this 
 _page.open 

 var phantom = require('phantom'), _ph, _page;
 var should = require('chai').should();

 phantom.create(--web-security=no, --ignore-ssl-errors=yes, { port: 12345 
 }, function (ph) {
 console.log(Phantom Bridge Initiated);
 _ph = ph;

 _ph.createPage(function(page) {
 console.log(Page created!);
 _page = page;
 });

 phaçntom.exit();
 });


 module.exports = function() {
 use strict;

 this.Given(/^I visit the episodes display page$/, function (callback) {

 console.log(_page:  + _page);
 _page.open(/, function(status){

 status.should.equal(success);
 });

 callback();

 });


 this.Then(/^I should not see any episodes listed$/, function (callback) {
 //page.should.have.content(There are no episodes available);

 callback.pending();
 });



 this.Given(/^there are some episodes to view$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.When(/^I go to the episodes display page$/, function (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });

 this.Then(/^I should see a list of episodes grouped by Topic$/, function 
 (callback) {
 // Write code here that turns the phrase above into concrete actions
 callback.pending();
 });


 };



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
nodejs group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/f47180f2-effb-44f0-bf07-eb156aba65a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.