Sha256: 7055c780e54a16c47d017566e82ad2bcf404b9e11ff663421a3dab211e9f8626

Contents?: true

Size: 958 Bytes

Versions: 28

Compression:

Stored size: 958 Bytes

Contents

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

class DelayedTestClass
  include Delayed
  
  attr_reader :name
  def initialize(n)
    @name = n
  end
  def say(msg)
    "me: #{msg}"
  end
  def respond(msg)
    delayed_action do
      "#{name}: #{msg}"
    end
  end
  
  def after_all_loaded
    run_after_loaded do |k,v|
      puts "hi: #{k}"
    end
  end
end

class DelayedTest < Test::Unit::TestCase
  
  def setup
    @inst = DelayedTestClass.new("Amy")
  end
  
  def test_loaded_bang
    assert_equal false, @inst.loaded
    @inst.loaded!
    assert_equal true, @inst.loaded
  end
  
  def test_delayed_action_output
    assert_equal({}, DelayedTestClass.delayed_calls)
    assert_equal "me: hello", @inst.say("hello")
    assert_equal DelayedProc, @inst.respond("hi back").class
  end
  
  def test_running_delayed_actions
    @inst.loaded!
    @inst.after_all_loaded
    assert_equal "Amy: hi back", @inst.respond("hi back")
  end
  
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.1 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.10 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.11 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.12 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.13 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.14 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.15 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.16 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.17 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.2 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.3 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.4 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.5 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.6 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.7 test/lib/mixins/delayed_test.rb
auser-poolparty-1.3.8 test/lib/mixins/delayed_test.rb
fairchild-poolparty-1.3.17 test/lib/mixins/delayed_test.rb
fairchild-poolparty-1.3.5 test/lib/mixins/delayed_test.rb
poolparty-1.3.15 test/lib/mixins/delayed_test.rb