Sha256: b2252d000b045d59b8aaa062ce7029d9848dcf8d34da6f1cfc4816f06bd78632

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require 'test/unit'
require 'rubygems'
require 'reactor'
require 'helpers'
require 'dummy_parser'


# Test case for the <tt>ChainReactor::Reaction</tt> class.
class TestReaction < Test::Unit::TestCase
  include ChainReactor::TestHelpers
  
  def test_block_is_executed
    block = Proc.new { |d| raise 'Block has been called' }
    reaction = ChainReactor::Reaction.new({:parser => :dummy}, block, get_logger)

    assert_raise ChainReactor::ReactionError, 'Block has been called' do
      reaction.execute('')
    end
  end

  def test_execute_sets_previous_result
    block = Proc.new { |d| 'Block has been called' }
    reaction = ChainReactor::Reaction.new({:parser => :dummy}, block, get_logger)
    reaction.execute('')

    assert_equal 'Block has been called', reaction.previous_result
  end
  
  def test_execute_sets_previous_data
    
    block = Proc.new { |d| 'Block has been called' }
    reaction = ChainReactor::Reaction.new({:parser => :json}, block, get_logger)
    data_string = '{"hello" : "world"}'
    data = {:hello => 'world'}
    reaction.execute(data_string)

    assert_equal data, reaction.previous_data
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chain-reactor-0.2.2 test/test_reaction.rb
chain-reactor-0.2.1 test/test_reaction.rb
chain-reactor-0.2.0 test/test_reaction.rb