Skip to content

Tests fail if there is a class named '*Helper' used in a model #1854

@mri-dula

Description

@mri-dula

I created a file named search_helper.rb inside the app/helpers folder.
It had a simple class inside, nothing fancy:
app/helpers/search_helper.rb:

class SearchHelper
    #some_code
end

It was used in a model:
app/models/end_user.rb:

search_helper = SearchHelper.new

After this change, when I ran the test cases, all of them failed with the following error(s):

An error occurred while loading ./spec/models/venue_spec.rb.
Failure/Error: require 'rspec/rails'

NameError:
uninitialized constant ActionView::TestCase::Behavior
# ./spec/rails_helper.rb:7:in `<top (required)>'
# ./spec/models/venue_spec.rb:1:in `<top (required)>'

When I renamed SearchHelper to SearchManager, the test cases started working again. Looks like Rspec had a problem with the word Helper.

My Versions:
Rails 5.0.4
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
Mac OS Sierra
rspec-rails 3.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions