Sha256: bdb968cd608608ae5b63ecd2b08624296431bce8d08edbaedf1cb5c86cff3057

Contents?: true

Size: 665 Bytes

Versions: 13

Compression:

Stored size: 665 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

13 entries across 13 versions & 1 rubygems

Version Path
xot-0.1.21 test/test_setter.rb
xot-0.1.20 test/test_setter.rb
xot-0.1.19 test/test_setter.rb
xot-0.1.16 test/test_setter.rb
xot-0.1.15 test/test_setter.rb
xot-0.1.14 test/test_setter.rb
xot-0.1.13 test/test_setter.rb
xot-0.1.12 test/test_setter.rb
xot-0.1.11 test/test_setter.rb
xot-0.1.10 test/test_setter.rb
xot-0.1.9 test/test_setter.rb
xot-0.1.8 test/test_setter.rb
xot-0.1.7 test/test_setter.rb