Sha256: 92dd9a0abf0d8963752116319687a25ef1e7b2eb2aa3b093674fb88e87b06953

Contents?: true

Size: 920 Bytes

Versions: 16

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

require 'helper'

class Nanoc::Int::ContextTest < Nanoc::TestCase
  def test_context_with_instance_variable
    # Create context
    context = Nanoc::Int::Context.new(foo: 'bar', baz: 'quux')

    # Ensure correct evaluation
    assert_equal('bar', eval('@foo', context.get_binding))
  end

  def test_context_with_instance_method
    # Create context
    context = Nanoc::Int::Context.new(foo: 'bar', baz: 'quux')

    # Ensure correct evaluation
    assert_equal('bar', eval('foo', context.get_binding))
  end

  def test_example
    # Parse
    YARD.parse(LIB_DIR + '/nanoc/base/entities/context.rb')

    # Run
    assert_examples_correct 'Nanoc::Int::Context#initialize'
  end

  def test_include
    context = Nanoc::Int::Context.new({})
    eval('include Nanoc::Helpers::HTMLEscape', context.get_binding)
    assert_equal('&lt;&gt;', eval('h("<>")', context.get_binding))
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
nanoc-4.8.10 test/base/test_context.rb
nanoc-4.8.9 test/base/test_context.rb
nanoc-4.8.8 test/base/test_context.rb
nanoc-4.8.7 test/base/test_context.rb
nanoc-4.8.6 test/base/test_context.rb
nanoc-4.8.5 test/base/test_context.rb
nanoc-4.8.4 test/base/test_context.rb
nanoc-4.8.3 test/base/test_context.rb
nanoc-4.8.2 test/base/test_context.rb
nanoc-4.8.1 test/base/test_context.rb
nanoc-4.8.0 test/base/test_context.rb
nanoc-4.7.14 test/base/test_context.rb
nanoc-4.7.13 test/base/test_context.rb
nanoc-4.7.12 test/base/test_context.rb
nanoc-4.7.11 test/base/test_context.rb
nanoc-4.7.10 test/base/test_context.rb