# Anchor
click_link 'Save'
# Button
click_button 'awesome'
# Both aboveUpdated for Rails 4.0.0+
-
Set up the
bowergem. -
Follow the Bower instructions and list your dependencies in your
bower.json, e.g.// bower.json
{
| # | |
| # A CORS (Cross-Origin Resouce Sharing) config for nginx | |
| # | |
| # == Purpose | |
| # | |
| # This nginx configuration enables CORS requests in the following way: | |
| # - enables CORS just for origins on a whitelist specified by a regular expression | |
| # - CORS preflight request (OPTIONS) are responded immediately | |
| # - Access-Control-Allow-Credentials=true for GET and POST requests |
| # This class should parse a yaml configuration file. | |
| # | |
| require 'ostruct' | |
| class APISettings | |
| def self.cross_origin_resource_sharing | |
| OpenStruct.new(allow: ['http://127.0.0.1:8080', 'http://localhost:8080']) | |
| end | |
| end |
I. Create a Middleman project with middleman-ember-template
$ middleman init hello --template=ember
II. Install ember.js package
$ bower install ember
In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.
A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.
You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.
class Article < ActiveRecord::Base| // sizeSelectionModule and addToCartModule are local variables that | |
| // act as shortcuts to their namespaces | |
| describe("when add to cart form is submitted", function () { | |
| var $form; | |
| beforeEach(function () { | |
| // We use div instead of form so we can just mock the submit behavior | |
| $form = $("<div />"); | |
| }); |
| Enable TRIM on non-Apple SSDs in OS X 10.8.2 Mountain Lion. | |
| WARNING: This is ONLY tested on 10.8.2 (IOAHCIBlockStorage version 2.3.1), and NOT earlier or later versions. | |
| Check /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/version.plist | |
| Technical note: The driver changed in 10.8.2 and similar perl commands that worked in earlier OS X versions did not work for me once I updated to 10.8.2. | |
| Run the following commands in Terminal… |
| #!/bin/sh | |
| # Credits to: | |
| # - http://vstone.eu/reducing-vagrant-box-size/ | |
| # - https://github.com/mitchellh/vagrant/issues/343 | |
| aptitude -y purge ri | |
| aptitude -y purge installation-report landscape-common wireless-tools wpasupplicant ubuntu-serverguide | |
| aptitude -y purge python-dbus libnl1 python-smartpm python-twisted-core libiw30 | |
| aptitude -y purge python-twisted-bin libdbus-glib-1-2 python-pexpect python-pycurl python-serial python-gobject python-pam python-openssl libffi5 |
| 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 |