Sha256: 77f90cf162d5a222a188f6ade1da2817fe7d74062e5dfd15f54baf23e2809e9a
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
begin require 'bundler/setup' rescue LoadError puts 'Use of Bundler is recommended' end require 'rspec' require 'net/https' require 'em-http' require File.expand_path("../../lib/keen", __FILE__) module Keen::SpecHelpers def stub_keen_request(method, url, status, response_body) stub_request(method, url).to_return(:status => status, :body => response_body) end def stub_keen_post(url, status, response_body) stub_keen_request(:post, url, status, MultiJson.encode(response_body)) end def stub_keen_get(url, status, response_body) stub_keen_request(:get, url, status, MultiJson.encode(response_body)) end def expect_keen_request(method, url, body, sync_or_async_ua, read_or_write_key) user_agent = "keen-gem, v#{Keen::VERSION}, #{sync_or_async_ua}" user_agent += ", #{RUBY_VERSION}, #{RUBY_PLATFORM}, #{RUBY_PATCHLEVEL}" if defined?(RUBY_ENGINE) user_agent += ", #{RUBY_ENGINE}" end headers = { "Content-Type" => "application/json", "User-Agent" => user_agent, "Authorization" => read_or_write_key } WebMock.should have_requested(method, url).with( :body => body, :headers => headers) end def expect_keen_get(url, sync_or_async_ua, read_key) expect_keen_request(:get, url, "", sync_or_async_ua, read_key) end def expect_keen_post(url, event_properties, sync_or_async_ua, write_key) expect_keen_request(:post, url, MultiJson.encode(event_properties), sync_or_async_ua, write_key) end def api_event_resource_url(collection) "https://api.keen.io/3.0/projects/#{project_id}/events/#{collection}" end end RSpec.configure do |config| config.include(Keen::SpecHelpers) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
keen-0.7.0 | spec/spec_helper.rb |