Sha256: 838ad209db4f6075a9822431943df1e5c775bbcc2f80e630325fbaa0675d4dad

Contents?: true

Size: 838 Bytes

Versions: 12

Compression:

Stored size: 838 Bytes

Contents

require 'spec_helper'
require 'peastash/rails_ext/watch'

describe "Peastash::Watch" do
  it "adds the #watch method to Peastash" do
    expect(Peastash.with_instance).to respond_to(:watch)
  end

  describe "#watch" do
    it "can subscribe to any notification" do
      @dummy = Object.new.stub(:foo)
      @subscriber = Peastash.with_instance.watch('foo.bar') { @dummy.foo }
      expect(@dummy).to receive(:foo)
      ActiveSupport::Notifications.instrument('foo.bar')
      ActiveSupport::Notifications.unsubscribe(@subscriber)
    end

    it "is provided with a handy named store" do
      Peastash.with_instance.watch('foo.bar') { |*event, store| store[:foo] = 'bar' }
      @subscriber = ActiveSupport::Notifications.instrument('foo.bar')
      expect(Peastash.with_instance.store['foo.bar']).to eq(foo: 'bar')
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
peastash-0.2.9 spec/peastash/rails_ext/watch_spec.rb
peastash-0.2.7 spec/peastash/rails_ext/watch_spec.rb
peastash-0.2.6 spec/peastash/rails_ext/watch_spec.rb
peastash-0.2.5 spec/peastash/rails_ext/watch_spec.rb
peastash-0.2.4 spec/peastash/rails_ext/watch_spec.rb
peastash-0.2.3 spec/peastash/rails_ext/watch_spec.rb
peastash-0.2.2 spec/peastash/rails_ext/watch_spec.rb
peastash-0.2.1 spec/peastash/rails_ext/watch_spec.rb
peastash-0.1.1 spec/peastash/rails_ext/watch_spec.rb
peastash-0.1.0 spec/peastash/rails_ext/watch_spec.rb
peastash-0.0.9 spec/peastash/rails_ext/watch_spec.rb
peastash-0.0.8 spec/peastash/rails_ext/watch_spec.rb