save_and_open_page
have_button(locator)| shared_examples_for "driver with javascript support" do | |
| before { @driver.visit('/with_js') } | |
| describe '#find' do | |
| it "should find dynamically changed nodes" do | |
| @driver.find('//p').first.text.should == 'I changed it' | |
| end | |
| end | |
| describe '#drag_to' do |
Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.
If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.
| jQuery(function($) { | |
| // returns an array of the potential selector components for the first element in the jQuery object. IDs, classes, and tagNames only. | |
| var getSelectorComponents = function($el) { | |
| var components = []; | |
| var id = $el.attr('id'); | |
| if (typeof(id)!='undefined' && /[^\s]/.test(id)) { | |
| components.push('#'+id); | |
| } |
| var app = require(process.cwd() + '/app'); | |
| var winston = require('winston'); | |
| var _ = require('lodash'); | |
| // Set up logger | |
| var customColors = { | |
| trace: 'white', | |
| debug: 'green', | |
| info: 'green', | |
| warn: 'yellow', |
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');Those suck for maintenance and they're ugly.
| # lib/tasks/db.rake | |
| namespace :db do | |
| desc "Dumps the database to db/APP_NAME.dump" | |
| task :dump => :environment do | |
| cmd = nil | |
| with_config do |app, host, db, user| | |
| cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
| end | |
| puts cmd |
Gemfile
gem 'rails_config'
config/settings/development.yml
mailer:| _ = require('underscore') | |
| React = require('React') | |
| {span, input} = React.DOM | |
| # Check box that always submits a value, even if unchecked. This uses the same | |
| # trick as Rails's `f.check_box`: a hidden input with the same name as the | |
| # checkbox but with a value of 0 that appears before the actual checkbox. When | |
| # the checkbox is checked, the checkbox's value will be submitted, when it's | |
| # unchecked, then the hidden input value of 0 will be submitted. |