diff options
| author | Luke Kanies <luke@madstop.com> | 2007-08-23 00:56:42 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-08-23 00:56:42 -0500 |
| commit | 5601ecf75d3854a66d087a108e1b06885fa2be12 (patch) | |
| tree | 28d5892bab14c9296bcd4232075f3658ee1224a0 /test/lib/spec/runner/extensions | |
| parent | 7c4d39ec09c10871d7eb234fe4392381245ff443 (diff) | |
| download | puppet-5601ecf75d3854a66d087a108e1b06885fa2be12.tar.gz puppet-5601ecf75d3854a66d087a108e1b06885fa2be12.tar.xz puppet-5601ecf75d3854a66d087a108e1b06885fa2be12.zip | |
Upgrading rspec to version 1.0.8. This only includes the contents of the lib directory, and even then only the spec-related stuff, not the autotest stuff.
Diffstat (limited to 'test/lib/spec/runner/extensions')
| -rw-r--r-- | test/lib/spec/runner/extensions/kernel.rb | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/test/lib/spec/runner/extensions/kernel.rb b/test/lib/spec/runner/extensions/kernel.rb index f060ec859..75f2c335e 100644 --- a/test/lib/spec/runner/extensions/kernel.rb +++ b/test/lib/spec/runner/extensions/kernel.rb @@ -1,17 +1,50 @@ module Kernel - def context(name, &block) - context = Spec::Runner::Context.new(name, &block) - context_runner.add_context(context) + # Creates and registers an instance of a Spec::DSL::Behaviour (or a subclass). + # The instantiated behaviour class depends on the directory of the file + # calling this method. For example, Spec::Rails will use different + # classes for specs living in <tt>spec/models</tt>, <tt>spec/helpers</tt>, + # <tt>spec/views</tt> and <tt>spec/controllers</tt>. + # + # It is also possible to override autodiscovery of the behaviour class + # with an options Hash as the last argument: + # + # describe "name", :behaviour_type => :something_special do ... + # + # The reason for using different behaviour classes is to have + # different matcher methods available from within the <tt>describe</tt> + # block. + # + # See Spec::DSL::BehaviourFactory#add_behaviour_class for details about + # how to register special Spec::DSL::Behaviour implementations. + # + def describe(*args, &block) + raise ArgumentError if args.empty? + args << {} unless Hash === args.last + args.last[:spec_path] = caller(0)[1] + register_behaviour(Spec::DSL::BehaviourFactory.create(*args, &block)) end - + alias :context :describe + + def respond_to(*names) + Spec::Matchers::RespondTo.new(*names) + end + private - def context_runner + def register_behaviour(behaviour) + if behaviour.shared? + Spec::DSL::Behaviour.add_shared_behaviour(behaviour) + else + behaviour_runner.add_behaviour(behaviour) + end + end + + def behaviour_runner # TODO: Figure out a better way to get this considered "covered" and keep this statement on multiple lines - unless $context_runner; \ - $context_runner = ::Spec::Runner::OptionParser.new.create_context_runner(ARGV.dup, STDERR, STDOUT, false); \ - at_exit { $context_runner.run(false) }; \ + unless $behaviour_runner; \ + $behaviour_runner = ::Spec::Runner::OptionParser.new.create_behaviour_runner(ARGV.dup, STDERR, STDOUT, false); \ + at_exit { $behaviour_runner.run(nil, false) }; \ end - $context_runner + $behaviour_runner end end |
