Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Test speedup by reusing the setup of a test context
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
gemfiles
lib/shoulda
test
.travis.yml
Appraisals
Gemfile
Gemfile.lock
Rakefile
Readme.md
gem-public_cert.pem
shoulda-reuse_setup.gemspec

Readme.md

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

Something went wrong with that request. Please try again.