I've completed Chapter 5 and all the exercises. As part of the final exercise, MH has you write tests for the ApplicationHelper method.
Once that is done, individual tests pass with:
shift-command-T
in ST2 (using the sublime-text-2-ruby-tests package) rspec spec/requests/user_pages_spec.rb
in the terminalrspec spec/requests/static_pages_spec.rb
in the terminalHowever, if I run all tests with rspec spec/
in the terminal I get this error:
/Users/anonymouscoward/rails/railstut/sample_app/spec/helpers/
application_helper_spec.rb:1:in `<top (required)>': uninitialized
constant ApplicationHelper (NameError)
If I run spork and try rspec spec/
again, all tests pass.
I'm not sure I understand why this works the way it does, or whether I'll always need to have spork running in the future when I want to run all my tests. Thanks.
I'm not sure, but maybe you forgot to require spec_helper. If so, just insert this in the first line of application_helper_spec.rb
require 'spec_helper'
spec_helper.rb
loads the Rails environment and makes ApplicationHelper available - rda3000 2012-04-06 03:26
I ran into the same issue. Thanks for the fix!
I found this response on another forum, which seems helpful in thinking about how Spork relates to Rspec.
RSpec does not "run" spec_helper. By default, rspec loads files that end with "_spec.rb" and it is up to those files to require spec_helper.rb. http://www.ruby-forum.com/topic/167768
describe "ApplicationHelper" do
ApplicationHelper should be a string, not constant