Skip to content

Commit 62a019f

Browse files
authored
Migrate ActionView::Utils tests to RSpec (#1432)
1 parent 000e167 commit 62a019f

File tree

2 files changed

+49
-47
lines changed

2 files changed

+49
-47
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
RSpec.describe Datadog::Contrib::ActionView::Utils do
2+
describe '#normalize_template_name' do
3+
subject(:normalize_template_name) { described_class.normalize_template_name(name) }
4+
5+
after { Datadog.configuration[:action_view].reset! }
6+
7+
context 'with template path' do
8+
let(:name) { '/rails/app/views/welcome/index.html.erb' }
9+
10+
it { is_expected.to eq('welcome/index.html.erb') }
11+
end
12+
13+
context 'with nil template' do
14+
let(:name) { nil }
15+
16+
it { is_expected.to be(nil) }
17+
end
18+
19+
context 'with file name only' do
20+
let(:name) { 'index.html.erb' }
21+
22+
it { is_expected.to eq('index.html.erb') }
23+
end
24+
25+
context 'with template outside of `views/` directory' do
26+
let(:name) { '/rails/app/other/welcome/index.html.erb' }
27+
28+
it { is_expected.to eq('index.html.erb') }
29+
end
30+
31+
context 'with a custom template base path' do
32+
before { Datadog.configuration[:action_view][:template_base_path] = 'custom/' }
33+
34+
context 'with template outside of `views/` directory' do
35+
let(:name) { '/rails/app/custom/welcome/index.html.erb' }
36+
37+
it { is_expected.to eq('welcome/index.html.erb') }
38+
end
39+
end
40+
41+
context 'with a non-string-like argument' do
42+
let(:name) { :not_a_string }
43+
44+
it 'stringifies arguments' do
45+
is_expected.to eq('not_a_string')
46+
end
47+
end
48+
end
49+
end

test/contrib/rails/utils_test.rb

-47
This file was deleted.

0 commit comments

Comments
 (0)