A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
| # Filter payment methods in Spree depending on the shipping name, | |
| # use the following snippet within your activation method to | |
| # make it work: | |
| # | |
| # CheckoutsController.class_eval { include FilterPaymentMethods } | |
| # | |
| # The magic happens within the InstanceMethods module, change the | |
| # regexp to fit your needs. | |
| # | |
| # Kai Krakow, http://github.com/kakra |
| #Model | |
| @user.should have(1).error_on(:username) # Checks whether there is an error in username | |
| @user.errors[:username].should include("can't be blank") # check for the error message | |
| #Rendering | |
| response.should render_template(:index) | |
| #Redirecting | |
| response.should redirect_to(movies_path) |
| Rails Date Formats – strftime | |
| StrFTime Format Codes for Ruby on Rails | |
| Year | |
| %Y year with century 2007 | |
| %y year without century 07 | |
| %C century number (year divided by 100) 20 | |
| Month | |
| %B full month name January |
| require 'fileutils' | |
| # Warning: The following deploy task will completely overwrite whatever is currently deployed to Heroku. | |
| # The deploy branch is rebased onto master, so the push needs to be forced. | |
| desc "Deploy app to Heroku after precompiling assets" | |
| task :deploy do | |
| deploy_branch = 'heroku' | |
| remote = 'heroku' | |
| deploy_repo_dir = "tmp/heroku_deploy" |
| #!/usr/bin/env python | |
| __author__ = 'Kevin Warrick' | |
| __email__ = 'kwarrick@uga.edu' | |
| import cPickle | |
| from functools import wraps | |
| def redis_lru(capacity=5000, slice=slice(None)): | |
| """ | |
| Simple Redis-based LRU cache decorator *. |
| function go() { | |
| var userId = prompt('Username?', 'Guest'); | |
| checkIfUserExists(userId); | |
| } | |
| var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users'; | |
| function userExistsCallback(userId, exists) { | |
| if (exists) { | |
| alert('user ' + userId + ' exists!'); |
A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
| /*************************************************** | |
| * Simple and elegant, no code complexity | |
| * Disadvantages: Requires warming all data into server memory (could take a long time for MBs of data or millions of records) | |
| * (This disadvantage should go away as we add optimizations to the core product) | |
| ***************************************************/ | |
| var fb = firebase.database.ref(); | |
| /** | |
| * @param {string} emailAddress |
| #Model | |
| @user.should have(1).error_on(:username) # Checks whether there is an error in username | |
| @user.errors[:username].should include("can't be blank") # check for the error message | |
| #Rendering | |
| response.should render_template(:index) | |
| #Redirecting | |
| response.should redirect_to(movies_path) |
| /** @jsx React.DOM */ | |
| 'use strict'; | |
| var React = require('react'); | |
| var ContentEditableLabel = React.createClass({ | |
| propTypes: { | |
| tag: React.PropTypes.func, |