Sha256: 90fd169d4e4586ad6801c4558c54e3b1110e65f23261f6582a769a0bcb9e671a

Contents?: true

Size: 1.45 KB

Versions: 22

Compression:

Stored size: 1.45 KB

Contents

require 'rails_helper'

module Kuroko2::Workflow::Task
  describe Env do
    describe '#execute' do
      let(:token) { build(:token, script: 'env:', context: { 'ENV' => { 'EXISTING' => 'true' } }) }

      context 'with valid syntax' do
        before { Env.new(node, token).execute }
        subject { token.context }

        context 'with nil option' do
          let(:node) { Kuroko2::Workflow::Node.new(:env) }

          context 'with exisiting env' do
            it { is_expected.to eq({ 'ENV' => { 'EXISTING' => 'true' } }) }
          end

          context 'without exisiting env' do
            let(:token) { build(:token, script: 'env:') }

            it { is_expected.to eq({}) }
          end
        end

        context 'with valid option' do
          let(:node) { Kuroko2::Workflow::Node.new(:env, 'A=1 B=2') }

          it { is_expected.to eq({ 'ENV' => { 'A' => '1', 'B' => '2', 'EXISTING' => 'true' } }) }
        end

        context 'with quote' do
          let(:node) { Kuroko2::Workflow::Node.new(:env, 'A="B=2 C=3"  D="E=5 F=\"6"' " G='\\'7'") }

          it { is_expected.to eq({ 'ENV' => { 'A' => 'B=2 C=3', 'D' => 'E=5 F="6', 'G' => "'7", 'EXISTING' => 'true' } }) }
        end
      end

      context 'with invalid syntax' do
        let(:node) { Kuroko2::Workflow::Node.new(:env, 'A="B=2 C=3" D="E=5 F=\"6') }

        it { expect { Env.new(node, token).execute }.to raise_error(Kuroko2::Workflow::AssertionError) }
      end
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
kuroko2-0.8.0 spec/workflow/task/env_spec.rb
kuroko2-0.7.0 spec/workflow/task/env_spec.rb
kuroko2-0.6.0 spec/workflow/task/env_spec.rb
kuroko2-0.5.2 spec/workflow/task/env_spec.rb
kuroko2-0.5.1 spec/workflow/task/env_spec.rb
kuroko2-0.5.0 spec/workflow/task/env_spec.rb
kuroko2-0.4.6 spec/workflow/task/env_spec.rb
kuroko2-0.4.5 spec/workflow/task/env_spec.rb
kuroko2-0.4.4 spec/workflow/task/env_spec.rb
kuroko2-0.4.3 spec/workflow/task/env_spec.rb
kuroko2-0.4.2 spec/workflow/task/env_spec.rb
kuroko2-0.4.1 spec/workflow/task/env_spec.rb
kuroko2-0.4.0 spec/workflow/task/env_spec.rb
kuroko2-0.3.4 spec/workflow/task/env_spec.rb
kuroko2-0.3.3 spec/workflow/task/env_spec.rb
kuroko2-0.3.2 spec/workflow/task/env_spec.rb
kuroko2-0.3.1 spec/workflow/task/env_spec.rb
kuroko2-0.3.0 spec/workflow/task/env_spec.rb
kuroko2-0.2.3 spec/workflow/task/env_spec.rb
kuroko2-0.2.2 spec/workflow/task/env_spec.rb