Skip to content

Commit 5cc263d

Browse files
committed
Fixed test
1 parent 41c3c47 commit 5cc263d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

lib/split/analytics.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ def tracking_code(options = {})
3131
end
3232

3333
def custom_variables
34-
return nil if session[:split].nil?
34+
return nil if session.nil?
3535
arr = []
36-
session[:split].each_with_index do |h, i|
36+
37+
session.each_with_index do |h, i|
3738
arr << "_gaq.push([\"_setCustomVar\", #{i + 1}, \"#{h[0]}\", \"#{h[1]}\", 1]);"
3839
end
3940
arr.reverse[0..4].reverse.join("\n")

spec/analytics_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
it 'should add custom variables for every test the user is involved in' do
2121
first_alt = ab_test('link_colour', 'red', 'blue')
2222

23-
session[:split].should eql({'link_colour' => first_alt})
23+
expect(session).to eql({'link_colour' => first_alt})
2424

2525
tracking_code = tracking_code(account: 'UA-12345-6')
2626
expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", 'UA-12345-6']);\n \n _gaq.push(['_setCustomVar', 1, 'link_colour', '#{first_alt}', 1]);\n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})

0 commit comments

Comments
 (0)