Sha256: fa73971d66fc3f1833bd1451d34df9dcdd7075cfe1b725a09ac0e0ce99fb8a9c

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

module Prosperity
  describe Metric do
    context "A simple scope metric" do
      subject do
        Class.new(Metric) do 
          scope { User }
        end.new
      end

      it "groups by created_at by default" do
        subject.group_by.should == :created_at
      end

      it "gets the scope" do
        subject.scope.should == User
      end
    end
    
    context "a metric missing the scope" do
      subject do
        Class.new(Metric) do 
        end
      end

      it "raises an exception when accessing the scope" do
        expect { subject.scope }.to raise_exception(MissingScope)
      end
    end

    context "A simple scope metric with multiple options" do
      subject do
        Class.new(Metric) do 
          scope { User }
          options "active" do |scope|
            scope.active
          end
        end.new
      end

      it "should have multiple options" do
        subject.options.size.should == 2
        subject.options['default'].should be_present
        subject.options['active'].should be_present
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prosperity-0.0.1 spec/lib/prosperity/metric_spec.rb