Sha256: ebe11afff805f887180f85dbdc22ea622751b3d55f7a1a469a508cb99a4d157d

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

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

describe Merb::Generators::MigrationGenerator do
  
  before do
    @generator = Merb::Generators::MigrationGenerator.new('/tmp', {}, 'SomeMoreStuff')
  end
  
  describe '#file_name' do
  
    it "should convert the name to snake case and prepend the version number" do
      @generator.name = 'SomeMoreStuff'
      @generator.file_name.should == '001_some_more_stuff'
    end
  
  end

  describe '#class_name' do
  
    it "should convert the name to camel case" do
      @generator.name = 'some_more_stuff'
      @generator.class_name.should == 'SomeMoreStuff'
    end
  
  end
  
  describe '#version' do
    it "should find the current migration version and increase it by one" do
      @previous_migration_files = [
        "/tmp/schema/migrations/001_monkey.rb",
        "/tmp/schema/migrations/002_blah.rb",
        "/tmp/schema/migrations/005_gurr_blah.rb",
        "/tmp/schema/migrations/006_garr.rb"
      ]
      Dir.should_receive(:[]).with('/tmp/schema/migrations/*').and_return(@previous_migration_files)
      
      @generator.version.should == "007"
    end
    
    it "should be 1 if there are no previous migrations" do
      Dir.should_receive(:[]).with('/tmp/schema/migrations/*').and_return([])
      
      @generator.version.should == "001"
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thorero-gen-0.9.4 spec/migration_spec.rb