Sha256: 8a6015f4a9d7611b77b9e14aba4147d32487b7078f8f6b1cb8b7a6b3cfef0ff6
Contents?: true
Size: 1.67 KB
Versions: 2
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(base_url, collection) "#{base_url}/3.0/projects/#{project_id}/events/#{collection}" end end RSpec.configure do |config| config.include(Keen::SpecHelpers) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
keen-0.7.2 | spec/spec_helper.rb |
keen-0.7.1 | spec/spec_helper.rb |