Sha256: 0d00ec9a1a682d309c4d0987b8bc03a4c068429916a95b9e7dd775d370296f06

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'minitest_helper'
require 'powertrack'
require 'multi_json'

class TestManageRules < Minitest::Test

  def test_add_then_delete_a_single_rule
    add_then_delete_a_single_rule(false)
  end

  def test_add_then_delete_a_single_rule_in_replay_mode
    add_then_delete_a_single_rule(true)
  end

  def add_then_delete_a_single_rule(replay)
    stream = new_stream(replay)

    rule = PowerTrack::Rule.new('coke')
    assert rule.valid?

    pre_existing_rules = stream.list_rules
    assert pre_existing_rules.is_a?(Array)

    assert_nil stream.add_rule(rule)

    rules_after_addition = stream.list_rules(false)
    assert rules_after_addition.is_a?(Array)
    assert_equal pre_existing_rules.size + 1, rules_after_addition.size
    assert [ rule ], rules_after_addition - pre_existing_rules

    assert_nil stream.delete_rules(rule)

    rules_after_removal = stream.list_rules
    assert rules_after_removal.is_a?(Array)
    assert_equal rules_after_addition.size - 1, rules_after_removal.size
    assert_equal [], rules_after_removal - rules_after_addition
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
powertrack-1.1.1 test/test_manage_rules.rb
powertrack-1.1.0 test/test_manage_rules.rb