Sha256: 02180631d47277b412e0ffb6659bc4e3c1f34e78b1f5d353e4fb90955bc2cc8b

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

#!/usr/bin/env ruby

require 'test/unit'
currentPath = File.dirname(__FILE__)
require File.join( currentPath, '../../lib/masterview' )

class TestDirectiveHelpers < Test::Unit::TestCase
  include MasterView::DirectiveHelpers


  def test_find_last_parent_strings
    tag = OpenStruct.new
    tag.parent = OpenStruct.new
    
    foo = 'foo'
    bar = 'bar'
    baz = 'baz'
    bar2 = 'bar'
    hello = 'hello'
    tag.parent.content = [foo, bar, baz, bar2, hello]
    assert_equal bar2.object_id, find_last_in_parent(tag, 'bar').object_id
    assert bar.object_id != find_last_in_parent(tag, 'bar').object_id
  end

  # test bug found by Sergey Shalatskly where it wasn't searching into arrays properly
  def test_find_last_parent_strings_and_arrays
    tag = OpenStruct.new
    tag.parent = OpenStruct.new
    
    foo = 'foo'
    bar = 'bar'
    baz = 'baz'
    bar2 = 'bar'
    hello = 'hello'
    tag.parent.content = [foo, bar, [baz, bar2, hello], ['one', 'world'], 'three']
    assert_equal bar2.object_id, find_last_in_parent(tag, 'bar').object_id
    assert bar.object_id != find_last_in_parent(tag, 'bar').object_id
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
masterview-0.3.1 test/unit/directive_helpers_test.rb
masterview-0.3.0 test/unit/directive_helpers_test.rb
masterview-0.3.2 test/unit/directive_helpers_test.rb
masterview-0.3.3 test/unit/directive_helpers_test.rb
masterview-0.3.4 test/unit/directive_helpers_test.rb