This file contains hidden or 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
module Spec | |
module Matchers | |
class IncludeAll | |
attr_reader :expected_elements, :actual_elements, :extra_elements_in_actual, :extra_elements_in_expected | |
def initialize(expected_elements) | |
@expected_elements = expected_elements | |
end | |
def matches?(actual_elements) | |
@actual_elements = actual_elements |
This file contains hidden or 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 Foo | |
def bar | |
"baz" | |
end | |
end | |
if __FILE__ == $0 | |
require 'rubygems' | |
require 'spec' | |
This file contains hidden or 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 Views::Layouts::Application < Erector::Widget | |
def render | |
div :class => "header" do | |
text "header" | |
end | |
div :class => "body" do | |
inner_content | |
end | |
This file contains hidden or 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
# app/views/hellos/erb.html.erb | |
# note the leading spaces - this makes it exactly the same number of bytes that erector outputs | |
<%- 1000.times do -%><%= render :partial => "simple" %><%- end -%> | |
# app/views/hellos/_simple.html.erb | |
<p><%= "hello world" %></p> | |
This file contains hidden or 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
When /^I type "([^\"]*)" into the "([^\"]*)" rich text editor$/ do |description, iframe_id| | |
selenium.select_frame "id=#{iframe_id}" | |
selenium.type_keys "css=body", description | |
selenium.select_frame "relative=top" | |
end |
This file contains hidden or 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
def in_memory_database? | |
ENV["RAILS_ENV"] == "test" and | |
ENV["IN_MEMORY_DB"] and | |
Rails::Configuration.new.database_configuration['test-in-memory']['database'] == ':memory:' | |
end | |
$TESTING=true | |
if in_memory_database? | |
puts "connecting to in-memory database ..." |
This file contains hidden or 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
=begin | |
See http://www.websequencediagrams.com/ for awesome diagrams. It has an api as well. | |
DSL-based state machine implementations make it hard to follow good coding practices, such as: | |
- keeping things DRY | |
- making sure that objects have single responsibility | |
- making sure that classes change at the same pace (open closed) | |
- making sure that classes only depend on classes that change less often than they do |
This file contains hidden or 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
# created by Peter Jaros and Jeff Dean | |
require "rubygems" | |
require "spec" | |
require "active_support" | |
module Weekdays | |
def advance_weekdays(days) | |
d = self | |
days.times do |day| |
This file contains hidden or 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
# This allows you to have namespaced models in fixjour | |
module Fixjour | |
class Builder | |
def name | |
@name ||= (@options[:as] || @klass.name.underscore).to_s.gsub("/", "_") | |
end | |
end | |
end |
This file contains hidden or 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
osascript -e "set Volume 10" && say "this will turn your volume on and say something" |
OlderNewer