Sha256: 7738ac9e56867d8e41478e80e6afb4a008e5749c5a8c4ba9e0c34a99ad5f7964

Contents?: true

Size: 1.24 KB

Versions: 28

Compression:

Stored size: 1.24 KB

Contents

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

class CallbacksTestClass
  attr_accessor :configured, :current_callback
  include Callbacks

  callback_block do |inst, callback|
    inst.current_callback = callback
  end
  
  def before_configure
    @configured = true
  end
end

class TestCallbacks < Test::Unit::TestCase
  context "methods" do
    setup do
      @tc = CallbacksTestClass.new
    end

    should "call the callback on the class when calling call_(\w+)_callbacks method" do
      assert_nil @tc.configured
      @tc.callback :before_configure
      assert @tc.configured
    end
    should "not explode when the method does not exist on the call_(\w+)_callbacks method" do
      lambda {@tc.callback :after_boxed}.should_not raise_error
    end
    
    should "call the callback_block with the callback call" do
      assert_nil @tc.current_callback
      @tc.callback :before_configure
      assert_equal :before_configure, @tc.current_callback
    end
    
    should "have the callbacks available in an array" do
      @tc.callback :before_configure
      assert_equal [:before_configure], @tc.callbacks
    end
    
    should "call the actual callback" do
      @tc.callback :before_configure
      assert @tc.configured
    end
  end
  
end

Version data entries

28 entries across 28 versions & 3 rubygems

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