Sha256: 02d32c4245e6f4cc532aca8aa265edaa6bfb5e3b247be8dde17eaa1b3fe7eb75

Contents?: true

Size: 1.19 KB

Versions: 15

Compression:

Stored size: 1.19 KB

Contents

require ::File.expand_path('../spec_helper.rb', __FILE__)

describe FnordMetric::Event do

  include FnordMetric

  before(:all) do
    @now = Time.utc(1992,01,13,5,23,23).to_i   
    @redis = Redis.new
    @redis_wrap = RedisWrap.new(@redis)

    @namespace = "fnordmetric-test-ns1234-api" 
    @timeline = "#{@namespace}-timeline"

    @opts = {         
      :namespace_prefix => "#{@namespace}",
      :redis_prefix => "fnordmetric-test",
      :redis => @redis
    }  
    @api = FnordMetric::API.new @opts
  end

  describe "creating events using API" do

    before(:each) do        
      @redis.keys("fnordmetric-test-*").each { |k| @redis.del(k) }     
    end

    it "should create an event from a (json-)string" do
      json_string = {
        :_type => "Fn0rd123", 
        :_time => @now
      }.to_json
      event_id = @api.event(json_string)
      event = FnordMetric::Event.find(event_id, @opts)
      event.type.should == "Fn0rd123"
    end

    it "should create an event from a hash" do
      event_id = @api.event(
        :_type => "Fn0rd234", 
        :_time => @now
      )
      event = FnordMetric::Event.find(event_id, @opts)
      event.type.should == "Fn0rd234"
    end

  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
johnf-fnordmetric-1.2.10 spec/api_spec.rb
fnordmetric-1.2.9 spec/api_spec.rb
johnf-fnordmetric-1.2.7 spec/api_spec.rb
bp-fnordmetric-1.2.7 spec/api_spec.rb
fnordmetric-1.2.7 spec/api_spec.rb
fnordmetric-1.2.6 spec/api_spec.rb
fnordmetric-1.2.4 spec/api_spec.rb
fnordmetric-1.2.1 spec/api_spec.rb
fnordmetric-1.2.0 spec/api_spec.rb
fnordmetric-1.0.1 spec/api_spec.rb
fnordmetric-1.0.0 spec/api_spec.rb
fnordmetric-0.9.7 spec/api_spec.rb
fnordmetric-0.7.5 spec/api_spec.rb
fnordmetric-0.7.4 spec/api_spec.rb
fnordmetric-0.7.3 spec/api_spec.rb