Sha256: 6371f7a207822f9d061c17870dc25f6013f03023995b7dad5ec7181e4cb625d0

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

RSpec.describe ActiveTracker::Model do
  context 'loading an item' do
    before do
      @key = '/ActiveTracker/Request/20190927194300/id:e52c5517-eb46-4ba5-be56-90aa7436f26a/path:%2Flogin%3Ffoo/method:get/summary'
      @value = {"items": [1,2,3]}.to_json
      @obj = ActiveTracker::Model.new(@key, @value)
    end

    it 'sets the id' do
      expect(@obj.id).to eq(@key)
    end

    it 'sets the type' do
      expect(@obj.type).to eq("Request")
    end

    it 'sets the data_type' do
      expect(@obj.data_type).to eq("summary")
    end

    it 'sets the tags' do
      expect(@obj.tags).to eq({id: "e52c5517-eb46-4ba5-be56-90aa7436f26a", method: "get", path: "/login?foo"})
    end

    it 'sets the log_at' do
      Timecop.freeze(Time.new(2019, 9, 1, 11, 00)) do
        @obj = ActiveTracker::Model.new(@key, @value)
        expect(@obj.log_at).to eq(Time.new(2019, 9, 27, 19, 43, 00))
      end
    end

    it 'sets the values from the body' do
      expect(@obj.items).to eq([1,2,3])
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activetracker-0.4.9 spec/lib/active_tracker/model_spec.rb
activetracker-0.4.8 spec/lib/active_tracker/model_spec.rb
activetracker-0.4.7 spec/lib/active_tracker/model_spec.rb
activetracker-0.4.6 spec/lib/active_tracker/model_spec.rb
activetracker-0.4.5 spec/lib/active_tracker/model_spec.rb
activetracker-0.4.4 spec/lib/active_tracker/model_spec.rb
activetracker-0.4.3 spec/lib/active_tracker/model_spec.rb
activetracker-0.4.2 spec/lib/active_tracker/model_spec.rb
activetracker-0.4.1 spec/lib/active_tracker/model_spec.rb
activetracker-0.4.0 spec/lib/active_tracker/model_spec.rb