Browse files

Get global predicate matchers from run_options (in example group)

instead of accessing globally from Spec::Runner (one less dependency
from Spec::Example to Spec::Runner).
  • Loading branch information...
1 parent 013fd6a commit 992ce4bbb289b429e0830a780f68dcd14b04fba7 @dchelimsky committed Dec 28, 2008
Showing with 20 additions and 7 deletions.
  1. +10 −2 TODO.txt
  2. +4 −4 lib/spec/example/example_group_methods.rb
  3. +6 −1 lib/spec/runner/options.rb
View
12 TODO.txt
@@ -1,10 +1,18 @@
+== Refactoring
+
+Refactoring for 1.2.0
+
+* eliminate dependency from Spec::Example to Spec::Runner
+** global predictate matchers should be stored in run_options
+* eliminate dependency on global options and configuration
+** the only place they should exist is in the Runner, which should manage them
+
== Future
* do SOMETHING with the website
* extract spec/story to rspec-stories (new gem)
-* remove the ruby engine adapter unless Rubinius team plans to use it
* rename top level namespace to Rspec and commands to 'rspec' and 'autorspec'
* continue to support Spec 'spec' and 'autospec' as aliases for a reasonable time
* separate the underlying framework from the DSL
* be able to do everything with classes and methods
-* tweak raise_error rdoc to show only one arg
+* tweak raise_error rdoc to show only one arg
View
8 lib/spec/example/example_group_methods.rb
@@ -123,7 +123,7 @@ def it_should_behave_like(*shared_example_groups)
# a predicate on your class. RSpec provides a couple of these
# out of the box:
#
- # exist (or state expectations)
+ # exist (for state expectations)
# File.should exist("path/to/file")
#
# an_instance_of (for mock argument constraints)
@@ -173,7 +173,7 @@ def run(run_options)
return dry_run(examples, run_options) if run_options.dry_run?
plugin_mock_framework
- define_methods_from_predicate_matchers
+ define_methods_from_predicate_matchers(run_options)
success, before_all_instance_variables = run_before_all(run_options)
success, after_all_instance_variables = execute_examples(success, before_all_instance_variables, examples, run_options)
@@ -346,9 +346,9 @@ def plugin_mock_framework
end
end
- def define_methods_from_predicate_matchers # :nodoc:
+ def define_methods_from_predicate_matchers(run_options) # :nodoc:
all_predicate_matchers = predicate_matchers.merge(
- Spec::Runner.configuration.predicate_matchers
+ run_options.predicate_matchers
)
all_predicate_matchers.each_pair do |matcher_method, method_on_object|
define_method matcher_method do |*args|
View
7 lib/spec/runner/options.rb
@@ -129,7 +129,12 @@ def examples_run?
def examples_should_not_be_run
@examples_should_be_run = false
- end
+ end
+
+ def predicate_matchers
+ # TODO - don't like this dependency - perhaps store these in here instead?
+ Spec::Runner.configuration.predicate_matchers
+ end
def colour=(colour)
@colour = colour

0 comments on commit 992ce4b

Please sign in to comment.