Sha256: 4ecc42a23f6b9eeb9c017022ed86aa702792320d20bdac2b3980bc0c7abde08a
Contents?: true
Size: 1.21 KB
Versions: 7
Compression:
Stored size: 1.21 KB
Contents
require 'test_helper' require 'chillout/creations_container' module Chillout class CreationsMonitorRackTest < ChilloutTestCase include Rack::Test::Methods def setup api_key = "xyz123" stub_api_request(api_key, "clients") stub_api_request(api_key, "metrics") @config = Chillout::Config.new(api_key) @client = Chillout::Client.new(@config, :logger => null_logger) end def app client = @client deepest_level = lambda do |env| Chillout.creations = CreationsContainer.new Chillout.creations.increment!("User", 2) Chillout.creations.increment!("Cart",3 ) [200, env, ['hello']] end Rack::Builder.new do use Middleware::CreationsMonitor, client run(deepest_level) end end def test_creations_values get "/" Thread.pass sleep 3 assert_equal 2, request_body["measurements"].find{|m| m["series"] == "User" }.fetch("values").fetch("creations") assert_equal 3, request_body["measurements"].find{|m| m["series"] == "Cart" }.fetch("values").fetch("creations") end private def request_body assert_request_body("metrics") { |body| return body } end end end
Version data entries
7 entries across 7 versions & 1 rubygems