glennm
glennm

Reputation: 335

My rspec test won't pass

I'm following Chapter 5 of the Michael Hartl tutorial. When I run the following from the root directory,

$ bundle exec rspec spec/

I get the following error:

No DRb server is running. running in local process instead ...
c:/sites/sample_app/spec/helpers/applcation_helper_spec.rb:1:in '<top required>>': uninitialized constant ApplicationHelper (NameError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:746:in 'loud'
.
.

I thought I should try and isolate which files were failing, and I found 2 files that came up with the above error (the rest ran the test and passed with 0 failing). Those that failed were:

1) spec/helpers/application_helper_spec.rb

describe ApplicationHelper do

  describe "full_title" do
    it "should include the page name" do
      full_title("foo").should =~ /foo/
    end

    it "should include the base name" do
      full_title("foo").should =~ /^Ruby on Rails Tutorial Sample App/
    end

    it "should not include a bar for the home page" do
      full_title("").should_not =~ /\|/
    end
  end
end

2) spec/support/utilities.rb

include ApplicationHelper

Upvotes: 0

Views: 899

Answers (1)

glennm
glennm

Reputation: 335

After reading around, I found out rspec needs spork running (not sure why it works on some tests and not on others?). I forgot to require spec_helper, so I insert this in the first line of application_helper_spec.rb and it worked.

require 'spec_helper'  

Here's the post that lead me to the answer.

Upvotes: 1

Related Questions