Running helpers spec separately fails, but works when running all the tests

12 views
Skip to first unread message

Javix

unread,
Feb 3, 2016, 10:05:43 AM2/3/16
to rspec
I can't figure out why when I run all the tests with
rspec

command, they all are run.

If I run a helper spec separately like that:

rspec spec/helpers/application_helper_spec.rb


it fails as follows:

spec/helpers/application_helper_spec.rb:3:in `<top (required)>': uninitialized constant ApplicationHelper (NameError)



 from /Users/serge-mac/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `
load'

 from /Users/serge-mac/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'


 
from /Users/serge-mac/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'

 from /Users/serge-mac/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `
load_spec_files'

 from /Users/serge-mac/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'


 
from /Users/serge-mac/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:88:in `run'

 from /Users/serge-mac/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `
run'

 from /Users/serge-mac/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'


 
from /Users/serge-mac/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.2/exe/rspec:4:in `<top (required)>'

 from /Users/serge-mac/.rvm/gems/ruby-2.3.0/bin/rspec:23:in `
load'

 from /Users/serge-mac/.rvm/gems/ruby-2.3.0/bin/rspec:23:in `<main>'


 
from /Users/serge-mac/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'

 

 from /Users/serge-mac/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'



Here is the application_helper_spec.rb:


equire 'spec_helper'


describe ApplicationHelper, :type => :helper do

  describe "generating full title" do

    let(:base_title) { I18n.t(:base_title)}

    it "should concatenate page title with base title" do

      expect(full_title('some page title')).to eq("#{base_title} | some page title")

    end

...

end

end



Javix

unread,
Feb 3, 2016, 10:09:07 AM2/3/16
to rspec
Figured out myself.
That was a wrong copy-paste from an old project: instead of requiring spec_helper (which fails), I had to change it to require rails_helper and it worked. :) 
Reply all
Reply to author
Forward
0 new messages