Sha256: 00a5dd8cda9bf8f89bb838d942c3f1466d5bb8f31bbf42ccce18efea5faa92ce

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 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

test_helper.rb:

require 'fixture_background'

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


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

1 entries across 1 versions & 1 rubygems

Version Path
fixture_background-0.9 README.rdoc