Skip to content

Instantly share code, notes, and snippets.

@ashmoran
ashmoran / env.rb
Created September 28, 2009 16:12
Initial attempt at implementing BeforeFeature using a the new listener API
class BeforeFeatureHooks
def initialize
@hooks = []
end
def register_hook(proc)
@hooks << proc
end
def run
class BeforeFeatureHooks
def initialize
@hooks = []
end
def register_hook(proc)
@hooks << proc
end
def run(feature)
require 'rubygems'
require "data_objects"
require "dm-core"
require "dm-types"
require "dm-validations"
require 'spec'
SQLITE_FILE = File.join(`pwd`.chomp, "test.db")
require 'rexml/document'
require 'rexml/formatters/transitive'
require 'rexml/formatters/pretty'
Spec::Matchers.define :be_equivalent_xml_to do |expected_xml|
match do |target_xml|
@expected_xml = expected_xml
formatter = REXML::Formatters::Pretty.new
formatted_target_xml, formatted_expected_xml = "", ""
class DatabaseResetter
def initialize(options)
@environment = options[:environment]
@files_to_watch = options[:files_to_watch] || "schema/migrations/**/*.rb"
end
def reset_if_required
if migrations_changed_since_last_database_reset?
reset
else
class BeforeFeatureHooks
def initialize
@hooks = []
end
def register_hook(proc)
@hooks << proc
end
def run(feature)
Spec::Matchers.define :include_all_at_least_times do |expected_elements, times|
match do |target_collection|
@elements_seen = expected_elements.inject({ }) { |hash, element| hash[element] = 0; hash }
target_collection.each do |element|
@elements_seen[element] += 1 if @elements_seen.has_key?(element)
end
@elements_seen.values.all? { |count| count >= times.to_i }
end
#!/Users/ashleymoran/.rvm/rubies/ruby-1.9.1-head/bin/ruby
ENV['GEM_HOME']=ENV['GEM_HOME'] || '/Users/ashleymoran/.rvm/gems/ruby-1.9.1-head'
ENV['GEM_PATH']=ENV['GEM_PATH'] || '/Users/ashleymoran/.rvm/gems/ruby-1.9.1-head:/Users/ashleymoran/.rvm/gems/ruby-1.9.1-head%global'
ENV['PATH']='/Users/ashleymoran/.rvm/rubies/ruby-1.9.1-head/bin:/Users/ashleymoran/.rvm/gems/ruby-1.9.1-head/bin:' + ENV['PATH']
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
% cat rails3.gems
# rails3.gems generated gem dump file. Note that any env variable settings will be missing. Append these after using a ';' field separator
tzinfo -v0.3.16
builder -v2.1.2
memcache-client -v1.7.8
rack -v1.1.0
rack-test -v0.5.3
rack-mount -v0.4.5
abstract -v1.0.0
erubis -v2.6.5
% rvm --trace gems load rails3.gems --trace gems load rails3.gems
rvm 0.1.9 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]
+__rvm_parse_args:343> [[ -z '' ]]
+__rvm_parse_args:343> [[ ! -z '' ]]
+__rvm_parse_args:344> [[ ! -z '' ]]
+__rvm_parse_args:344> [[ ! -z '' ]]
+__rvm_parse_args:3> [[ 3 -gt 0 ]]
+__rvm_parse_args:4> rvm_token=gems