forked from railslove/rack-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbing_spec.rb
More file actions
53 lines (43 loc) · 1.63 KB
/
bing_spec.rb
File metadata and controls
53 lines (43 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
RSpec.describe Rack::Tracker::Bing do
it 'will be placed in the body' do
expect(described_class.position).to eq(:body)
end
describe "with events" do
subject { described_class.new(env, tracker: 'somebody').render }
describe "default" do
def env
{'tracker' => {
'bing' => [
{ 'class_name' => 'Conversion', 'category' => 'Users', 'action' => 'Login', 'label' => 'Standard', 'value' => 10 }
]
}}
end
it "will show event initialiser" do
expect(subject).to include "window.uetq = window.uetq || [];"
end
it "will show events" do
expect(subject).to include "window.uetq.push({ 'ec': 'Users', 'ea': 'Login', 'el': 'Standard', 'ev': 10 });"
end
end
end
describe "with multiple events" do
subject { described_class.new(env, tracker: 'somebody').render }
describe "default" do
def env
{'tracker' => {
'bing' => [
{ 'class_name' => 'Conversion', 'category' => 'Users', 'action' => 'Login', 'label' => 'Standard', 'value' => 10 },
{ 'class_name' => 'Conversion', 'category' => 'Users', 'action' => 'Logout', 'label' => 'Standard', 'value' => 5 }
]
}}
end
it "will show event initialiser" do
expect(subject).to include "window.uetq = window.uetq || [];"
end
it "will show events" do
expect(subject).to include "window.uetq.push({ 'ec': 'Users', 'ea': 'Login', 'el': 'Standard', 'ev': 10 });"
expect(subject).to include "window.uetq.push({ 'ec': 'Users', 'ea': 'Logout', 'el': 'Standard', 'ev': 5 });"
end
end
end
end