Sha256: 811a9173ae87f79fe238db21cc1dce81f00a113f80bf25571c47f0845ef9c306

Contents?: true

Size: 660 Bytes

Versions: 11

Compression:

Stored size: 660 Bytes

Contents

# -*- coding: utf-8 -*-


require_relative 'helper'


class TestSetter < Test::Unit::TestCase

  class Temp

    include Xot::Setter

    attr_accessor :x, :y

  end# Temp

  def temp(*args)
    Temp.new
  end

  def test_set()
    o = temp
    assert_equal nil, o.x
    o.set :x, 1
    assert_equal 1,   o.x
  end

  def test_set_by_hash()
    o = temp
    o.set :x => 1, :y => 2
    assert_equal [1, 2], [o.x, o.y]
  end

  def test_invalid_name()
    assert_raise(NoMethodError) {temp.set :badname, 1}
    assert_raise(ArgumentError) {temp.set :badname}
  end

  def test_invalid_value()
    assert_raise(ArgumentError) {temp.set :x}
  end

end# TestSetter

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
xot-0.1.32 test/test_setter.rb
xot-0.1.31 test/test_setter.rb
xot-0.1.30 test/test_setter.rb
xot-0.1.29 test/test_setter.rb
xot-0.1.28 test/test_setter.rb
xot-0.1.27 test/test_setter.rb
xot-0.1.26 test/test_setter.rb
xot-0.1.25 test/test_setter.rb
xot-0.1.24 test/test_setter.rb
xot-0.1.23 test/test_setter.rb
xot-0.1.22 test/test_setter.rb