summaryrefslogtreecommitdiffstats
path: root/test/lib/spec/runner/context.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-08-23 01:17:33 -0500
committerLuke Kanies <luke@madstop.com>2007-08-23 01:17:33 -0500
commitd59315a07a8a01ca65952d8e8fe9d2f1bb84d30e (patch)
tree8e2470f271c8c6e622f0aef3fd5a2f01502d8305 /test/lib/spec/runner/context.rb
parent5601ecf75d3854a66d087a108e1b06885fa2be12 (diff)
Adding the second half of the rspec upgrade -- apparently the "git add" thing I used did not remove the old files, only add the new ones.
Diffstat (limited to 'test/lib/spec/runner/context.rb')
-rw-r--r--test/lib/spec/runner/context.rb154
1 files changed, 0 insertions, 154 deletions
diff --git a/test/lib/spec/runner/context.rb b/test/lib/spec/runner/context.rb
deleted file mode 100644
index 3155e169a..000000000
--- a/test/lib/spec/runner/context.rb
+++ /dev/null
@@ -1,154 +0,0 @@
-module Spec
- module Runner
- class ContextEvalModule < Module
- end
- class Context
- module InstanceMethods
- def initialize(description, &context_block)
- @description = description
-
- @context_eval_module = ContextEvalModule.new
- @context_eval_module.extend ContextEval::ModuleMethods
- @context_eval_module.include ContextEval::InstanceMethods
- before_context_eval
- @context_eval_module.class_eval(&context_block)
- end
-
- def before_context_eval
- end
-
- def inherit_context_eval_module_from(klass)
- @context_eval_module.inherit klass
- end
- alias :inherit :inherit_context_eval_module_from
-
- def include(mod)
- @context_eval_module.include(mod)
- end
-
- def run(reporter, dry_run=false)
- reporter.add_context(@description)
- prepare_execution_context_class
- errors = run_context_setup(reporter, dry_run)
-
- specifications.each do |specification|
- specification_execution_context = execution_context(specification)
- specification_execution_context.copy_instance_variables_from(@once_only_execution_context_instance, []) unless context_setup_block.nil?
- specification.run(reporter, setup_block, teardown_block, dry_run, specification_execution_context)
- end unless errors.length > 0
-
- run_context_teardown(reporter, dry_run)
- end
-
- def number_of_specs
- specifications.length
- end
-
- def matches?(full_description)
- matcher ||= SpecMatcher.new(@description)
- specifications.each do |spec|
- return true if spec.matches?(matcher, full_description)
- end
- return false
- end
-
- def run_single_spec(full_description)
- return if @description == full_description
- matcher = SpecMatcher.new(@description)
- specifications.reject! do |spec|
- !spec.matches?(matcher, full_description)
- end
- end
-
- def methods
- my_methods = super
- my_methods |= @context_eval_module.methods
- my_methods
- end
-
- protected
-
- def method_missing(*args)
- @context_eval_module.method_missing(*args)
- end
-
- def context_setup_block
- @context_eval_module.send :context_setup_block
- end
-
- def context_teardown_block
- @context_eval_module.send :context_teardown_block
- end
-
- def specifications
- @context_eval_module.send :specifications
- end
-
- def setup_block
- @context_eval_module.send :setup_block
- end
-
- def teardown_block
- @context_eval_module.send :teardown_block
- end
-
- def prepare_execution_context_class
- weave_in_context_modules
- execution_context_class
- end
-
- def weave_in_context_modules
- mods = context_modules
- context_eval_module = @context_eval_module
- execution_context_class.class_eval do
- include context_eval_module
- mods.each do |mod|
- include mod
- end
- end
- end
-
- def context_modules
- @context_eval_module.send :context_modules
- end
-
- def execution_context_class
- @context_eval_module.send :execution_context_class
- end
-
- def execution_context specification
- execution_context_class.new(specification)
- end
-
- def run_context_setup(reporter, dry_run)
- errors = []
- unless dry_run
- begin
- @once_only_execution_context_instance = execution_context(nil)
- @once_only_execution_context_instance.instance_eval(&context_setup_block)
- rescue => e
- errors << e
- location = "context_setup"
- reporter.spec_finished(location, e, location) if reporter
- end
- end
- errors
- end
-
- def run_context_teardown(reporter, dry_run)
- unless dry_run
- begin
- @once_only_execution_context_instance ||= execution_context(nil)
- @once_only_execution_context_instance.instance_eval(&context_teardown_block)
- rescue => e
- location = "context_teardown"
- reporter.spec_finished(location, e, location) if reporter
- end
- end
- end
-
- end
- include InstanceMethods
- end
- end
-end