Sha256: 3200e619e156e55c087057f24ff251e6de272ca27396201f7d5df8b1cb878ffa

Contents?: true

Size: 1.41 KB

Versions: 22

Compression:

Stored size: 1.41 KB

Contents

require 'rails_helper'

module Kuroko2::Workflow::Task
  describe ExpectedTime do
    describe '#execute' do
      let(:node) { Kuroko2::Workflow::Node.new('expected_time', '100') }
      let(:token) { build(:token, context: {}) }

      subject { ExpectedTime.new(node, token).execute }

      it "sets EXPECTED_TIME context" do
        subject
        expect(token.context).to eq({ 'EXPECTED_TIME' => 100 })
      end

      context 'With %d+h type' do
        let(:node) { Kuroko2::Workflow::Node.new('expected_time', '10h') }

        it "sets EXPECTED_TIME context" do
          subject
          expect(token.context).to eq({ 'EXPECTED_TIME' => 10*60 })
        end
      end

      context 'With %d+m type' do
        let(:node) { Kuroko2::Workflow::Node.new('expected_time', '10m') }

        it "sets EXPECTED_TIME context" do
          subject
          expect(token.context).to eq({ 'EXPECTED_TIME' => 10 })
        end
      end

      context 'Without options' do
        let(:node) { Kuroko2::Workflow::Node.new('expected_time') }

        it "does not sets EXPECTED_TIME context" do
          subject
          expect(token.context).to eq({})
        end
      end

      context 'With non integer value' do
        let(:node) { Kuroko2::Workflow::Node.new('expected_time', 'abc') }

        it "raises error" do
          expect { subject }.to raise_error(Kuroko2::Workflow::AssertionError)
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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