Sha256: cc17f1430a24c1f04919f337c84ce7e588454a244e7456edf2503aed6bb25304

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

require 'test_helper'

class PersonTest < ActiveSupport::TestCase
  
  background do
    test_helper_returning_one
    instance_test_helper_defined_after_background_returning_one
    @hase = Person.create(:name => "bunny")
  end

  should "without context" do
    assert @hase
    assert_nil @thies
    assert_nil @manuel
    assert_nil @norman
  end
  
  should "not create post.yml" do
    assert !File.exist?(File.dirname(__FILE__) + '/../backgrounds/person_test/posts.yml')
  end

  context "with thies" do
    background do
      test_helper_returning_one
      instance_test_helper_defined_after_background_returning_one
      @thies = Person.create(:name => "thies")
    end
    
    should "be cool" do
      assert @hase
      assert @thies
      assert_nil @manuel
      assert_nil @norman
      assert_equal 2, 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 3, 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 4, Person.count
        end
      end
    end
  
    should "nother truth" do
      assert @hase
      assert @thies
      assert_nil @manuel
      assert_nil @norman
      assert_equal 2, Person.count
    end
  end
  
  private
    def instance_test_helper_defined_after_background_returning_one
      1
    end
end

class ZZZEmptyDatabaseTest < ActiveSupport::TestCase  
  should "have a clean database" do
    assert_equal 0, Person.count
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fixture_background-0.9.7 test/rails3/test/unit/person_test.rb