This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Based conceptually on the _.extend() function in underscore.js ( see http://documentcloud.github.com/underscore/#extend for more details ) | |
* Copyright (C) 2012 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955 | |
* | |
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. | |
**/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# user.json.rabl_spec.rb | |
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..')) | |
$: << File.join(APP_ROOT, 'spec/support') # for my spec helpers | |
$: << File.join(APP_ROOT, 'config/initializers') # for rabl_init.rb | |
require 'my_spec_mocks' | |
require 'rabl' | |
require 'rabl_init' | |
# We need to fool rabl into thinking we are running rails. | |
# All rabl wants is the root path to help in finding templates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Useful if you have a slow CI server... | |
When /^I wait until all Ajax requests are complete$/ do | |
wait_until do | |
page.evaluate_script('$.active') == 0 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gems: | |
gem 'cucumber' | |
gem 'cucumber-rails' | |
gem 'rspec' | |
gem 'rspec-rails' | |
gem 'capybara' | |
gem 'database_cleaner' | |
gem 'spork' | |
gem 'watchr' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credit goes to JonnyO from stackoverflow: http://stackoverflow.com/questions/7567404/backbone-js-repopulate-or-recreate-the-view/7607853 | |
@BaseView = (options) -> | |
@bindings = [] | |
Backbone.View.apply this, [ options ] | |
_.extend BaseView::, Backbone.View::, | |
# binds and keeps track of objects (models and collections) we want this view to respond to | |
bindTo: (model, event, callback) -> | |
model.bind event, callback, this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((Account) -> | |
Account.Route.Registration = Backbone.Router.extend( | |
routes: | |
"": "index" | |
"!/choose": "choose" | |
initialize: (args) -> | |
if args.view_managers | |
_.each args.view_managers, ((view_manager, name) -> | |
this[name] = view_manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://blog.hashtagify.me/2011/12/08/update-css-rules-with-5-lines-of-coffeescript/ | |
# http://jsfiddle.net/danmaz74/C7dv4/1/ | |
@updateCSS = (selector, styles) -> | |
for sheet in document.styleSheets | |
for rule in sheet.cssRules || sheet.rules || [] | |
if rule.selectorText == selector | |
for style, value of styles | |
rule.style[style] = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc 'Drop, create, migrate, and seed a database' | |
task :reload => :environment do | |
puts "Environment Check: Rails Environment = #{Rails.env}" | |
Rake::Task['db:drop'].reenable | |
Rake::Task['db:drop'].invoke | |
Rake::Task['db:create'].reenable | |
Rake::Task['db:create'].invoke | |
Rake::Task['db:migrate'].reenable if Rails.env.development? | |
Rake::Task['db:migrate'].invoke if Rails.env.development? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In a helper | |
def box(&block) | |
("<div class='box'>" + capture(&block) + "</div>").html_safe | |
end | |
# In your view template | |
#<%= box do %> | |
# <p>Hello World!</p> | |
#<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extracted from the WEBrick::Utils module | |
RAND_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz" | |
def random_string(len) | |
rand_max = RAND_CHARS.bytesize | |
ret = "" | |
len.times{ ret << RAND_CHARS[rand(rand_max)] } | |
ret | |
end |