Browse Source

Request specs over feature specs

pull/134/head
baarkerlounger 4 years ago committed by Paul Robert Lloyd
parent
commit
c51e1b91f9
  1. 15
      spec/features/user_spec.rb
  2. 41
      spec/requests/user_controller_spec.rb

15
spec/features/user_spec.rb

@ -144,21 +144,6 @@ RSpec.describe "User Features" do
expect(page).to have_current_path("/users/#{user.id}")
end
it "main page is present and accessible" do
visit("/users/#{user.id}")
expect(page).to have_content("Your account")
end
it "personal details page is present and accessible" do
visit("/users/#{user.id}/edit")
expect(page).to have_content("Change your personal details")
end
it "edit password page present and accessible" do
visit("users/#{user.id}/password/edit")
expect(page).to have_content("Change your password")
end
it "can navigate to change your password page from main account page" do
visit("/users/#{user.id}")
find('[data-qa="change-password"]').click

41
spec/requests/user_controller_spec.rb

@ -0,0 +1,41 @@
require "rails_helper"
require_relative "../support/devise"
RSpec.describe UsersController, type: :request do
let(:user) { FactoryBot.create(:user) }
let(:headers) { { "Accept" => "text/html" } }
let(:page) { Capybara::Node::Simple.new(response.body) }
describe "#show" do
before do
sign_in user
get "/users/#{user.id}", headers: headers, params: {}
end
it "show the user details" do
expect(page).to have_content("Your account")
end
end
describe "#edit" do
before do
sign_in user
get "/users/#{user.id}/edit", headers: headers, params: {}
end
it "show the edit personal details page" do
expect(page).to have_content("Change your personal details")
end
end
describe "#edit_password" do
before do
sign_in user
get "/users/#{user.id}/password/edit", headers: headers, params: {}
end
it "show the edit password page" do
expect(page).to have_content("Change your password")
end
end
end
Loading…
Cancel
Save