Note that there are some explanatory texts on larger screens.

plurals
  1. PORails Tutorial chapter 9.1.1 sign_in unrecognised
    text
    copied!<p>I'm working through Michael Hartl's tutorial.</p> <p>I've just introduced these tests to <code>user_pages_spec.rb</code></p> <pre><code>describe "edit" do let(:user) { FactoryGirl.create(:user) } before do sign_in user visit edit_user_path(user) end describe "page" do it { should have_content("Update your profile") } it { should have_title("Edit user") } it { should have_link('change', href: 'http://gravatar.com/emails') } end describe "with invalid information" do before { click_button "Save changes" } it { should have_content('error') } end end </code></pre> <p>My <code>sessions_helper.rb</code> file is:</p> <pre><code>module SessionsHelper def sign_in(user) remember_token = User.new_remember_token cookies.permanent[:remember_token] = remember_token user.update_attribute(:remember_token, User.encrypt(remember_token)) self.current_user= user end def current_user=(user) @current_user=user end def current_user remember_token = User.encrypt(cookies[:remember_token]) @current_user ||= User.find_by(remember_token: remember_token) end def signed_in? !current_user.nil? end def sign_out self.current_user = nil cookies.delete(:remember_token) end end </code></pre> <p>When I run the tests, all 4 fail with error messages along the lines of:</p> <pre><code>1) User pages edit page Failure/Error: sign_in user NoMethodError: undefined method `sign_in' for #&lt;RSpec::Core::ExampleGroup::Nested_1::Nested_4::Nested_1:0x007fcd57928138&gt; # ./spec/requests/user_pages_spec.rb:90:in `block (3 levels) in &lt;top (required)&gt;' </code></pre> <p>How should I get the user pages specs to pick up the sign_in function from sessions_helper? users_controller can use it; it's just the test files that I've done wrong.</p> <p>I tried including SessionsHelper explicitly and it didn't help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload