Skip to content

Commit

Permalink
Migrate ActionView::Utils tests to RSpec (#1432)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc authored Mar 29, 2021
1 parent 000e167 commit 62a019f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 47 deletions.
49 changes: 49 additions & 0 deletions spec/ddtrace/contrib/action_view/utils_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
RSpec.describe Datadog::Contrib::ActionView::Utils do
describe '#normalize_template_name' do
subject(:normalize_template_name) { described_class.normalize_template_name(name) }

after { Datadog.configuration[:action_view].reset! }

context 'with template path' do
let(:name) { '/rails/app/views/welcome/index.html.erb' }

it { is_expected.to eq('welcome/index.html.erb') }
end

context 'with nil template' do
let(:name) { nil }

it { is_expected.to be(nil) }
end

context 'with file name only' do
let(:name) { 'index.html.erb' }

it { is_expected.to eq('index.html.erb') }
end

context 'with template outside of `views/` directory' do
let(:name) { '/rails/app/other/welcome/index.html.erb' }

it { is_expected.to eq('index.html.erb') }
end

context 'with a custom template base path' do
before { Datadog.configuration[:action_view][:template_base_path] = 'custom/' }

context 'with template outside of `views/` directory' do
let(:name) { '/rails/app/custom/welcome/index.html.erb' }

it { is_expected.to eq('welcome/index.html.erb') }
end
end

context 'with a non-string-like argument' do
let(:name) { :not_a_string }

it 'stringifies arguments' do
is_expected.to eq('not_a_string')
end
end
end
end
47 changes: 0 additions & 47 deletions test/contrib/rails/utils_test.rb

This file was deleted.

0 comments on commit 62a019f

Please sign in to comment.