Skip to content

Instantly share code, notes, and snippets.

View dchelimsky's full-sized avatar

David Chelimsky dchelimsky

  • Retired
  • Chicago, IL, USA
View GitHub Profile
require 'spec_helper.rb'
describe "Migration" do
before(:all) do
MyModel = Object.new
require 'my_migration'
end
before(:each) do
class Foo
def self.capping_bar
alias_method :orig_bar, :bar
def bar; 'BAR'; end
yield
alias_method :bar, :orig_bar
end
def bar; 'bar'; end
end
Spec::Matchers.create(:be_successful) do
matches do |rack|
rack.status == 200
end
message do |not_string, rack|
"Expected #{describe_request(rack)}#{not_string} " \
"to be successful, but it returned a #{rack.status}"
end
end
TODOS = []
def todo(message)
TODOS << "TODO: #{message}\n#{caller(0)[1]}"
end
module Cucumber
module Formatters
class PrettyFormatter
alias_method :orig_dump, :dump
describe SavingsAccount do
it_should fullfill_role("account") do |contract|
contract.overdraft do |account|
initial_balance = account.balance
account.withdraw(initial_balance + 1)
account.balance.should == initial_balance
end
end
end
var execute_search = function(ordinal) {
jQuery.ajax({
type: "GET",
url: jQuery('#asset-search-xml-src').attr('value'),
dataType: "xml",
success: function(xml) {
clear_search_results(ordinal);
jQuery(xml).find('asset').each(function(i, xml_asset) {
asset = new WrappedXmlAsset(xml_asset, ordinal);
if (asset.matches(jQuery('#assets-search-' + ordinal + ' input')[0].value)) {
module InstanceVariableHelpers
def set_ivar(type, name, obj)
instance_variable_set ivar_name(type, name), obj
end
def get_ivar(type, name)
returning instance_variable_get(ivar_name(type, name)) do |obj|
yield obj if block_given?
end
end
<p><b>Title:</b> <%=h @race.title %></p>
<p><b>State:</b> <%=h @race.state.title %></p>
<p><b>Racetype:</b> <%=h @race.racetype.title %></p>
<hr>
<h3>Questions</h3>
<% form_tag :action => :manage_questions, :id => @race do %>
<table>
@dchelimsky
dchelimsky / an example
Created September 30, 2008 14:01 — forked from zdennis/an example
require File.dirname(__FILE__) + '/../spec_helper'
class Foo
def self.per_page
10
end
end
describe Foo do
should_have_per_page 10
<% form_for(@user) do |f| %>
...
<% f.check_boxes_for :roles do |role| %>
<%= role.check_box %>
<%= role.label :name %><br/>
<% end %>
<% end %>
... or ...