Skip to content

Commit 03afd47

Browse files
committed
Merge pull request #1289 from tinynumbers/view-example-helper-class-bug
If a view example's description contains no path elements, then do not attempt to load a helper based on the example description.
2 parents df9bbc0 + 155dda5 commit 03afd47

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/rspec/rails/example/view_example_group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module ViewExampleGroup
1414
module ClassMethods
1515
def _default_helper
1616
base = metadata[:description].split('/')[0..-2].join('/')
17-
(base.camelize + 'Helper').constantize if base
17+
(base.camelize + 'Helper').constantize unless base.to_s.empty?
1818
rescue NameError
1919
nil
2020
end

spec/rspec/rails/example/view_example_group_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ module ::Namespaced; module ThingsHelper; end; end
3434
}.not_to raise_error
3535
end
3636

37+
it 'operates normally when the view has no path and there is a Helper class defined' do
38+
class ::Helper; end
39+
expect {
40+
RSpec::Core::ExampleGroup.describe 'show.html.erb' do
41+
include ViewExampleGroup
42+
end
43+
}.not_to raise_error
44+
end
45+
3746
context 'application helper exists' do
3847
before do
3948
if !Object.const_defined? 'ApplicationHelper'

0 commit comments

Comments
 (0)