Sha256: 8abd82be98393a98cd4ad11864bde278bc2b24c934f298d6b299180566d6cddb

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# -*- encoding: utf-8 -*-

require 'test/unit'
require 'helper'
require 'webgen/context'

class TestContext < Test::Unit::TestCase

  def setup
    @context = Webgen::Context.new(:content => 'test', :key => :value, :chain => [:first, :last])
  end

  def test_initialize
    context = Webgen::Context.new
    assert_equal('', context.content)
    assert_kind_of(Webgen::ContentProcessor::AccessHash, context[:processors])
  end

  def test_clone
    other = @context.clone(:content => 'new', :key => :other)
    assert_equal('new', other.content)
    assert_equal(:other, other[:key])
    assert_equal([:first, :last], other[:chain])
  end

  def test_accessors
    assert_equal(:value, @context[:key])
    assert_equal([:first, :last], @context[:chain])
    assert_equal('test', @context.content)
    @context[:key] = :newvalue
    assert_equal(:newvalue, @context[:key])
  end

  def test_node_methods
    assert_equal(:first, @context.ref_node)
    assert_equal(:last, @context.content_node)
    assert_equal(:last, @context.dest_node)
    @context[:dest_node] = :other
    assert_equal(:other, @context.dest_node)
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.8.20090507 test/test_context.rb
webgen-0.5.8 test/test_context.rb