I'm going through Chapter 5 of RailsTutorial.org.
I have one test that I can't get to work no matter what I do. It passes when I put in the string the variable passes, but not when I put in the variable itself.
The error says undefined method 'full_title' (I couldn't find an answer after 30 min of browsing related questions after typing this up.)
Doing a superficial test, the desired content displays in the app, the title includes the full title with 'Sign up.'
Here is my code:
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
before { visit signup_path }
it { should have_selector('h1', text: 'Sign up') }
it { should have_selector('title', text: full_title('Sign up')) }
end
end
This is when the error says undefined method 'full_title'
It passes when I use this code:
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
before { visit signup_path }
it { should have_selector('h1', text: 'Sign up') }
it { should have_selector('title', text: 'Ruby on Rails Tutorial Sample App | Sign up') }
end
end
Thanks for your help! Adam
Restarting Guard fixes the problem.
To make the full_title
tests work, make sure to create spec/support/utilities.rb
from Listing 5.26
I skipped it by accident since it looks exactly like a duplicate method from Chapter 3.
I got the same problem, and here is how I solved it. Make sure that the file /spec/support/utilities.rb
has the following code:
include ApplicationHelper
This will fix your problem.
If write: config.include ApplicationHelper into spec_helper.rb everything will work fine, but it that moment I don't see logic to have file utilities.rb into spec/support (everything works without it)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With