-
Notifications
You must be signed in to change notification settings - Fork 658
/
Copy pathapplication_helper_spec.rb
57 lines (44 loc) · 1.26 KB
/
application_helper_spec.rb
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
54
55
56
57
# frozen_string_literal: true
require 'rails_helper'
describe ApplicationHelper, type: :helper do
describe '#class_for_path' do
# class_for_path(req, path)
subject { class_for_path(req, link_path) }
let(:req) { OpenStruct.new(path: req_path) }
let(:link_path) { '/explore' }
context 'paths are the same' do
context 'both root path' do
let(:req_path) { '/' }
let(:link_path) { '/' }
it 'returns `active`' do
expect(subject).to eq('active')
end
end
context 'exact match' do
let(:req_path) { link_path }
it 'returns `active`' do
expect(subject).to eq('active')
end
end
context 'sub path' do
let(:req_path) { '/explore/sub-link' }
it 'returns `active`' do
expect(subject).to eq('active')
end
end
context 'two sub path links' do
let(:req_path) { '/explore/sub-link' }
let(:link_path) { '/explore/sub-link' }
it 'returns `active` for subpath link' do
expect(subject).to eq('active')
end
end
end
context 'paths not the same' do
let(:req_path) { '/training' }
it 'returns nil' do
expect(subject).to be_nil
end
end
end
end