Skip to content

Instantly share code, notes, and snippets.

@evan-007
evan-007 / capyreact.md
Last active January 25, 2017 19:28
capybara webkit with react

capybara needs qt5 to work with react. OSX probably has qt 4 installed by default.

thoughtbot/capybara-webkit#666

brew uninstall qt
brew install qt5
brew linkapps qt5
brew doctor
gem uninstall capybara-webkit
@evan-007
evan-007 / rspec_errors.rb
Created September 18, 2014 23:05
rspec token auth test errors
ruby /Users/evan/.rvm/gems/ruby-2.1.1/bin/rspec spec/controllers/api/v1/messages_controller_spec.rb(1245,0x7fff792bf310) malloc: *** error for object 0x7ff15fb73c00: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
@evan-007
evan-007 / ihateProtractor.js
Created September 11, 2014 16:29
protractor scoping
var helper = require('../helpers/signinHelper')
describe('Adding friends', function(){
beforeEach(function(){
helper.login();
})
afterEach(function(){
browser.manage().deleteAllCookies();
@evan-007
evan-007 / gulpfile.js
Last active August 19, 2016 01:33
gulp shell example
var gulp = require('gulp');
var connect = require('gulp-connect');
var modRewrite = require('connect-modrewrite');
var runSequence = require('run-sequence');
var shell = require('gulp-shell');
//proxy all requests to /api to localhost:3000 for rails api
gulp.task('connect', function(){
connect.server({
root: './app',
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
.directive('mailBox', function(OneMessage){
return {
restrict: 'E',
templateUrl: './ui/messages/mailbox.html',
scope: {
messages: '=messages'
},
//wow this actual works, scope is $scope?
link: function(scope, element, attrs) {
scope.getMessage = function(id) {
@evan-007
evan-007 / gist:c8de5bc45fe86e2fd898
Last active August 29, 2015 14:03
Protractor matchers/commands
Matchers are same as selenium webdriver matchers!
//url matcher
expect(brower.getCurrentUrl()).toMatch(/\/yourmom/);
//by ng-model
//match input form value
locationInput = element(by.model('signup.location'));
expect(locationInput.getAttribute("value")).toMatch(/boston/);
@evan-007
evan-007 / gist:5e69fa7a41d09b43adb6
Last active October 31, 2016 10:34
angular testing

Testing countries & capitals

karma init installs jasmine 1.3 by default, 2.0 has cleaner syntax for asynchronous tests, but doesn't support all of the same libraries.

Testing an Asynchronous Service with Jasmine 2.0

If there is a service that uses promises, like:

var app = angular.module('app', []);
(function(){
angular.module('app', []);
});
angular.module('app', []);
@evan-007
evan-007 / gist:38c70da8a3dd6b856940
Last active August 29, 2015 14:02
f-f-ff-factory
//factory returns entire API response, controller is responsible for parsing the return value
.factory('CapitalData', function(API_AUTH, $http, $q, SEARCH_PATH){
return function(countryId, capital){
var defer = $q.defer();
$http.get(SEARCH_PATH+'&name_equals='+capital+'&country='+countryId+API_AUTH)
.success(function(data){
defer.resolve(data);
});
return defer.promise;