[rspec-users] Stubbing out common setup

David Chelimsky dchelimsky at gmail.com
Fri Dec 24 06:11:28 EST 2010

On Wed, Dec 22, 2010 at 2:28 PM, Suman Gurung <sumangurung at gmail.com> wrote:
> I want to stub an after save method(which generates files and so, is
> time consuming), for most of my spec files apart from a few where that
> method is actually tested.
> I was trying to do this with using shared examples but with rspec 2, i
> believe before(:each) defined in the shared examples are automatically
> wrapped inside a 'context' in the host class.
> What would be a good way to include a setup like this in more than one
> spec files?
> before(:each) do
>  stub some methods
> end
> What I am trying to achieve is not to have the above code in all my
> spec files.

RSpec.configure do |config|
  config.before(:each, :type => :controller) do
    # stub some methods


More information about the rspec-users mailing list