Sha256: b129991ec4b55bfb632c0bbb154ab0c49580b24a2a3cc62a1dd137ecea49ae86

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'test_helper'
require 'rubytree'

module Rooler
  class TemplateTest < ActiveSupport::TestCase
    
    test "finds an object from one of the templates rules" do
      rule = create(:rule, klass_name: 'Foo', klass_finder_method: 'active_record_finder')
      assert_nil rule.template.test_object
      
      foo1 = Foo.create
      foo2 = Foo.create
      assert_equal foo1, rule.template.test_object
    end
    
    test 'returns a tree of liquid methods from the sample object' do
      rule = create(:rule, klass_name: 'Foo', klass_finder_method: 'active_record_finder')
      foo = Foo.create
      
      tree = ::Tree::TreeNode.new("foo") 
      tree << ::Tree::TreeNode.new('active')
      tree << ::Tree::TreeNode.new('created_at')
      tree << ::Tree::TreeNode.new('bars')
      tree["bars"] << ::Tree::TreeNode.new("test")
      tree["bars"] << ::Tree::TreeNode.new("raboof")
      tree["bars"]["raboof"] << ::Tree::TreeNode.new('test')
      tree["bars"]["raboof"] << ::Tree::TreeNode.new('created_at')
      
      assert_equal tree, rule.template.liquid_method_tree
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rooler-0.0.4 test/models/rooler/template_test.rb
rooler-0.0.3 test/models/rooler/template_test.rb