Sha256: 1cb1f50b4a0e0aa1bcdc3825f9e21d45cc9b1de25e4c204f4ee8056fe9eea4d2

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 KB

Contents

if RUBY_PLATFORM != 'opal'
  class TestTask < Volt::TaskHandler
    def allowed_method(arg1)
      return 'yes' + arg1
    end
  end


  describe Volt::Dispatcher do

    it 'should only allow method calls on TaskHandler or above in the inheritance chain' do
      channel = double('channel')

      expect(channel).to receive(:send_message).with('response', 0, 'yes works', nil)

      Volt::Dispatcher.new.dispatch(channel, [0, 'TestTask', :allowed_method, {}, ' works'])
    end

    it 'should not allow eval' do
      channel = double('channel')

      expect(channel).to receive(:send_message).with('response', 0, nil, RuntimeError.new('unsafe method: eval'))

      Volt::Dispatcher.new.dispatch(channel, [0, 'TestTask', :eval, '5 + 10'])
    end

    it 'should not allow instance_eval' do
      channel = double('channel')

      expect(channel).to receive(:send_message).with('response', 0, nil, RuntimeError.new('unsafe method: instance_eval'))

      Volt::Dispatcher.new.dispatch(channel, [0, 'TestTask', :instance_eval, '5 + 10'])
    end

    it 'should not allow #methods' do
      channel = double('channel')

      expect(channel).to receive(:send_message).with('response', 0, nil, RuntimeError.new('unsafe method: methods'))

      Volt::Dispatcher.new.dispatch(channel, [0, 'TestTask', :methods])
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
volt-0.8.27.beta2 spec/tasks/dispatcher_spec.rb
volt-0.8.27.beta1 spec/tasks/dispatcher_spec.rb
volt-0.8.26.beta1 spec/tasks/dispatcher_spec.rb
volt-0.8.26 spec/tasks/dispatcher_spec.rb
volt-0.8.24 spec/tasks/dispatcher_spec.rb
volt-0.8.23 spec/tasks/dispatcher_spec.rb
volt-0.8.22 spec/tasks/dispatcher_spec.rb
volt-0.8.22.beta2 spec/tasks/dispatcher_spec.rb
volt-0.8.22.beta1 spec/tasks/dispatcher_spec.rb
volt-0.8.21 spec/tasks/dispatcher_spec.rb
volt-0.8.20 spec/tasks/dispatcher_spec.rb
volt-0.8.19 spec/tasks/dispatcher_spec.rb