Skip to content

Commit

Permalink
If a view example's description contains no path elements, then do no…
Browse files Browse the repository at this point in the history
…t attempt to load a helper based on the example description.
  • Loading branch information
tinynumbers committed Jan 23, 2015
1 parent 0fb5483 commit 155dda5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec/rails/example/view_example_group.rb
Expand Up @@ -14,7 +14,7 @@ module ViewExampleGroup
module ClassMethods
def _default_helper
base = metadata[:description].split('/')[0..-2].join('/')
(base.camelize + 'Helper').constantize if base
(base.camelize + 'Helper').constantize unless base.to_s.empty?
rescue NameError
nil
end
Expand Down
9 changes: 9 additions & 0 deletions spec/rspec/rails/example/view_example_group_spec.rb
Expand Up @@ -34,6 +34,15 @@ module ::Namespaced; module ThingsHelper; end; end
}.not_to raise_error
end

it 'operates normally when the view has no path and there is a Helper class defined' do
class ::Helper; end
expect {
RSpec::Core::ExampleGroup.describe 'show.html.erb' do
include ViewExampleGroup
end
}.not_to raise_error
end

context 'application helper exists' do
before do
if !Object.const_defined? 'ApplicationHelper'
Expand Down

0 comments on commit 155dda5

Please sign in to comment.