Sha256: ee3afde7faa6161646726962b8ab821d535148b08ee28591a3ad79f5ddf7d4b3

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

== Fixture Backgrounds

Generate fixtures from factories _in_ you testcode to speedup test-runs!

Requires shoulda 2.11.3 (exact version for now - sorry)

thies@tmp8.de 20110207


== Usage

in test_helper.rb:

  class ActiveSupport::TestCase
    include ::FixtureBackground::ActiveSupport::TestCase
  end


in some_test.rb:

  require 'test_helper'

  class TestTest < ActiveSupport::TestCase
    background do
      @hase = Hase.create(:name => "bunny")
    end

    context "with thies" do
      background do
        @thies = Person.create(:name => "thies")
      end
    
      should "be cool" do
        assert @hase
        assert @thies
        assert_nil @manuel
        assert_nil @norman
        assert_equal 1, Person.count
      end

      context "with manuel" do
        background do
          @manuel = Person.create(:name => "manuel")
        end
    
        should "be cool" do
          assert @hase
          assert @thies
          assert @manuel
          assert_nil @norman
          assert_equal 2, Person.count
        end
      
        context "with norman" do
          background do
            @norman = Person.create(:name => "norman")
          end
      
          should "be cool" do
            assert @hase
            assert @thies
            assert @manuel
            assert @norman
            assert_equal 3, Person.count
          end
        end
      end

      should "nother truth" do
        assert @hase
        assert @thies
        assert_nil @manuel
        assert_nil @norman
        assert_equal 1, Person.count
      end
    end
  end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fixture_background-0.9.1 README.rdoc
fixture_background-0.9.0.2 README.rdoc