[rspec-devel] [ rspec-Feature Requests-9983 ] Allow before_setup and after_teardown to be called in BehaviourEval

noreply at rubyforge.org noreply at rubyforge.org
Mon Apr 9 06:59:38 EDT 2007


Feature Requests item #9983, was opened at 2007-04-09 06:29
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=9983&group_id=797

Category: None
Group: None
Status: Open
Priority: 3
Submitted By: Brian Takita (btakita)
Assigned to: Nobody (None)
Summary: Allow before_setup and after_teardown to be called in BehaviourEval

Initial Comment:
This would provide a hook for cross cutting.

For example:
Somebody wants to have setup and/or teardown functionality in a select few Examples. One may want to create a module and define the included method.

module Foobar
  def self.included(mod)
    mod.before_setup do
      puts 'my special setup hook'
    end
  end
end

describe MyObject
  include Foobar
end

----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-04-09 10:59

Message:
Right now you can do the following - would it suffice?
# in a central location like spec_helper.rb
module SpecialSetups
  def stuff_to_do_first
    ...
  end
end

Spec::Runner.configure do |config|
  config.include SpecialSetups
end

# in a spec file
describe SomeObject do
  setup do
    stuff_to_do_first
    # other stuff
  end
  ...
end

This makes things a bit more transparent in the specs and is not really any more verbose if you've got a setup anyhow.

WDYT?

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=9983&group_id=797


More information about the rspec-devel mailing list