Sha256: 63d020cac7f4deff121a40a6744992f95e31e21dcf4f0d95c52d82e28a272579

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 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.0 spec/kit_spec.rb
kit-1.0.1 spec/kit_spec.rb
kit-1.0.0 spec/kit_spec.rb