Browse files

Dev: Fix helper_spec.feature from failing after the first run

Because we manually include `ApplicationHelper` into the `_view`
object, we can't have conflicting method names between the helpers.

This is not really something to worry about with user projects: I
believe most projects use `helper :all` and/or do not utilize
inheritance (include helper in a helper, with conflicting names in

Fixes #554
  • Loading branch information...
1 parent e09f6e5 commit 2a684525df38ebdbfb3fad0501766dbe57d9afd4 @justinko justinko committed Jun 2, 2012
Showing with 9 additions and 9 deletions.
  1. +8 −8 features/helper_specs/helper_spec.feature
  2. +1 −1 lib/rspec/rails/example/helper_example_group.rb
@@ -1,5 +1,5 @@
Feature: helper spec
Helper specs live in `spec/helpers`, or any example group with `:type =>
@@ -12,12 +12,12 @@ Feature: helper spec
on the `helper` object.
NOTE: helper methods defined in controllers are not included.
Scenario: helper method that returns a value
Given a file named "spec/helpers/application_helper_spec.rb" with:
require "spec_helper"
describe ApplicationHelper do
describe "#page_title" do
it "returns the default title" do
@@ -36,7 +36,7 @@ Feature: helper spec
When I run `rspec spec/helpers/application_helper_spec.rb`
Then the examples should all pass
Scenario: helper method that accesses an instance variable
Given a file named "spec/helpers/application_helper_spec.rb" with:
@@ -68,10 +68,10 @@ Feature: helper spec
require "spec_helper"
describe WidgetsHelper do
- describe "#page_title" do
+ describe "#widget_title" do
it "includes the app name" do
- assign(:title, "This Page")
- helper.page_title.should eq("The App: This Page")
+ assign(:title, "This Widget")
+ helper.widget_title.should eq("The App: This Widget")
@@ -87,7 +87,7 @@ Feature: helper spec
And a file named "app/helpers/widgets_helper.rb" with:
module WidgetsHelper
- def page_title
+ def widget_title
"#{app_name}: #{@title}"
@@ -18,7 +18,7 @@ def determine_default_helper_class(ignore)
# mixed in, along with any of the built-in rails helpers.
def helper
_view.tap do |v|
- v.extend(ApplicationHelper) if defined?(ApplicationHelper)
+ v.singleton_class.send(:include, ApplicationHelper) if defined?(ApplicationHelper)

0 comments on commit 2a68452

Please sign in to comment.