Sha256: a33f77054c2a0881c39f7c682f5785d44d210f1e33a1f42ca2d87210d829a18a

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require_relative './test_helper'

class TestEnvironment < Minitest::Test
  def setup
    @parent = Environment.new(nil, { language: 'ruby' })
    @child = Environment.new(@parent, { test_framework: 'minitest' })
  end

  def test_initialize
    assert_instance_of Environment, @parent
    assert_instance_of Environment, @child
  end

  def test_parent
    assert_nil @parent.parent
    assert_instance_of Environment, @child.parent
    assert_equal @parent, @child.parent
  end

  def test_defaults
    assert_instance_of Hash, @parent.defaults
    assert_instance_of Hash, @child.defaults
  end

  def test_define
    assert_equal 'vim', @child.define(:editor, 'vim')
    assert_equal 'vim', @child.defaults[:editor]
  end

  def test_defined?
    assert @child.defined?(:test_framework)
    assert @child.defined?(:language)
    refute @child.defined?(:version_control)
  end

  def test_lookup
    assert_equal 'minitest', @child.lookup(:test_framework)
    assert_equal 'ruby',  @child.lookup(:language)
    assert_raises(RuntimeError) { @child.lookup(:version_control) }
  end

  def test_set
    assert_equal 'rspec', @child.set(:test_framework, 'rspec')
    assert_equal 'rspec', @child.lookup(:test_framework)
    assert_equal 'lisp',  @child.set(:language, 'lisp')
    assert_equal 'lisp', @child.lookup(:language)
    assert_raises(RuntimeError) { @child.set(:version_control, 'git') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
forsta-0.0.1 test/environment_test.rb