Permalink
Browse files

Ensure namespaced helpers are included automatically

-- Closes #446.
  • Loading branch information...
1 parent 1ac8709 commit c00355f3626035746a6018b300378da113e2e736 @dolzenko dolzenko committed with dchelimsky Sep 28, 2011
View
@@ -4,6 +4,7 @@
* Enhancements
* Eliminate deprecation warnings in generated view specs in Rails 3.2
+ * Ensure namespaced helpers are included automatically (Evgeniy Dolzhenko)
### 2.8.0.rc2 / 2011-12-19
@@ -10,7 +10,7 @@ module ViewExampleGroup
module ClassMethods
def _default_helper
- base = metadata[:example_group][:description].split('/').first
+ base = metadata[:example_group][:description].split('/')[0..-2].join('/')
(base.camelize + 'Helper').constantize if base
rescue NameError
nil
@@ -14,6 +14,7 @@ module RSpec::Rails
describe 'automatic inclusion of helpers' do
module ::ThingsHelper; end
+ module ::Namespaced; module ThingsHelper; end; end
it 'includes the helper with the same name' do
group = RSpec::Core::ExampleGroup.describe 'things/show.html.erb'
@@ -23,6 +24,14 @@ module ::ThingsHelper; end
end
end
+ it 'includes the namespaced helper with the same name' do
+ group = RSpec::Core::ExampleGroup.describe 'namespaced/things/show.html.erb'
+ group.should_receive(:helper).with(Namespaced::ThingsHelper)
+ group.class_eval do
+ include ViewExampleGroup
+ end
+ end
+
it 'operates normally when no helper with the same name exists' do
raise 'unexpected constant found' if Object.const_defined?('ClocksHelper')
lambda {

0 comments on commit c00355f

Please sign in to comment.