Sha256: 04db76118b7536325fcdc8fad0654dd8be30886ef5989673dc98577ebfbd0271

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

describe Mina::Helpers::Internal do
  class DummyInternalHelper
    include Mina::DSL
    include Mina::Helpers::Internal
  end

  let(:helper) { DummyInternalHelper.new }

  describe '#deploy_script' do
    before do
      Mina::Configuration.instance.set(:deploy_script, Mina.root_path('data/deploy.sh.erb'))
      Mina::Configuration.instance.set(:version_scheme, :sequence)
    end

    it 'returns whole script' do
      expect(helper.deploy_script {}).to_not be_empty
    end
  end

  describe '#erb' do
    before { Mina::Configuration.instance.set(:version_scheme, :sequence) }
    after { Mina::Configuration.instance.remove(:version_scheme) }

    it 'returns whole script' do
      expect(helper.erb('data/deploy.sh.erb')).to_not be_empty
    end
  end

  describe '#echo_cmd' do
    context 'when not verbose' do
      it 'reuturns unedited code' do
        expect(helper.echo_cmd('ls -al')).to eq('ls -al')
      end
    end

    context 'when verbose' do
      before { Mina::Configuration.instance.set(:verbose, true) }
      after { Mina::Configuration.instance.remove(:verbose) }

      it 'modifies code' do
        expect(helper.echo_cmd('ls -al')).to eq("echo \\$\\ ls\\ -al &&\nls -al")
      end

      it 'does not modify code if ignore_verbose is true' do
        expect(helper.echo_cmd('ls -al', ignore_verbose: true)).to eq('ls -al')
      end
    end
  end

  describe '#indent' do
    it 'indents code' do
      expect(helper.indent(4, 'ls -al')).to eq('    ls -al')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mina-1.2.4 spec/lib/mina/helpers/internal_spec.rb