Sha256: 90945edfc5462b9d927c04be42ccbd4fc2cfa80e85453cc4283dedf5f3b4a7ac

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

require 'kit'

describe Kit do

  before :all do
    @kit_path = File.expand_path '../../test_kit', __FILE__
    @config_file = File.expand_path '../../test_kit/config.yml', __FILE__
    @config = YAML.load File.read("#{@kit_path}/config.yml")
  end

  subject { Kit.new @config_file }

  describe ".path" do

    it "determines the correct path to the kit" do
      subject.path.should == @kit_path
    end
  end

  describe ".config" do

    it "loads the config file" do
      subject.config.should == @config
    end
  end

  describe ".open" do

    it "creates a new kit and opens a database connections" do
      Kit.any_instance.should_receive(:db_connect)
      Kit.open @config_file
    end
  end

  db_actions              = {}
  db_actions[:destroy]    = [Hash.new]
  db_actions[:create]     = [Hash.new]
  db_actions[:migrate]    = [String.new, Hash.new, 0]
  db_actions[:migrate_to] = [String.new, 0]

  db_actions.each do |action, args|

    describe ".db_#{action}" do

      it "calls KitDBSupport::#{action}" do
        KitDBSupport.should_receive(action).with( *( args.map { |x| kind_of(x.class) } ) )
        subject.send "db_#{action}", *args[1..-1]
      end

      it "returns the instance of Kit" do
        KitDBSupport.stub action
        subject.send("db_#{action}", *args[1..-1]).should equal subject
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kit-1.1.4 spec/kit_spec.rb
kit-1.1.2 spec/kit_spec.rb
kit-1.1.1 spec/kit_spec.rb