test/test_statsmix.rb in statsmix-0.3.0 vs test/test_statsmix.rb in statsmix-1.0.0
- old
+ new
@@ -1,19 +1,34 @@
require 'helper'
require 'statsmix'
class TestStatsmix < Test::Unit::TestCase
+
+ GEM_VERSION = File.exist?('VERSION') ? File.read('VERSION') : ""
# TODO use fakwweb gem for testing
# http://technicalpickles.com/posts/stop-net-http-dead-in-its-tracks-with-fakeweb/
# https://github.com/chrisk/fakeweb
# http://fakeweb.rubyforge.org/
# TODO use VCR for tests
# http://www.rubyinside.com/vcr-a-recorder-for-all-your-tests-http-interactions-4169.html
# https://github.com/myronmarston/vcr
-
+
+ should "Provide the correct user_agent" do
+ StatsMix.api_key = '59f08613db2691f28afe'
+ StatsMix.format = 'xml'
+ result = StatsMix.track('Ruby Gem Testing')
+
+ if StatsMix.error
+ raise "error in gem: #{StatsMix.error}"
+ end
+ assert !StatsMix.error
+ assert StatsMix.user_agent == "StatsMix Ruby Gem " + GEM_VERSION
+ puts StatsMix.user_agent
+ end
+
should "Track a stat and view the result in xml" do
StatsMix.api_key = '59f08613db2691f28afe'
StatsMix.format = 'xml'
result = StatsMix.track('Ruby Gem Testing')
if StatsMix.error
@@ -32,11 +47,11 @@
end
assert !StatsMix.error
puts result
end
- should "Track a stat with metadataand view the result in xml" do
+ should "Track a stat with metadata and view the result in xml" do
StatsMix.api_key = '59f08613db2691f28afe'
StatsMix.format = 'xml'
result = StatsMix.track('Ruby Gem Testing', 1, {"meta"=>{"client"=>"Android", "client_version"=>"1.0.7.2"}})
if StatsMix.error
raise "Error in gem: #{StatsMix.error}"
@@ -64,7 +79,6 @@
raise "Error in gem: #{StatsMix.error}"
end
assert !StatsMix.error
puts result
end
-
end
\ No newline at end of file