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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button 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
# ==== Database connection | |
DATABASE_URL = if File.exists?(root_path('config/database.yml')) | |
YAML.load(File.read('config/database.yml'))[RACK_ENV.to_sym] | |
end | |
if DATABASE_URL | |
DB = Sequel.connect(DATABASE_URL) | |
else | |
# Use in-memory sqlite if no db has been specified (probably running tests) |
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
<?php | |
/** | |
* This is free and unencumbered software released into the public domain. | |
* | |
* Anyone is free to copy, modify, publish, use, compile, sell, or | |
* distribute this software, either in source code form or as a compiled | |
* binary, for any purpose, commercial or non-commercial, and by any | |
* means. | |
* |
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
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
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 HelloWorldController < AbstractController::Base | |
include AbstractController::Rendering | |
include AbstractController::Layouts | |
include AbstractController::Helpers | |
include AbstractController::Translation | |
include AbstractController::AssetPaths | |
include ActionController::UrlWriter | |
# Uncomment if you want to use helpers defined in ApplicationHelper in your views | |
# helper ApplicationHelper |
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
# create the template | |
template = PageOfflineTemplate.new | |
template.quote = quote | |
template.pages = quote.build_pages | |
# Here I render a template with layout to a string then a PDF | |
pdf = PDFKit.new template.render_to_string(:template=>"quotes/review.html.haml") | |
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
[merge] | |
keepBackup = false | |
tool = custom | |
[mergetool "custom"] | |
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "$PWD/$BASE" "$PWD/$REMOTE" "$PWD/$LOCAL" "$PWD/$MERGED" | |
keepTemporaries = false | |
trustExitCode = false | |
keepBackup = false |
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
#! usr/bin/env ruby | |
require 'chunky_png' | |
class ChunkyPNG::Image | |
# s: Integer (pixel size) | |
def pixelize s = 10 | |
temp = Array.new((height*1.0/s).ceil) {Array.new((width*1.0/s).ceil) {Array.new(3) {0}}} | |
height.times {|j| width.times {|i| ChunkyPNG::Color.to_truecolor_bytes(get_pixel(i,j)).each.with_index {|e,k| temp[j/s][i/s][k] += e}}} | |
png = ChunkyPNG::Image.new width, height | |
sq = s**2 |
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
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(window).load(function(){ | |
$().hatchShow(); | |
}); | |
jQuery.fn.hatchShow = function(){ | |
$('.hsjs').css('display','inner-block').css('white-space','pre').each(function(){ | |
var t = $(this); | |
t.wrap("<span class='hatchshow_temp' style='display:block'>"); | |
var pw = t.parent().width(); |
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 'spec_helper' | |
describe FeaturePool do | |
it "creates a new instance given valid attributes" do | |
Fabricate :feature_pool | |
end | |
it "is not valid without a name" do | |
Fabricate.build(:feature_pool, :name => "").should_not be_valid | |
end |
OlderNewer