Sha256: 07ca71c566a91bfb6503adc04b701e9d31e277cf30e614ff0a3b041ef35f81b6

Contents?: true

Size: 841 Bytes

Versions: 5

Compression:

Stored size: 841 Bytes

Contents

require 'spec_helper'

describe Metrics::Instruments::Gauge do
  before(:each) do
  end

  it "should create a new gauge" do
    callback = Proc.new {}
    @gauge = Metrics::Instruments::Gauge.new &callback
  end
  
  it "should correctly callback the block given when we call Gauge#get" do
    result = 42
    
    callback = Proc.new do 
      {
        :result => result
      }
    end
    
    @gauge = Metrics::Instruments::Gauge.new &callback
    
    @gauge.get[:result].should == 42
    
    result += 1
    
    @gauge.get[:result].should == 43
  end
  
  it "should JSONify the results when you call to_s" do
    result = 42
    
    callback = Proc.new do 
      {
        :result => result
      }
    end
    
    @gauge = Metrics::Instruments::Gauge.new &callback
    
    @gauge.to_s.should == "{\"result\":42}"
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-metrics-0.8.5 spec/instruments/gauge_spec.rb
ruby-metrics-0.8.0 spec/instruments/gauge_spec.rb
ruby-metrics-0.7.0 spec/instruments/gauge_spec.rb
ruby-metrics-0.6.0 spec/instruments/gauge_spec.rb
ruby-metrics-0.5.0 spec/instruments/gauge_spec.rb