Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure namespaced helpers are included automatically

-- Closes #446.
  • Loading branch information...
commit c00355f3626035746a6018b300378da113e2e736 1 parent 1ac8709
@dolzenko dolzenko authored dchelimsky committed
View
1  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
View
2  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
View
9 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 {
Please sign in to comment.
Something went wrong with that request. Please try again.