Hartl Rails Section 8.3 rspec Error

I am working on a hartl rails tutorial

I am at the end of section 8.3, the application works correctly, but I get an rspec error

1) User pages signup with valid information after saving the user 
 Failure/Error: it { should have_link('Sign out') }
   expected link "Sign out" to return something
 # ./spec/requests/user_pages_spec.rb:48:in `block (5 levels) in <top (required)>'

the user_pages_spec.rb part involved in this is

it "should create a user" do
    expect { click_button submit }.to change(User, :count).by(1)
  end  
  describe "after saving the user" do
    it { should have_link('Sign out') }
  end

I lost a little how to fix it. There are other posts similar to this, but alas, I cannot get their solutions to work in my case. Thank you

+3
source share
1 answer

It looks like you need to create an account before checking the link. Tests more than you posted. Here is a snippet of code that I used when viewing the tutorial.

describe "after saving the user" do
  before { click_button "Create my account" }
  it { should have_link('Sign out') }
end
+5
source

All Articles