Skip to content

Commit 1d86b32

Browse files
shanecav84sebjacobs
authored andcommitted
Extract constant
1 parent fe41e04 commit 1d86b32

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/rspec/rails/example/system_example_group.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ module SystemExampleGroup
1111
include ActionDispatch::Assertions
1212
include ActionController::TemplateAssertions
1313

14+
# Special characters to translate into underscores for #method_name
15+
CHARS_TO_TRANSLATE = ['/', '.', ':', ',', "'", '"', " "].freeze
16+
1417
# @private
1518
module BlowAwayAfterTeardownHook
1619
# @private
@@ -35,7 +38,7 @@ def method_name
3538
self.class.name.underscore,
3639
RSpec.current_example.description.underscore,
3740
rand(1000)
38-
].join("_").tr('/.:,\'" ', "_")
41+
].join("_").tr(CHARS_TO_TRANSLATE.join, "_")
3942
end
4043

4144
# Delegates to `Rails.application`.

spec/rspec/rails/example/system_example_group_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module RSpec::Rails
1010
group = RSpec::Core::ExampleGroup.describe ActionPack do
1111
include SystemExampleGroup
1212
end
13-
['/', '.', ':', ',', "'", '"', ' '].each do |char|
13+
SystemExampleGroup::CHARS_TO_TRANSLATE.each do |char|
1414
example = group.new
1515
example_class_mock = double('name' => "method#{char}name")
1616
allow(example).to receive(:class).and_return(example_class_mock)

0 commit comments

Comments
 (0)