Sha256: 3d680af2785d9c4f8bf4142c6ee70ef343097d42cd6f414763293a78cad42011

Contents?: true

Size: 558 Bytes

Versions: 9

Compression:

Stored size: 558 Bytes

Contents

require "#{::File.dirname(__FILE__)}/../../test_helper"

class RunOnceClass
  attr_reader :apples, :count
  def initialize
    @count = 1
  end
  def run_me
    do_once do
      @count += 1
      @apples = "to apples"
    end
  end
end

class RunOnceTest < Test::Unit::TestCase
  def setup
    @ro = RunOnceClass.new
  end
  def test_apples_should_be_nil
    assert_nil @ro.apples
    assert_equal @ro.count, 1
  end
  def test_apples_should_not_be_nil_when_run
    @ro.run_me
    assert_equal @ro.apples, "to apples"
    assert_equal @ro.count, 2
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
auser-poolparty-1.2.10 test/poolparty/core/object_test.rb
auser-poolparty-1.2.11 test/poolparty/core/object_test.rb
auser-poolparty-1.2.12 test/poolparty/core/object_test.rb
auser-poolparty-1.2.3 test/poolparty/core/object_test.rb
auser-poolparty-1.2.4 test/poolparty/core/object_test.rb
auser-poolparty-1.2.7 test/poolparty/core/object_test.rb
auser-poolparty-1.2.8 test/poolparty/core/object_test.rb
auser-poolparty-1.2.9 test/poolparty/core/object_test.rb
fairchild-poolparty-1.2.12 test/poolparty/core/object_test.rb