Sha256: 7cddf897182614ddefa2d1b356a394ea782bdb38855ecb38a3c4fb12c1759721

Contents?: true

Size: 489 Bytes

Versions: 3

Compression:

Stored size: 489 Bytes

Contents

require File.expand_path(File.dirname(__FILE__)) + '/helper'

class TestSafety < Test::Unit::TestCase
  class Testable
    include Tracksperanto::Safety
    attr_accessor :foo, :bar
    safe_reader :foo, :bar
  end
  
  def test_safe_reader_raises_with_no_ivar
    t = Testable.new
    assert_raise(RuntimeError) { t.foo }
  end

  def test_safe_reader_does_not_raise_with_value_assigned
    t = Testable.new
    t.foo = 123
    assert_nothing_raised { assert_equal 123, t.foo }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tracksperanto-4.1.2 test/test_safety.rb
tracksperanto-4.1.0 test/test_safety.rb
tracksperanto-4.0.0 test/test_safety.rb