Sha256: e3cfe12e82e29af959af186fa123ec0b45c690bdf719528e5d9a023796690bd1

Contents?: true

Size: 1.89 KB

Versions: 22

Compression:

Stored size: 1.89 KB

Contents

require 'helper'

class Nanoc::Deploying::Deployers::RsyncTest < Nanoc::TestCase
  def test_run_without_dst
    # Create deployer
    rsync = Nanoc::Deploying::Deployers::Rsync.new(
      'output/',
      {},
    )

    # Mock run_shell_cmd
    def rsync.run_shell_cmd(args)
      @shell_cms_args = args
    end

    # Try running
    error = assert_raises(RuntimeError) do
      rsync.run
    end

    # Check error message
    assert_equal 'No dst found in deployment configuration', error.message
  end

  def test_run_with_erroneous_dst
    # Create deployer
    rsync = Nanoc::Deploying::Deployers::Rsync.new(
      'output/',
      dst: 'asdf/',
    )

    # Mock run_shell_cmd
    def rsync.run_shell_cmd(args)
      @shell_cms_args = args
    end

    # Try running
    error = assert_raises(RuntimeError) do
      rsync.run
    end

    # Check error message
    assert_equal 'dst requires no trailing slash', error.message
  end

  def test_run_everything_okay
    # Create deployer
    rsync = Nanoc::Deploying::Deployers::Rsync.new(
      'output',
      dst: 'asdf',
    )

    # Mock run_shell_cmd
    def rsync.run_shell_cmd(args)
      @shell_cms_args = args
    end

    # Run
    rsync.run

    # Check args
    opts = Nanoc::Deploying::Deployers::Rsync::DEFAULT_OPTIONS
    assert_equal(
      ['rsync', opts, 'output/', 'asdf'].flatten,
      rsync.instance_eval { @shell_cms_args },
    )
  end

  def test_run_everything_okay_dry
    # Create deployer
    rsync = Nanoc::Deploying::Deployers::Rsync.new(
      'output',
      { dst: 'asdf' },
      dry_run: true,
    )

    # Mock run_shell_cmd
    def rsync.run_shell_cmd(args)
      @shell_cms_args = args
    end

    # Run
    rsync.run

    # Check args
    opts = Nanoc::Deploying::Deployers::Rsync::DEFAULT_OPTIONS
    assert_equal(
      ['echo', 'rsync', opts, 'output/', 'asdf'].flatten,
      rsync.instance_eval { @shell_cms_args },
    )
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
nanoc-4.7.9 test/deploying/test_rsync.rb
nanoc-4.7.8 test/deploying/test_rsync.rb
nanoc-4.7.7 test/deploying/test_rsync.rb
nanoc-4.7.6 test/deploying/test_rsync.rb
nanoc-4.7.5 test/deploying/test_rsync.rb
nanoc-4.7.4 test/deploying/test_rsync.rb
nanoc-4.7.3 test/deploying/test_rsync.rb
nanoc-4.7.2 test/deploying/test_rsync.rb
nanoc-4.7.1 test/deploying/test_rsync.rb
nanoc-4.7.0 test/deploying/test_rsync.rb
nanoc-4.6.4 test/deploying/test_rsync.rb
nanoc-4.6.3 test/deploying/test_rsync.rb
nanoc-4.6.2 test/deploying/test_rsync.rb
nanoc-4.6.1 test/deploying/test_rsync.rb
nanoc-4.6.0 test/deploying/test_rsync.rb
nanoc-4.5.4 test/deploying/test_rsync.rb
nanoc-4.5.3 test/deploying/test_rsync.rb
nanoc-4.5.2 test/deploying/test_rsync.rb
nanoc-4.5.1 test/deploying/test_rsync.rb
nanoc-4.5.0 test/deploying/test_rsync.rb