Sha256: e8c4302468a104d6b7dd17e7d5d76a973134f13c217583c6bd5dc2222de4321f

Contents?: true

Size: 1013 Bytes

Versions: 1

Compression:

Stored size: 1013 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe MockedFixtures::MockFixtures do
  
  before(:all) do
    # just making sure we don't hit the database at all
    ActiveRecord::Base.connection.disconnect! rescue nil
  end
  
  before(:each) do
    @fixture_path = Test::Unit::TestCase.fixture_path
  end  

  it "should return primary key for fixture table" do
    fixtures = MockedFixtures::MockFixtures.create_fixtures(@fixture_path, [:companies])
    fixtures[0].primary_key_name.should == 'cid'
  end  
  
  it "should create fixtures" do
    fixtures = MockedFixtures::MockFixtures.create_fixtures(@fixture_path, [:companies])
    fixtures.should have(1).instance_of(Fixture)
    fixtures.first['mega_corp'][:name].should == 'Mega Corporation'
  end

  it "should create fixtures with association values inserted" do
    fixtures = MockedFixtures::MockFixtures.create_fixtures(@fixture_path, [:employees])
    fixtures.first['adam'][:company_id].should == Fixtures.identify('mega_corp')
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mocked_fixtures-0.1.0 spec/mock_fixtures_spec.rb