tracks/vendor/plugins/rspec/lib/spec/runner/heckle_runner.rb
Luke Melia 35ae5fc431 Next step in upgrading Tracks to Rails 2.2. Some highlights:
* Ran rake rails:update
* Added old actionwebservice framework
* Updated RSpec and RSpec-Rails
* Removed asset_packager plugin (not compatible, Scott no longer maintaining), and replaced with bundle_fu. See the bundle_fu README for more info.
* Hacks to UJS and ARTS plugins, which are no longer supported. Probably should move off both UJS and RJS.
* Hack to flashobject_helper plugin (upgrade to Rails 2.2-compatible version if/when it comes out.)
* Hack to skinny-spec plugin, for Rails 2.2 compatibility. Should check for official release.
* Hacks to resource_feeder plugin, for Rails 2.2 compatibility. Should check for official release (not likely) or move off it.
* Addressed some deprecation warnings. More to come.
* My mobile mime type hackery is no longer necessary with new Rails features. Yay!
* Updated environment.rb.tmpl with changes

TODO:
* Restore view specs marked pending
* Fix failing integration tests.
* Try selenium tests.
* Investigate OpenID support.
* Address deprecation warnings.
* Consider moving parts of environment.rb to initializers
* Address annoying config.gem warning about highline gem
2008-11-30 00:34:15 -05:00

72 lines
2.1 KiB
Ruby

begin
require 'rubygems'
require 'heckle'
rescue LoadError ; raise "You must gem install heckle to use --heckle" ; end
module Spec
module Runner
# Creates a new Heckler configured to heckle all methods in the classes
# whose name matches +filter+
class HeckleRunner
def initialize(filter, heckle_class=Heckler)
@filter = filter
@heckle_class = heckle_class
end
# Runs all the example groups held by +rspec_options+ once for each of the
# methods in the matched classes.
def heckle_with
if @filter =~ /(.*)[#\.](.*)/
heckle_method($1, $2)
else
heckle_class_or_module(@filter)
end
end
def heckle_method(class_name, method_name)
verify_constant(class_name)
heckle = @heckle_class.new(class_name, method_name, Spec::Runner.options)
heckle.validate
end
def heckle_class_or_module(class_or_module_name)
verify_constant(class_or_module_name)
pattern = /^#{class_or_module_name}/
classes = []
ObjectSpace.each_object(Class) do |klass|
classes << klass if klass.name =~ pattern
end
classes.each do |klass|
klass.instance_methods(false).each do |method_name|
heckle = @heckle_class.new(klass.name, method_name, Spec::Runner.options)
heckle.validate
end
end
end
def verify_constant(name)
begin
# This is defined in Heckle
name.to_class
rescue
raise "Heckling failed - \"#{name}\" is not a known class or module"
end
end
end
#Supports Heckle 1.2 and prior (earlier versions used Heckle::Base)
class Heckler < (Heckle.const_defined?(:Base) ? Heckle::Base : Heckle)
def initialize(klass_name, method_name, rspec_options)
super(klass_name, method_name)
@rspec_options = rspec_options
end
def tests_pass?
success = @rspec_options.run_examples
success
end
end
end
end