Sha256: 3ddcccef96d92422b2c56ac1e2c779965d77e7368209d23a7164809233f59672

Contents?: true

Size: 1.85 KB

Versions: 13

Compression:

Stored size: 1.85 KB

Contents

class Nanoc::Extra::Deployers::RsyncTest < Nanoc::TestCase
  def test_run_without_dst
    # Create deployer
    rsync = Nanoc::Extra::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::Extra::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::Extra::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::Extra::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::Extra::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::Extra::Deployers::Rsync::DEFAULT_OPTIONS
    assert_equal(
      ['echo', 'rsync', opts, 'output/', 'asdf'].flatten,
      rsync.instance_eval { @shell_cms_args },
    )
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
nanoc-4.3.7 test/extra/deployers/test_rsync.rb
nanoc-4.3.6 test/extra/deployers/test_rsync.rb
nanoc-4.3.5 test/extra/deployers/test_rsync.rb
nanoc-4.3.4 test/extra/deployers/test_rsync.rb
nanoc-4.3.3 test/extra/deployers/test_rsync.rb
nanoc-4.3.2 test/extra/deployers/test_rsync.rb
nanoc-4.3.1 test/extra/deployers/test_rsync.rb
nanoc-4.3.0 test/extra/deployers/test_rsync.rb
nanoc-4.2.4 test/extra/deployers/test_rsync.rb
nanoc-4.2.3 test/extra/deployers/test_rsync.rb
nanoc-4.2.2 test/extra/deployers/test_rsync.rb
nanoc-4.2.1 test/extra/deployers/test_rsync.rb
nanoc-4.2.0 test/extra/deployers/test_rsync.rb