Sha256: c8e5f77295914a6d323472072bc71b2bb20c16be3bb608550d36d7e41233fb8e

Contents?: true

Size: 635 Bytes

Versions: 2

Compression:

Stored size: 635 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'helper')

module Testing__
  class Foo
    attr_accessor :name
    include InstantiateWithAttrs
  end
end

class TestInstantiateWithAttrs < Test::Unit::TestCase

  def test_instantiated_without_any_attrs
    object = Testing__::Foo.new
    assert_nil object.name
  end

  def test_instantiated_with_attrs
    name = 'my name'
    attrs = {:name => name}
    object = Testing__::Foo.new attrs
    assert_equal name, object.name
  end

  def test_instantiated_with_invalid_attr
    attrs = {:wrong => 'boom'}
    assert_nothing_raised do
      Testing__::Foo.new attrs
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nextbus-0.0.1 test/unit/test_instantiate_with_attrs.rb
nextbus-0.0.0 test/unit/test_instantiate_with_attrs.rb