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
config.before(:each) do | |
with_transaction_callbacks = example.options[:with_transaction_callbacks] | |
if with_transaction_callbacks | |
DatabaseCleaner.strategy = :truncation | |
else | |
DatabaseCleaner.strategy = :transaction | |
end | |
DatabaseCleaner.start | |
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
<% PWD = ENV["PWD"] %> | |
<% PID_DIR = '/usr/local/var/run' %> | |
<% | |
ADDITIONAL = '' | |
if ENV['RVM'] | |
ADDITIONAL = "export PATH=#{ENV['PATH']} && export GEM_HOME=#{ENV['GEM_HOME']} && export GEM_PATH=#{ENV['GEM_PATH']} && export HOME=#{ENV['HOME']} && " | |
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
namespace :monit do | |
desc 'Generate the monit configuration' | |
task :generate do | |
require 'erb' | |
PWD = ENV['PWD'] | |
CONFIG_TEMPLATE = File.join(PWD, 'config', 'monit.cfg.erb') | |
templ = ERB.new(File.read(CONFIG_TEMPLATE)) | |
CONFIG = File.join(PWD, 'monit.cfg') | |
File.open(CONFIG, 'w') {|f| f.write(templ.result) } | |
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
# Sharing common attributes and validations in Rails ActiveRecord to stay DRY | |
module CommonData | |
def self.included(clazz) | |
clazz.class_eval do | |
validates :duplicate_field, presence: true, length: { maximum: 255 } | |
attr_accessible :duplicate_field | |
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
it "tries to update a Model's string attribute in place" do | |
person = Person.new | |
person.name = "" | |
person.save! | |
person.reload | |
person.name = "" | |
person.name << "TEST" | |
person.save! | |
person.reload |
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
mount BeanstalkdView::Server, :at => "/beanstalkd" |
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
# Single instance running locally | |
ENV['BEANSTALK_URL'] = 'beanstalk://localhost/' | |
# Two instances running locally on different ports | |
ENV['BEANSTALK_URL'] = 'beanstalk://localhost/,beanstalk://localhost:12400/' |
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
class Example.Routers.TestRouter extends Backbone.Router | |
routes: | |
"index" : "index" | |
"example/:example_num" : "example" | |
".*" : "index" |
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
describe 'Example.Routers.TestRouter:', -> | |
beforeEach -> | |
@router = new Example.Routers.TestRouter() | |
it "check index route", -> | |
url_fragment = '#' | |
method = RouteHelpers.getRouteHandlerMethod(@router, url_fragment) | |
expect(@router.routes[method]).toEqual('index') | |
it "check example/1 route", -> |
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
window.RouteHelpers = { | |
getRouteHandlerMethod: (router, url_fragment) -> | |
routeStripper = /^[#\/]/; | |
url_fragment = url_fragment.replace(routeStripper, '') | |
routes = Object.keys(router.routes) | |
return _.find routes, (route) => | |
regexp = router._routeToRegExp(route) | |
if (regexp.test(url_fragment)) | |
return true | |
else |