Sha256: df8e3702ddad9079ba4ce416f1e73191503ae794f89f561290948cdeb36f7155

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

require "spec_helper"
require "cascade/statistics"

describe Cascade::Statistics do
  subject { Cascade::Statistics.instance }

  context "#register_action" do
    it "regsiter store for statistics with passed name, store type and value" do
      subject.register_action(:record_parsed, :counter)
      assert_instance_of Cascade::StatisticsStores::CounterStore, subject.
        send(:store_repository)[:record_parsed]
    end

    it "raise NotImplementedError for unknown stores" do
      assert_raises NotImplementedError do
        subject.register_action(:some_action, :magic)
      end
    end
  end

  context "#register_action" do
    it "delegate update action to store with passed value" do
      mock(subject.send(:store_repository)[:record_parsed]).update(29)
      subject.update(:record_parsed, 29)
    end

    it "delegate update action to store with nil as default value" do
      mock(subject.send(:store_repository)[:record_parsed]).update(nil)
      subject.update(:record_parsed, nil)
    end
  end

  context "#for" do
    it "retrives info from store object" do
      mock(subject.send(:store_repository)[:record_parsed]).store
      subject.for(:record_parsed)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cascade-rb-0.2.3 spec/lib/statistics_spec.rb
cascade-rb-0.2.2 spec/lib/statistics_spec.rb
cascade-rb-0.2.1 spec/lib/statistics_spec.rb
cascade-rb-0.2.0 spec/lib/statistics_spec.rb
cascade-rb-0.1.5 spec/lib/statistics_spec.rb
cascade-rb-0.1.4 spec/lib/statistics_spec.rb
cascade-rb-0.1.2 spec/lib/statistics_spec.rb
cascade-rb-0.1.1 spec/lib/statistics_spec.rb
cascade-rb-0.1.0 spec/lib/statistics_spec.rb