Sha256: c49a9f676a98ac2df42dd81896e2219e1e89cbc7cab07efa05cbb5ed73a72772

Contents?: true

Size: 703 Bytes

Versions: 3

Compression:

Stored size: 703 Bytes

Contents

# encoding: utf-8

require 'test/helper'

class Nanoc3::CodeSnippetTest < MiniTest::Unit::TestCase

  include Nanoc3::TestHelpers

  def test_load
    # Initialize
    $complete_insane_parrot = 'meow'

    # Create code and load it
    code_snippet = Nanoc3::CodeSnippet.new("$complete_insane_parrot = 'woof'", 'parrot.rb')
    code_snippet.load

    # Ensure code is loaded
    assert_equal('woof', $complete_insane_parrot)
  end

  def test_load_with_toplevel_binding
    # Initialize
    @foo = 'meow'

    # Create code and load it
    code_snippet = Nanoc3::CodeSnippet.new("@foo = 'woof'", 'dog.rb')
    code_snippet.load

    # Ensure binding is correct
    assert_equal('meow', @foo)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nanoc3-3.1.9 test/base/test_code_snippet.rb
nanoc3-3.1.8 test/base/test_code_snippet.rb
nanoc3-3.2.0a4 test/base/test_code_snippet.rb