No commit activity in last 3 years
No release in over 3 years
Test speedup by reusing the setup of a test context
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Test speedup by reusing the setup of a test context

Install

gem install shoulda-reuse_setup

# Gemfile
gem "shoulda-reuse_setup", :require => "shoulda/reuse_setup"

Usage

context "reuse" do
  context "a" do
    reuse_setup do
      $foo ||= 0
      $foo += 1
      @foo = $foo
    end

    should "1 preserve instance state" do
      assert_equal 1, @foo
    end

    should "2 only run setup once" do
      assert_equal 1, $foo
    end

    should "3 preserve instance state" do
      assert_equal 1, @foo
    end

    # nesting does not work!
    # context "nested" do
    #  reuse_setup { ...  }
    # end
  end
end

Author

Michael Grosser
michael@grosser.it
License: MIT
Build Status