@@ -7,27 +7,46 @@ def env
77 describe "with events" do
88 describe "default" do
99 def env
10- { "tracker.google_analytics.events" => [
11- Rack ::Tracker ::GoogleAnalytics ::Event . new ( "Users" , "Login" , "Standard" )
12- ] }
10+ { 'tracker' => {
11+ 'google_analytics' => [
12+ Rack ::Tracker ::GoogleAnalytics ::Event . new ( "Users" , "Login" , "Standard" )
13+ ]
14+ } }
1315 end
1416
1517 subject { described_class . new ( env , tracker : 'somebody' , cookieDomain : "railslabs.com" ) . render }
1618 it "will show events" do
17- expect ( subject ) . to match ( %r{ga\( ' send', {\" hitType\" :\" event\" ,\" eventCategory\" :\" Users\" ,\" eventAction\" :\" Login\" ,\" eventLabel\" :\" Standard\" }\) } )
19+ expect ( subject ) . to match ( %r{ga\( \" send\" , {\" hitType\" :\" event\" ,\" eventCategory\" :\" Users\" ,\" eventAction\" :\" Login\" ,\" eventLabel\" :\" Standard\" }\) } )
1820 end
1921 end
2022
2123 describe "with a event value" do
2224 def env
23- { " tracker. google_analytics.events" => [
25+ { ' tracker' => { ' google_analytics' => [
2426 Rack ::Tracker ::GoogleAnalytics ::Event . new ( "Users" , "Login" , "Standard" , 5 )
25- ] }
27+ ] } }
2628 end
2729
2830 subject { described_class . new ( env , tracker : 'somebody' , cookieDomain : "railslabs.com" ) . render }
2931 it "will show events with values" do
30- expect ( subject ) . to match ( %r{ga\( 'send', {\" hitType\" :\" event\" ,\" eventCategory\" :\" Users\" ,\" eventAction\" :\" Login\" ,\" eventLabel\" :\" Standard\" ,\" eventValue\" :5}\) } , )
32+ expect ( subject ) . to match ( %r{ga\( \" send\" ,{\" hitType\" :\" event\" ,\" eventCategory\" :\" Users\" ,\" eventAction\" :\" Login\" ,\" eventLabel\" :\" Standard\" ,\" eventValue\" :5}\) } , )
33+ end
34+ end
35+ end
36+
37+ describe 'with e-commerce events' do
38+ describe "default" do
39+ def env
40+ { 'tracker' => {
41+ 'google_analytics' => [
42+ Rack ::Tracker ::GoogleAnalytics ::Ecommerce . new ( 'ecommerce:addItem' , { id : '1234' , affiliation : 'Acme Clothing' , revenue : 11.99 , shipping : '5' , tax : '1.29' , currency : 'EUR' } )
43+ ]
44+ } }
45+ end
46+
47+ subject { described_class . new ( env , tracker : 'somebody' , cookieDomain : "railslabs.com" ) . render }
48+ it "will show events" do
49+ expect ( subject ) . to match ( %r{ga\( \" ecommerce:addItem\" ,#{ { id : '1234' , affiliation : 'Acme Clothing' , revenue : 11.99 , shipping : '5' , tax : '1.29' , currency : 'EUR' } . to_json } } )
3150 end
3251 end
3352 end
0 commit comments