Sha256: dbd50c52f02999aeaefd84c2d586f4eaa9e3681ea0194da48e6bd73c21345673

Contents?: true

Size: 707 Bytes

Versions: 7

Compression:

Stored size: 707 Bytes

Contents

require "spec_helper"

describe ErpRules::Extensions::ActiveRecord::HasRuleContext do

  before(:each) do
    TestClass = Class.new(ActiveRecord::Base) do 
      has_rule_context
      set_table_name "role_types"
    end
  end

  it "should provide a get_context method to an ActiveRecord::Base class" do

    @test_obj = TestClass.new
    @test_obj.respond_to?(:get_context).should eq(true)
  end

  it "should return a hash with the attributes of the model" do

    @obj = TestClass.new
    @obj.internal_identifier = "test_obj"
    @obj.save

    @result = @obj.get_context()
    @result.has_key?("internal_identifier").should eq(true)
    @result["internal_identifier"].should eq("test_obj")
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
erp_rules-4.2.0 spec/lib/erp_rules/extensions/active_record/has_rule_context_spec.rb
erp_rules-4.0.0 spec/lib/erp_rules/extensions/active_record/has_rule_context_spec.rb
erp_rules-3.1.0 spec/lib/erp_rules/extensions/active_record/has_rule_context_spec.rb
erp_rules-3.0.4 spec/lib/erp_rules/extensions/active_record/has_rule_context_spec.rb
erp_rules-3.0.3 spec/lib/erp_rules/extensions/active_record/has_rule_context_spec.rb
erp_rules-3.0.2 spec/lib/erp_rules/extensions/active_record/has_rule_context_spec.rb
erp_rules-3.0.1 spec/lib/erp_rules/extensions/active_record/has_rule_context_spec.rb