diff --git a/Changelog.md b/Changelog.md index f6b9f562ac..79f7b34cca 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/lib/rspec/rails/example/view_example_group.rb b/lib/rspec/rails/example/view_example_group.rb index 94275d1240..f78d3878d5 100644 --- a/lib/rspec/rails/example/view_example_group.rb +++ b/lib/rspec/rails/example/view_example_group.rb @@ -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 diff --git a/spec/rspec/rails/example/view_example_group_spec.rb b/spec/rspec/rails/example/view_example_group_spec.rb index 430cdc003a..5812a22f3b 100644 --- a/spec/rspec/rails/example/view_example_group_spec.rb +++ b/spec/rspec/rails/example/view_example_group_spec.rb @@ -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 {