Sha256: 2e5e6bc392ef667a620d3eabde4665b064ed6572bc830cb61c246e2c659b5345

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

class LifecycleNotificationPlugin < Killbill::Plugin::PluginBase
  attr_accessor :lifecycled

  def start_plugin
    @lifecycled = true
    super
  end

  def stop_plugin
    @lifecycled = true
    super
  end
end

describe Killbill::Plugin::PluginBase do
  it 'should be able to register Killbill API instances' do
    plugin = Killbill::Plugin::PluginBase.new(:account_user_api => MockAccountUserApi.new)

    plugin.account_user_api.get_accounts(nil).size.should == 0
    lambda { plugin.foobar_user_api.do_foo('with my bar') }.should raise_error Killbill::Plugin::PluginBase::APINotAvailableError
  end

  it 'should be able to add custom code in the startup/shutdown sequence' do
    plugin = LifecycleNotificationPlugin.new

    plugin.lifecycled = false
    plugin.lifecycled.should be_false
    plugin.active.should be_false

    plugin.start_plugin
    plugin.lifecycled.should be_true
    plugin.active.should be_true

    plugin.lifecycled = false
    plugin.lifecycled.should be_false
    plugin.active.should be_true

    plugin.stop_plugin
    plugin.lifecycled.should be_true
    plugin.active.should be_false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
killbill-1.0.0 spec/killbill/base_plugin_spec.rb