Sha256: 6bac97359efe74ea64e96f797d934b2a31a18bbffa52f6a728c0eb6f10071593

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require "test_helper"

class TestYads < MiniTest::Unit::TestCase

  def setup
    @log_file = File.open("/dev/null", "w")
  end

  def test_try_loading_not_found_config_file_on_setup
    assert_raises(Yads::ConfigNotFound) do
      Dir.chdir("/tmp") do
        deployer = Yads::Deployer.new(@log_file)
        deployer.setup
      end
    end
  end

  def test_try_loading_not_found_config_file_on_deploy
    assert_raises(Yads::ConfigNotFound) do
      Dir.chdir("/tmp") do
        deployer = Yads::Deployer.new(@log_file)
        deployer.deploy
      end
    end
  end

  def test_setup
    inside_project_root do
      ssh = mock
      ssh.expects(:execute).with("mkdir -p /tmp/yads && cd /tmp/yads && git clone --depth 1 git@repohost.com:myrepo.git .")
      Yads::SSH.expects(:new).with(:host => "rafaelss.com", :user => "deploy", :forward_agent => true).returns(ssh)

      deployer = Yads::Deployer.new(@log_file)
      deployer.setup
    end
  end

  def test_deploy
    inside_project_root do
      ssh = mock
      ssh.expects(:execute).with("cd /tmp/yads && rake db:migrate && touch test")
      Yads::SSH.expects(:new).with(:host => "rafaelss.com", :user => "deploy", :forward_agent => true).returns(ssh)

      deployer = Yads::Deployer.new(@log_file)
      deployer.deploy
    end
  end

  private

    def inside_project_root(&block)
      Dir.chdir(File.expand_path("../../fixtures", __FILE__), &block)
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yads-0.1.1 test/yads/test_deployer.rb
yads-0.1.0 test/yads/test_deployer.rb