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
require File.expand_path(File.dirname(__FILE__) + "/../test_helper") | |
require 'capybara/rails' | |
Jammit.load_configuration(Jammit::DEFAULT_CONFIG_PATH) | |
Jammit.packager.force = true | |
Jammit.packager.precache_all | |
class CapybaraTest < ActionController::IntegrationTest | |
fixtures :all | |
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
var LocationHash = Class.create({ | |
currentHash: "", | |
initialize: function(proxy) { | |
this.proxy = proxy || { | |
get: function() { | |
return location.hash; | |
}, | |
set: function(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
var MockPrompt = { | |
install: function() { | |
MockPrompt.message = undefined; | |
MockPrompt.value = undefined; | |
MockPrompt.returnValue = undefined; | |
MockPrompt.originalPrompt = window.prompt; | |
window.prompt = function(message, value) { | |
MockPrompt.message = message; | |
MockPrompt.value = 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 :monit do | |
task :install, :roles => :app do | |
raise "ENV[PLUGIN] is missing" unless ENV['PLUGIN'] | |
sudo "ln -sf #{current_path}/etc/monit.d/#{ENV['PLUGIN']} /etc/monit.d/#{ENV['PLUGIN']}" | |
end | |
task :list, :roles => :app do | |
sudo "ls -al /etc/monit.d" | |
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
task :convert do | |
require 'nokogiri' | |
Dir.glob("public/javascripts/test-pages/**/*_test.html").each do |file| | |
doc = Nokogiri::HTML(File.read(file)) | |
name = File.basename(file, "_test.html") | |
script = doc.css("script").find { |tag| tag[:src].blank? } | |
if body = doc.at("body") | |
File.open("spec/javascripts/fixtures/#{name}.html", "w") do |out| |
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
function assertEquals(expected, actual) { | |
expect(expected).toEqual(actual); | |
} | |
function assertNotEquals(expected, actual) { | |
expect(expected).toNotEqual(actual); | |
} | |
function assertTrue(value) { | |
expect(value).toBeTruthy(); |
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 :jasmine do | |
task :fixtures do | |
blobs = {} | |
Dir.glob("spec/javascripts/fixtures/*.html").each do |file| | |
blobs[File.basename(file, ".html")] = File.read(file) | |
end | |
File.open("spec/javascripts/helpers/fixtures.js", "w") do |file| | |
file << <<END | |
var Fixtures = { |
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 Delayed::Worker | |
def handle_failed_job_with_hoptoad(job, error) | |
HoptoadNotifier.notify(error) | |
handle_failed_job_without_hoptoad(job, error) | |
end | |
alias_method_chain :handle_failed_job, :hoptoad | |
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
TIMINGS = Hash.new(0) | |
module Capistrano::Configuration::Execution | |
def execute_task_with_timing(task) | |
start = Time.now | |
execute_task_without_timing(task) | |
ensure | |
TIMINGS[task.fully_qualified_name] += Time.now - 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
var fake = function(methods) { | |
methods = methods || []; | |
var object = {listeners: {}}; | |
for (var i = 0; i < methods.length; i++) { | |
object[methods[i]] = jasmine.createSpy(); | |
}; | |
object.addEventListener = function(event, callback) { | |
object.listeners[event] = callback; |