Sha256: 62485489c2a12296771c6e5a285cf45ef23a37cfc7e8156d6e516a42b8829ae2

Contents?: true

Size: 1.4 KB

Versions: 10

Compression:

Stored size: 1.4 KB

Contents

require File.dirname(__FILE__) + '/test_helper'
require 'fileutils'

# TODO Test limit params
# TODO Test renaming
# TODO Examine contents of fixture and skeleton dump
class ArFixturesTest < Test::Unit::TestCase
  fixtures :beers, :drunkards, :beers_drunkards
  include FileUtils

  def setup
    %w(db test/fixtures).each { |dir| mkdir_p File.join(RAILS_ROOT, dir) }
  end
  
  def test_dump_to_file
    Beer.dump_to_file
    assert File.exist?(File.join(RAILS_ROOT, 'db', 'beers.yml'))
    
    Beer.destroy_all
    assert_equal 0, Beer.count
    Beer.load_from_file
    assert_equal 2, Beer.count
  end

  def test_load_from_file
    cp  File.join(RAILS_ROOT, 'fixtures', 'glasses.yml'), 
        File.join(RAILS_ROOT, 'db', 'glasses.yml')
    assert_equal 0, Glass.count
    Glass.load_from_file
    assert_equal 2, Glass.count
  end

  def test_to_fixture
    Beer.to_fixture
    assert File.exist?(File.join(RAILS_ROOT, 'test', 'fixtures', 'beers.yml'))
    assert File.exist?(File.join(RAILS_ROOT, 'test', 'fixtures', 'beers_drunkards.yml'))
  end
  
  def test_habtm_to_fixture
    Beer.habtm_to_fixture
    assert File.exist?(File.join(RAILS_ROOT, 'test', 'fixtures', 'beers_drunkards.yml'))
  end
  
  def test_to_skeleton
    Beer.to_skeleton
    assert File.exist?(File.join(RAILS_ROOT, 'test', 'fixtures', 'beers.yml'))
  end

  def teardown
    %w(db test).each { |dir| rm_rf File.join(RAILS_ROOT, dir) }    
  end
  
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
ar_fixtures-0.0.4 test/ar_fixtures_test.rb
sugoi-mail-0.1.5 vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb
sugoi-mail-0.0.2 vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb
sugoi-mail-0.1.0 vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb
sugoi-mail-0.0.0 vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb
sugoi-mail-0.0.3 vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb
sugoi-mail-0.0.1 vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb
sugoi-mail-0.0.5 vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb
sugoi-mail-0.3.0 vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb
sugoi-mail-0.3.2 vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb