Sha256: cf29144bd4e6124c3e756791b32b70dce802bebe3b3702b3f26d47f9ae928c03

Contents?: true

Size: 901 Bytes

Versions: 6

Compression:

Stored size: 901 Bytes

Contents

require 'test_helper'

class PostTest < ActiveSupport::TestCase
  test_data do
    puts "Loading test data in #{self}"
    10.times do 
      Factory.create(:post)
    end
    Factory.create(:post, :title => "Foobar")
  end

  should belong_to(:user)
  
  # 11 from test data, 2 from fixtures
  should "have 13 Posts existing" do
    assert_equal 13, Post.count
  end
  
  should "delete 5 posts" do
    5.times { assert Post.last.delete }
  end
  
  should "destroy 5 posts" do
    5.times { assert Post.last.delete }
  end
  
  should "have post with title 'Foobar'" do
    assert Post.find_by_title('Foobar')
  end
  
  should "have no post with title 'Whatever'" do
    assert !Post.find_by_title('Whatever')
  end
  
  
  context "after destroying 3 posts" do
    setup { 3.times { Post.last.destroy } }
    should "have 10 Posts remaining" do
      assert_equal 10, Post.count
    end
  end
end

Version data entries

6 entries across 3 versions & 1 rubygems

Version Path
transactionata-0.3.0 test/rails2/test/unit/post_test.rb
transactionata-0.3.0 test/rails3/test/unit/post_test.rb
transactionata-0.2.0 test/rails2/test/unit/post_test.rb
transactionata-0.2.0 test/rails3/test/unit/post_test.rb
transactionata-0.1.0 test/rails2/test/unit/post_test.rb
transactionata-0.1.0 test/rails3/test/unit/post_test.rb