tracks/vendor/plugins/rspec/lib/spec/example/example_methods.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

106 lines
2.7 KiB
Ruby

module Spec
module Example
module ExampleMethods
extend ExampleGroupMethods
extend ModuleReopeningFix
include ModuleInclusionWarnings
def execute(options, instance_variables)
options.reporter.example_started(self)
set_instance_variables_from_hash(instance_variables)
execution_error = nil
Timeout.timeout(options.timeout) do
begin
before_example
eval_block
rescue Exception => e
execution_error ||= e
end
begin
after_example
rescue Exception => e
execution_error ||= e
end
end
options.reporter.example_finished(self, execution_error)
success = execution_error.nil? || ExamplePendingError === execution_error
end
def instance_variable_hash
instance_variables.inject({}) do |variable_hash, variable_name|
variable_hash[variable_name] = instance_variable_get(variable_name)
variable_hash
end
end
def violated(message="")
raise Spec::Expectations::ExpectationNotMetError.new(message)
end
def eval_each_fail_fast(procs) #:nodoc:
procs.each do |proc|
instance_eval(&proc)
end
end
def eval_each_fail_slow(procs) #:nodoc:
first_exception = nil
procs.each do |proc|
begin
instance_eval(&proc)
rescue Exception => e
first_exception ||= e
end
end
raise first_exception if first_exception
end
def description
@_defined_description || ::Spec::Matchers.generated_description || "NO NAME"
end
def options
@_options
end
def __full_description
"#{self.class.description} #{self.description}"
end
def set_instance_variables_from_hash(ivars)
ivars.each do |variable_name, value|
# Ruby 1.9 requires variable.to_s on the next line
unless ['@_implementation', '@_defined_description', '@_matcher_description', '@method_name'].include?(variable_name.to_s)
instance_variable_set variable_name, value
end
end
end
def eval_block
instance_eval(&@_implementation)
end
def implementation_backtrace
eval("caller", @_implementation)
end
protected
include Matchers
include Pending
def before_example
setup_mocks_for_rspec
self.class.run_before_each(self)
end
def after_example
self.class.run_after_each(self)
verify_mocks_for_rspec
ensure
teardown_mocks_for_rspec
end
end
end
end