Sha256: 6a19f3e9e59823ae893d8eae770545638c8f97d1b6521d3bba2bfb691b912f5f

Contents?: true

Size: 636 Bytes

Versions: 4

Compression:

Stored size: 636 Bytes

Contents

require 'helper'

class FilterWithDispatcherMixin
  include Temple::Mixins::Dispatcher

  def on_test(arg)
    [:on_test, arg]
  end

  def on_second_test(arg)
    [:on_second_test, arg]
  end
end

describe Temple::Mixins::Dispatcher do
  before do
    @filter = FilterWithDispatcherMixin.new
  end

  it 'should return unhandled expressions' do
    @filter.call([:unhandled]).should.equal [:unhandled]
  end

  it 'should dispatch first level' do
    @filter.call([:test, 42]).should.equal [:on_test, 42]
  end

  it 'should dispatch second level' do
    @filter.call([:second, :test, 42]).should.equal [:on_second_test, 42]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
temple-0.3.4 test/mixins/test_dispatcher.rb
temple-0.3.2 test/mixins/test_dispatcher.rb
temple-0.3.1 test/mixins/test_dispatcher.rb
temple-0.3.0 test/mixins/test_dispatcher.rb