RSpec fails for no obvious reason
-
04-12-2019 - |
Question
So I'm using rspec
to test my code as I'm going through the Rails Tutorial, and I keep getting this error when I test the code in listing 3.20. Everything checks out when I look at it with my eyeball, but RSpec doesn't seem to like it.
(Note that I just did one of the pages, not all three because they all give the same error)
james@tristan:~/rails_projects/sample_app$ rspec spec/controllers/pages_controller_spec.rb
F...
Failures:
1) PagesController should have the right title Failure/Error: response.should have_selector("title", expected following output to contain a | Home tag: # ./spec/controllers/pages_controller_spec.rb:13:in `block (2 levels) in '
Finished in 0.97999 seconds 4 examples, 1 failure
james@tristan:~/rails_projects/sample_app$
La solution
At the top of that spec file it says:
before(:each) do
#
# Define @base_title here.
#
end
Does your spec assign a value to @base_title
?