Sha256: 081b5b0874ffd071cc4961f47badd2cec0a1d6678030d14f2eaa641d2f69e633

Contents?: true

Size: 723 Bytes

Versions: 7

Compression:

Stored size: 723 Bytes

Contents

require "spec_helper"

describe ErpRules::RulesEngine::Ruleby::Engine do

  before(:each) do

    RuleBook = Class.new(Ruleby::Rulebook) do
      def rules
        rule :last_name_is_smith, {:priority => 1},[ErpRules::RulesEngine::Context, :context, m.customer_last_name == 'Smith'] do |v|
          v[:context].valid_offers << 2
        end
      end
    end
    @rule_context = ErpRules::RulesEngine::Context.new
  end

  it "should invoke ruleby and execute context against a rulebook" do
    @rule_context[:customer_last_name] = "Smith"
    @rule_context[:valid_offers] = []

    @context = ErpRules::RulesEngine::Ruleby::Engine.invoke(RuleBook, @rule_context)
    @context[:valid_offers].should include(2)
  end


end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
erp_rules-4.2.0 spec/lib/erp_rules/rules_engine/ruleby/engine_spec.rb
erp_rules-4.0.0 spec/lib/erp_rules/rules_engine/ruleby/engine_spec.rb
erp_rules-3.1.0 spec/lib/erp_rules/rules_engine/ruleby/engine_spec.rb
erp_rules-3.0.4 spec/lib/erp_rules/rules_engine/ruleby/engine_spec.rb
erp_rules-3.0.3 spec/lib/erp_rules/rules_engine/ruleby/engine_spec.rb
erp_rules-3.0.2 spec/lib/erp_rules/rules_engine/ruleby/engine_spec.rb
erp_rules-3.0.1 spec/lib/erp_rules/rules_engine/ruleby/engine_spec.rb