Permalink
Browse files

started to correct test suite and fixed some spelling mistakes

  • Loading branch information...
1 parent 3efab93 commit f15b18179a17a3d3abe577d87c9f16b170072a53 Gernot committed May 4, 2012
Showing with 44 additions and 16 deletions.
  1. +7 −0 Gemfile
  2. +19 −0 Gemfile.lock
  3. +2 −2 test/helper.rb
  4. +16 −14 test/test_rack_piwik.rb
View
@@ -0,0 +1,7 @@
+source 'https://rubygems.org'
+
+group :test do
+ gem "rack", "~> 1.4.1"
+ gem "rack-test", "~> 0.6.1"
+ gem "shoulda", "~> 3.0.1"
+end
View
@@ -0,0 +1,19 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ rack (1.4.1)
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ shoulda (3.0.1)
+ shoulda-context (~> 1.0.0)
+ shoulda-matchers (~> 1.0.0)
+ shoulda-context (1.0.0)
+ shoulda-matchers (1.0.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rack (~> 1.4.1)
+ rack-test (~> 0.6.1)
+ shoulda (~> 3.0.1)
View
@@ -3,7 +3,7 @@
require 'shoulda'
require 'rack'
require 'rack/test'
-require File.expand_path('../../lib/rack/google-analytics',__FILE__)
+require File.expand_path('../../lib/rack/piwik',__FILE__)
class Test::Unit::TestCase
include Rack::Test::Methods
@@ -22,7 +22,7 @@ def mock_app(options)
}
builder = Rack::Builder.new
- builder.use Rack::GoogleAnalytics, options
+ builder.use Rack::Piwik, options
builder.run main_app
@app = builder.to_app
end
View
@@ -1,24 +1,26 @@
require File.expand_path('../helper',__FILE__)
-class TestRackGoogleAnalytics < Test::Unit::TestCase
-
- context "Asyncronous" do
+class TestRackPiwik < Test::Unit::TestCase
+
+ context "Asynchronous" do
context "default" do
- setup { mock_app :async => true, :tracker => 'somebody' }
- should "show asyncronous tracker" do
+ setup { mock_app :async => true, :tracker => 'somebody', :piwik_url => 'piwik.example.org' }
+ should "show asynchronous tracker" do
get "/"
assert_match %r{\_gaq\.push}, last_response.body
assert_match %r{\'\_setAccount\', \"somebody\"}, last_response.body
- assert_match %r{</script></head>}, last_response.body
+ assert_match %r{</noscript></body>}, last_response.body
assert_equal "532", last_response.headers['Content-Length']
end
+ setup { mock_app :async => true, :multiple => true, :tracker => 'gonna', :piwik_url => 'piwik.example.org' }
should "not add tracker to none html content-type" do
get "/test.xml"
assert_no_match %r{\_gaq\.push}, last_response.body
assert_match %r{Xml here}, last_response.body
end
+ setup { mock_app :async => true, :multiple => true, :tracker => 'gonna', :piwik_url => 'piwik.example.org' }
should "not add without </head>" do
get "/bob"
assert_no_match %r{\_gaq\.push}, last_response.body
@@ -27,16 +29,16 @@ class TestRackGoogleAnalytics < Test::Unit::TestCase
end
context "multiple sub domains" do
- setup { mock_app :async => true, :multiple => true, :tracker => 'gonna', :domain => 'mydomain.com' }
+ setup { mock_app :async => true, :multiple => true, :tracker => 'gonna', :piwik_url => 'piwik.example.org' }
should "add multiple domain script" do
get "/"
- assert_match %r{'_setDomainName', \"mydomain.com\"}, last_response.body
+ assert_match %r{'_setDomainName', \"piwik.example.org\"}, last_response.body
assert_equal "579", last_response.headers['Content-Length']
end
end
-
+
context "multiple top-level domains" do
- setup { mock_app :async => true, :top_level => true, :tracker => 'get', :domain => 'mydomain.com' }
+ setup { mock_app :async => true, :top_level => true, :tracker => 'get', :piwik_url => 'piwik.example.org' }
should "add top_level domain script" do
get "/"
assert_match %r{'_setDomainName', 'none'}, last_response.body
@@ -45,10 +47,10 @@ class TestRackGoogleAnalytics < Test::Unit::TestCase
end
end
-
- context "Syncronous" do
- setup { mock_app :async => false, :tracker => 'whatthe' }
- should "show non-asyncronous tracker" do
+
+ context "Synchronous" do
+ setup { mock_app :async => false, :tracker => 'whatthe', :piwik_url => 'piwik.example.org' }
+ should "show non-asynchronous tracker" do
get "/bob"
assert_match %r{_gat._getTracker}, last_response.body
assert_match %r{</script></body>}, last_response.body

0 comments on commit f15b181

Please sign in to comment.