Sha256: aa4555f752385435fa35345383441527b108352749ab583a4817e08d667541e6

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 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
    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(NoMethodError) {temp.set :badname}
  end

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

end# TestSetter

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xot-0.1.6 test/test_setter.rb
xot-0.1.5 test/test_setter.rb