Week 5, day 2
Today my pair programming partner and I re-did our Airport challenge in Javascript. There were the expected issues of syntax and learning how JS constructs its functions and tests but it was a very informative and productive day.
The thing that gave us the most trouble was stubbing out behaviour with doubles, we can write mocks in Ruby with our eyes closed but doing it in JS is another story. It took a lot of searching and conferring with more experienced colleagues but we did eventually get there.
1 plane = jasmine.createSpyObj('plane', ['location']);
2 plane.location.and.callFake(function() {
3 return 'air';
4 });
That is how we eventually doubled and stubbed behaviour of a foreign object in a unit test.
1 Airport.prototype.locationOf = function(plane) {
2 return plane.location();
3 };
Above is the application code we were trying to unit test.
Very soon the next cohort will be starting at Makers so we've been mentoring them in the lead-up. My mentee is a very smart young lady who came in today to do some pair programming in Ruby TDD/BDD and it went really well.
I was glad to be able to answer her questions and very impressed to see how much she had already achieved on her own.