Sha256: 724107c4a47b29d2ab599f0866a9b23b8be37bb0b67d4c435e85d13a1cb7f69e

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Controll::Flow::EventMapper::PathFinder do
  def notice name
    Hashie::Mash.new(name: name.to_sym, type: :notice)
  end

  def error name
    Hashie::Mash.new(name: name.to_sym, type: :error)
  end

  let(:redirections) do
    { 
      :error => error_map, :notice => notice_map
    }
  end

  let(:notice_map)  do
    {:welcome =>  valid_events }
  end

  let(:valid_events) { [:hello, :hi] }
  let(:invalid_events) { [:blip, :blap] }

  let(:error_map)  do
    {bad: ['bad_payment', 'wrong_payment'] }
  end

  let(:types) { [:notice, :error] }

  context 'use' do    
    let(:clazz)       { Controll::Flow::EventMapper::PathFinder }
    let(:hello)       { notice :hello }
    let(:bad_payment) { error :bad_payment }

    describe '.action event' do
      subject { clazz.new hello, redirections, types  }

      specify do
        expect { subject.map }.to_not raise_error(Controll::Flow::NoMappingFoundError)
      end

      specify do
        subject.path.should == 'welcome'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
controll-0.3.2 spec/controll/flow/event_mapper/path_finder_spec.rb
controll-0.3.1 spec/controll/flow/event_mapper/path_finder_spec.rb
controll-0.3.0 spec/controll/flow/event_mapper/path_finder_spec.rb