Sha256: 8e3c4eaa82ef0cd002eb59b4ac28851d71ea70dd1ce9ad96d66d669bede5f829

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

require 'spec_helper'

describe Chargify::Loops do
  before :each do
    Chargify::Loops.loops.clear
  end

  describe '.delegate_hook' do
    let(:alpha_hook) { double('hook') }
    let(:beta_hook)  { double('hook') }

    it "calls every registered loop for the given event with the payload" do
      Chargify::Loops.loops[:alpha] = [alpha_hook]
      Chargify::Loops.loops[:beta]  = [beta_hook]

      alpha_hook.should_receive(:call).with(:foo)
      beta_hook.should_not_receive(:call)

      Chargify::Loops.delegate_hook :alpha, :foo
    end

    it "does not complain if there's no loops for a given hook" do
      Chargify::Loops.delegate_hook :alpha, :foo
    end
  end

  describe '.loop!' do
    it "appends a loop for the given event" do
      Chargify::Loops.loop! :test do |payload|
        #
      end

      Chargify::Loops.loops[:test].length.should == 1
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chargify-loops-0.2.0 spec/chargify/loops_spec.rb
chargify-loops-0.1.0 spec/chargify/loops_spec.rb